22
33namespace Swader \Diffbot \Test ;
44
5- use GuzzleHttp \Client ;
6- use GuzzleHttp \Message \Response ;
7- use GuzzleHttp \Stream \Stream ;
8- use GuzzleHttp \Subscriber \Mock ;
9- use Swader \Diffbot \Abstracts \Entity ;
5+ use Swader \Diffbot \Factory \Entity ;
106
11- class EntityIteratorTest extends \PHPUnit_Framework_TestCase
7+ class EntityIteratorTest extends ResponseProvider
128{
139
1410 /** @var array */
@@ -19,28 +15,11 @@ class EntityIteratorTest extends \PHPUnit_Framework_TestCase
1915 'Images/multi_images_smittenkitchen.json '
2016 ];
2117
22- protected function prepareResponses ()
23- {
24- if (empty ($ this ->responses )) {
25- $ mockInput = [];
26- foreach ($ this ->files as $ file ) {
27- $ mockInput [] = file_get_contents (__DIR__ . '/../Mocks/ ' . $ file );
28- }
29- unset($ file );
30- $ mock = new Mock ($ mockInput );
31- $ client = new Client ();
32- $ client ->getEmitter ()->attach ($ mock );
33- foreach ($ this ->files as $ file ) {
34- $ this ->responses [$ file ] = $ client ->get ('sampleurl.com ' );
35- }
36- unset($ file );
37- }
38- return $ this ->responses ;
39- }
18+ protected $ folder = '/../Mocks/ ' ;
4019
4120 public function testBadMethodCall ()
4221 {
43- $ ef = new \ Swader \ Diffbot \ Factory \ Entity ();
22+ $ ef = new Entity ();
4423 $ ei = $ ef ->createAppropriateIterator ($ this ->prepareResponses ()['Images/one_image_zola.json ' ]);
4524
4625 $ this ->setExpectedException ('BadMethodCallException ' );
@@ -49,7 +28,7 @@ public function testBadMethodCall()
4928
5029 public function testMagic ()
5130 {
52- $ ef = new \ Swader \ Diffbot \ Factory \ Entity ();
31+ $ ef = new Entity ();
5332 $ ei = $ ef ->createAppropriateIterator ($ this ->prepareResponses ()['Images/one_image_zola.json ' ]);
5433
5534 $ this ->assertEquals ('image ' , $ ei ->type );
@@ -63,7 +42,7 @@ public function testCount()
6342 'Images/multi_images_smittenkitchen.json ' => 9
6443 ];
6544
66- $ ef = new \ Swader \ Diffbot \ Factory \ Entity ();
45+ $ ef = new Entity ();
6746
6847 foreach ($ fileExpectations as $ fileName => $ expectation ) {
6948 $ ei = $ ef ->createAppropriateIterator ($ this ->prepareResponses ()[$ fileName ]);
@@ -73,17 +52,17 @@ public function testCount()
7352
7453 public function testGetResponse ()
7554 {
76- $ ef = new \ Swader \ Diffbot \ Factory \ Entity ();
55+ $ ef = new Entity ();
7756
7857 foreach ($ this ->files as $ fileName ) {
7958 $ ei = $ ef ->createAppropriateIterator ($ this ->prepareResponses ()[$ fileName ]);
80- $ this ->assertInstanceOf ('GuzzleHttp\ Message\Response ' , $ ei ->getResponse ());
59+ $ this ->assertInstanceOf ('Psr\Http\ Message\ResponseInterface ' , $ ei ->getResponse ());
8160 }
8261 }
8362
8463 public function testIteration ()
8564 {
86- $ ef = new \ Swader \ Diffbot \ Factory \ Entity ();
65+ $ ef = new Entity ();
8766 foreach ($ this ->files as $ fileName ) {
8867
8968 $ ei = $ ef ->createAppropriateIterator ($ this ->prepareResponses ()[$ fileName ]);
0 commit comments