diff --git a/tests/phpunit/Unit/CachedCurlRequestTest.php b/tests/phpunit/Unit/CachedCurlRequestTest.php index 68ac621..d62a0b6 100644 --- a/tests/phpunit/Unit/CachedCurlRequestTest.php +++ b/tests/phpunit/Unit/CachedCurlRequestTest.php @@ -160,4 +160,26 @@ public function testDefinedConstants() { } } + public function testDeprecatedFunctions() { + + $cache = $this->getMockBuilder( '\Onoi\Cache\Cache' ) + ->disableOriginalConstructor() + ->getMockForAbstractClass(); + + $instance = new CachedCurlRequest( curl_init(), $cache ); + + $instance->setExpiryInSeconds( 42 ); + $instance->setCachePrefix( 'Foo' ); + + $this->assertEquals( + 42, + $instance->getOption( ONOI_HTTP_REQUEST_RESPONSECACHE_TTL ) + ); + + $this->assertEquals( + 'Foo', + $instance->getOption( ONOI_HTTP_REQUEST_RESPONSECACHE_PREFIX ) + ); + } + } diff --git a/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php b/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php index aa1b0cb..26ea8e0 100644 --- a/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php +++ b/tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php @@ -20,7 +20,7 @@ public function setUp() { stream_wrapper_unregister( 'http' ); $return = stream_wrapper_register( - 'http', + 'http', 'Onoi\HttpRequest\Tests\MockHttpStreamWrapper' ); @@ -77,6 +77,25 @@ public function testFollowLocation( $url, $urlComponent, $followLocation, $expec ); } + public function testToReturnInvalidResource() { + + $instance = $this->getMockBuilder( '\Onoi\HttpRequest\SocketRequest' ) + ->disableOriginalConstructor() + ->setMethods( array( 'getResourceFromSocketClient' ) ) + ->getMock(); + + $instance->expects( $this->once() ) + ->method( 'getResourceFromSocketClient' ) + ->will( $this->returnValue( false ) ); + + $instance->setOption( ONOI_HTTP_REQUEST_URL, 'http://example.com/' ); + + $this->assertEquals( + false, + $instance->execute() + ); + } + public function locationProvider() { $urlComponent = array (