Skip to content

Commit

Permalink
Improve coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
mwjames committed Nov 23, 2015
1 parent f37d201 commit e6b704d
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 1 deletion.
22 changes: 22 additions & 0 deletions tests/phpunit/Unit/CachedCurlRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
);
}

}
21 changes: 20 additions & 1 deletion tests/phpunit/Unit/MockedHttpStreamSocketRequestTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ public function setUp() {

stream_wrapper_unregister( 'http' );
$return = stream_wrapper_register(
'http',
'http',
'Onoi\HttpRequest\Tests\MockHttpStreamWrapper'
);

Expand Down Expand Up @@ -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 (
Expand Down

0 comments on commit e6b704d

Please sign in to comment.