22
33namespace FeedIo ;
44
5- use FeedIo \Adapter \ClientFactory ;
5+ use FeedIo \Adapter \Http \ Client ;
66use Nyholm \Psr7 \Response ;
77use Nyholm \Psr7 \Stream ;
88use PHPUnit \Framework \TestCase ;
99use Psr \Http \Client \ClientInterface ;
10- use Psr \Http \Message \StreamInterface ;
1110
1211/**
1312 * Generated by PHPUnit_SkeletonGenerator on 2015-02-23 at 20:31:12.
@@ -27,49 +26,45 @@ protected function setUp(): void
2726 {
2827 $ html = file_get_contents (__DIR__ ."/../samples/expected-atom.xml " );
2928
30- $ adapterClient = $ this ->getMockForAbstractClass ('\FeedIo\Adapter\ClientInterface ' );
31- $ clientFactory = $ this ->createMock (ClientFactory::class);
32- $ clientFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ adapterClient );
29+ $ client = $ this ->createMock (ClientInterface::class);
30+ $ adapterClient = new Client ($ client );
3331
3432 $ stream = $ this ->createMock (Stream::class);
3533 $ stream ->expects ($ this ->any ())->method ('getContents ' )->willReturn ($ html );
3634
3735 $ psrResponse = $ this ->createMock (Response::class);
3836 $ psrResponse ->expects ($ this ->any ())->method ('getBody ' )->willReturn ($ stream );
3937 $ psrResponse ->expects ($ this ->any ())->method ('getStatusCode ' )->willReturn (200 );
40-
41- $ client = $ this ->createMock (ClientInterface::class);
4238 $ client ->method ('sendRequest ' )->willReturn ($ psrResponse );
4339
4440 $ adapterResponse = $ this ->createMock ('FeedIo\Adapter\ResponseInterface ' );
4541 $ adapterResponse ->expects ($ this ->any ())->method ('isModified ' )->willReturn (true );
4642 $ adapterResponse ->expects ($ this ->any ())->method ('getBody ' )->willReturn ($ html );
4743 $ adapterResponse ->expects ($ this ->any ())->method ('getLastModified ' )->willReturn (new \DateTime ());
48- $ adapterClient ->expects ($ this ->any ())->method ('getResponse ' )->willReturn ($ adapterResponse );
4944
5045 $ logger = new \Psr \Log \NullLogger ();
5146
52- $ this ->object = new FeedIo ($ client , $ logger , new Specification ($ logger ), $ clientFactory );
47+ $ this ->object = new FeedIo ($ adapterClient , $ logger , new Specification ($ logger ));
5348 }
5449
5550 /**
56- * @covers FeedIo\FeedIo::__construct
57- * @covers FeedIo\FeedIo::loadCommonStandards
51+ * @covers \ FeedIo\FeedIo::__construct
52+ * @covers \ FeedIo\FeedIo::loadCommonStandards
5853 */
5954 public function testConstruct ()
6055 {
61- $ client = $ this ->getMockForAbstractClass (ClientInterface::class);
62- $ feedIo = new FeedIo ($ client , new \Psr \Log \NullLogger ());
56+ $ client = $ this ->createMock (ClientInterface::class);
57+ $ adapterClient = new Client ($ client );
58+ $ feedIo = new FeedIo ($ adapterClient , new \Psr \Log \NullLogger ());
6359 $ this ->assertInstanceOf ('\FeedIo\Reader ' , $ feedIo ->getReader ());
6460 }
6561
6662 public function testDiscovery ()
6763 {
6864 $ html = file_get_contents (__DIR__ ."/../samples/discovery.html " );
6965
70- $ adapterClient = $ this ->getMockForAbstractClass ('\FeedIo\Adapter\ClientInterface ' );
71- $ clientFactory = $ this ->createMock (ClientFactory::class);
72- $ clientFactory ->expects ($ this ->once ())->method ('create ' )->willReturn ($ adapterClient );
66+ $ client = $ this ->createMock (ClientInterface::class);
67+ $ adapterClient = new Client ($ client );
7368
7469 $ stream = $ this ->createMock (Stream::class);
7570 $ stream ->expects ($ this ->any ())->method ('getContents ' )->willReturn ($ html );
@@ -78,14 +73,12 @@ public function testDiscovery()
7873 $ psrResponse ->method ('getBody ' )->willReturn ($ stream );
7974 $ psrResponse ->method ('getStatusCode ' )->willReturn (200 );
8075
81- $ client = $ this ->createMock (ClientInterface::class);
8276 $ client ->method ('sendRequest ' )->willReturn ($ psrResponse );
8377
8478 $ adapterResponse = $ this ->createMock ('FeedIo\Adapter\ResponseInterface ' );
8579 $ adapterResponse ->expects ($ this ->any ())->method ('getBody ' )->willReturn ($ html );
86- $ adapterClient ->expects ($ this ->any ())->method ('getResponse ' )->willReturn ($ adapterResponse );
8780
88- $ feedIo = new FeedIo ($ client , new \Psr \Log \NullLogger (), null , $ clientFactory );
81+ $ feedIo = new FeedIo ($ adapterClient , new \Psr \Log \NullLogger (), null );
8982 $ urls = $ feedIo ->discover ('https://example.org/feed ' );
9083
9184 $ this ->assertCount (2 , $ urls );
@@ -99,15 +92,15 @@ public function testWithModifiedSince()
9992 }
10093
10194 /**
102- * @covers FeedIo\FeedIo::getDateTimeBuilder
95+ * @covers \ FeedIo\FeedIo::getDateTimeBuilder
10396 */
10497 public function testGetDateTimeBuilder ()
10598 {
10699 $ this ->assertInstanceOf ('\FeedIo\Rule\DateTimeBuilder ' , $ this ->object ->getDateTimeBuilder ());
107100 }
108101
109102 /**
110- * @covers FeedIo\FeedIo::getReader
103+ * @covers \ FeedIo\FeedIo::getReader
111104 */
112105 public function testGetReader ()
113106 {
@@ -116,7 +109,7 @@ public function testGetReader()
116109
117110
118111 /**
119- * @covers FeedIo\FeedIo::read
112+ * @covers \ FeedIo\FeedIo::read
120113 */
121114 public function testRead ()
122115 {
@@ -126,8 +119,8 @@ public function testRead()
126119 }
127120
128121 /**
129- * @covers FeedIo\FeedIo::format
130- * @covers FeedIo\FeedIo::logAction
122+ * @covers \ FeedIo\FeedIo::format
123+ * @covers \ FeedIo\FeedIo::logAction
131124 */
132125 public function testFormat ()
133126 {
@@ -139,7 +132,7 @@ public function testFormat()
139132 }
140133
141134 /**
142- * @covers FeedIo\FeedIo::toRss
135+ * @covers \ FeedIo\FeedIo::toRss
143136 */
144137 public function testToRss ()
145138 {
@@ -150,7 +143,7 @@ public function testToRss()
150143 }
151144
152145 /**
153- * @covers FeedIo\FeedIo::toAtom
146+ * @covers \ FeedIo\FeedIo::toAtom
154147 */
155148 public function testToAtom ()
156149 {
@@ -161,7 +154,7 @@ public function testToAtom()
161154 }
162155
163156 /**
164- * @covers FeedIo\FeedIo::toJson
157+ * @covers \ FeedIo\FeedIo::toJson
165158 */
166159 public function testToJson ()
167160 {
0 commit comments