1212namespace Http \Adapter \Tests ;
1313
1414use Http \Adapter \HttpAdapterException ;
15- use Http \Adapter \Message \InternalRequestInterface ;
16- use Http \ Adapter \Message \ResponseInterface ;
15+ use Http \Adapter \Message \InternalRequest ;
16+ use Psr \ Http \Message \ResponseInterface ;
1717
1818/**
1919 * @author GeLo <geloen.eric@gmail.com>
@@ -82,153 +82,14 @@ public function testResetResponse()
8282 $ this ->assertNull ($ this ->exception ->getRequest ());
8383 }
8484
85- public function testCannotFetchUri ()
86- {
87- $ exception = HttpAdapterException::cannotFetchUri ('uri ' , 'adapter ' , 'error ' );
88-
89- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
90- $ this ->assertSame (
91- 'An error occurred when fetching the URI "uri" with the adapter "adapter" ("error"). ' ,
92- $ exception ->getMessage ()
93- );
94- }
95-
96- public function testCannotLoadCookieJar ()
97- {
98- $ exception = HttpAdapterException::cannotLoadCookieJar ('error ' );
99-
100- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
101- $ this ->assertSame ('An error occurred when loading the cookie jar ("error"). ' , $ exception ->getMessage ());
102- }
103-
104- public function testCannotSaveCookieJar ()
105- {
106- $ exception = HttpAdapterException::cannotSaveCookieJar ('error ' );
107-
108- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
109- $ this ->assertSame ('An error occurred when saving the cookie jar ("error"). ' , $ exception ->getMessage ());
110- }
111-
112- public function testHttpAdapterDoesNotExist ()
113- {
114- $ exception = HttpAdapterException::httpAdapterDoesNotExist ('adapter ' );
115-
116- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
117- $ this ->assertSame ('The http adapter "adapter" does not exist. ' , $ exception ->getMessage ());
118- }
119-
120- public function testHttpAdapterIsNotUsable ()
121- {
122- $ exception = HttpAdapterException::httpAdapterIsNotUsable ('adapter ' );
123-
124- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
125- $ this ->assertSame ('The http adapter "adapter" is not usable. ' , $ exception ->getMessage ());
126- }
127-
128- public function testHttpAdaptersAreNotUsable ()
129- {
130- $ exception = HttpAdapterException::httpAdaptersAreNotUsable ();
131-
132- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
133- $ this ->assertSame ('No http adapters are usable. ' , $ exception ->getMessage ());
134- }
135-
136- public function testHttpAdapterMustImplementInterface ()
137- {
138- $ exception = HttpAdapterException::httpAdapterMustImplementInterface ('class ' );
139-
140- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
141- $ this ->assertSame (
142- 'The class "class" must implement "Ivory\HttpAdapter\HttpAdapterInterface". ' ,
143- $ exception ->getMessage ()
144- );
145- }
146-
147- public function testDoesNotSupportSubAdapter ()
148- {
149- $ exception = HttpAdapterException::doesNotSupportSubAdapter ('adapter ' , 'subAdapter ' );
150-
151- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
152- $ this ->assertSame (
153- 'The adapter "adapter" does not support the sub-adapter "subAdapter". ' ,
154- $ exception ->getMessage ()
155- );
156- }
157-
158- public function testMaxRedirectsExceeded ()
159- {
160- $ exception = HttpAdapterException::maxRedirectsExceeded ('uri ' , 5 , 'adapter ' );
161-
162- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
163- $ this ->assertSame (
164- 'An error occurred when fetching the URI "uri" with the adapter "adapter" ("Max redirects exceeded (5)"). ' ,
165- $ exception ->getMessage ()
166- );
167- }
168-
169- public function testRequestIsNotValidWithObject ()
170- {
171- $ exception = HttpAdapterException::requestIsNotValid (new \stdClass ());
172-
173- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
174- $ this ->assertSame (
175- 'The request must be a string, an array or implement "Psr\Http\Message\RequestInterface" ("stdClass" given). ' ,
176- $ exception ->getMessage ()
177- );
178- }
179-
180- public function testRequestIsNotValidWithScalar ()
181- {
182- $ exception = HttpAdapterException::requestIsNotValid (true );
183-
184- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
185- $ this ->assertSame (
186- 'The request must be a string, an array or implement "Psr\Http\Message\RequestInterface" ("boolean" given). ' ,
187- $ exception ->getMessage ()
188- );
189- }
190-
191- public function testStreamIsNotValidWithObject ()
192- {
193- $ exception = HttpAdapterException::streamIsNotValid (new \stdClass (), 'wrapper ' , 'expected ' );
194-
195- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
196- $ this ->assertSame (
197- 'The stream "wrapper" only accepts a "expected" (current: "stdClass"). ' ,
198- $ exception ->getMessage ()
199- );
200- }
201-
202- public function testStreamIsNotValidWithScalar ()
203- {
204- $ exception = HttpAdapterException::streamIsNotValid (true , 'wrapper ' , 'expected ' );
205-
206- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
207- $ this ->assertSame (
208- 'The stream "wrapper" only accepts a "expected" (current: "boolean"). ' ,
209- $ exception ->getMessage ()
210- );
211- }
212-
213- public function testTimeoutExceeded ()
214- {
215- $ exception = HttpAdapterException::timeoutExceeded ('uri ' , 1.1 , 'adapter ' );
216-
217- $ this ->assertInstanceOf ('Http\Adapter\HttpAdapterException ' , $ exception );
218- $ this ->assertSame (
219- 'An error occurred when fetching the URI "uri" with the adapter "adapter" ("Timeout exceeded (1.10)"). ' ,
220- $ exception ->getMessage ()
221- );
222- }
223-
22485 /**
22586 * Creates a request mock
22687 *
227- * @return InternalRequestInterface |\PHPUnit_Framework_MockObject_MockObject
88+ * @return InternalRequest |\PHPUnit_Framework_MockObject_MockObject
22889 */
22990 private function createRequestMock ()
23091 {
231- return $ this ->getMock ('Http\Adapter\Message\InternalRequestInterface ' );
92+ return $ this ->getMock ('Http\Adapter\Message\InternalRequest ' );
23293 }
23394
23495 /**
@@ -238,6 +99,6 @@ private function createRequestMock()
23899 */
239100 private function createResponseMock ()
240101 {
241- return $ this ->getMock ('Http\Adapter \Message\ResponseInterface ' );
102+ return $ this ->getMock ('Psr\Http \Message\ResponseInterface ' );
242103 }
243104}
0 commit comments