1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-01-17 21:38:16 +01:00

[Tests] Getting code coverage back to 100%

This commit is contained in:
Michael Dowling 2011-11-13 16:46:37 -06:00
parent a5bf022a31
commit 3946b93bbf
5 changed files with 40 additions and 1 deletions

View File

@ -50,9 +50,11 @@ class Inspector
*/
public static function getInstance()
{
// @coveCoverageIgnoreStart
if (!self::$instance) {
self::$instance = new self();
}
// @coveCoverageIgnoreEnd
return self::$instance;
}
@ -148,7 +150,7 @@ class Inspector
$matches = array();
// Get all of the @guzzle annotations from the class
preg_match_all('/' . self::GUZZLE_ANNOTATION . '\s+([A-Za-z0-9_\-\.]+)\s*([A-Za-z0-9]+=".+")*/', $doc, $matches);
if (!isset($matches[1])) {
if (empty($matches[1])) {
return array();
}

View File

@ -9,6 +9,7 @@ use Doctrine\Common\Cache\ArrayCache;
* CacheAdapter test case
*
* @author Michael Dowling <michael@guzzlephp.org>
* @covers Guzzle\Common\Cache\DoctrineCacheAdapter
*/
class CacheAdapterTest extends \Guzzle\Tests\GuzzleTestCase
{

View File

@ -13,6 +13,7 @@ use Guzzle\Tests\Common\Mock\MockFilter;
/**
* @author Michael Dowling <michael@guzzlephp.org>
* @covers Guzzle\Common\Inspector
*
* @guzzle test type="class:Guzzle\Tests\GuzzleTestCase"
* @guzzle bool_1 default="true" type="boolean"
@ -285,4 +286,15 @@ The supplied value is not an instance of stdClass: <string:123> supplied", $e->g
Requires that the min argument be >= 2 characters.
Requires that the max argument be <= 2 characters.", implode("\n", $result));
}
/**
* @covers Guzzle\Common\Inspector::parseDocBlock
*/
public function testVerifiesGuzzleAnnotations()
{
$this->assertEquals(
array(),
Inspector::getInstance()->parseDocBlock('testing')
);
}
}

View File

@ -10,6 +10,8 @@ use Guzzle\Common\Collection;
* Test class for ZendLogAdapter
*
* @author Michael Dowling <michael@guzzlephp.org>
* @covers Guzzle\Common\Log\AbstractLogAdapter
* @covers Guzzle\Common\Log\ZendLogAdapter
*/
class ZendLogAdapterTest extends \Guzzle\Tests\GuzzleTestCase
{

View File

@ -15,6 +15,7 @@ use Guzzle\Tests\Common\Mock\MockObserver;
/**
* @group server
* @author Michael Dowling <michael@guzzlephp.org>
* @covers Guzzle\Http\Curl\CurlFactory
*/
class CurlFactoryTest extends \Guzzle\Tests\GuzzleTestCase
{
@ -600,6 +601,7 @@ class CurlFactoryTest extends \Guzzle\Tests\GuzzleTestCase
/**
* @covers Guzzle\Http\Curl\CurlFactory
* @covers Guzzle\Http\Curl\CurlFactory::getConnectionsPerHost
* @depends testReleasesAllHandles
*/
public function testClosesHandlesWhenHandlesAreReleasedAndNeedToBeClosed()
@ -658,6 +660,7 @@ class CurlFactoryTest extends \Guzzle\Tests\GuzzleTestCase
/**
* @covers Guzzle\Http\Curl\CurlFactory::setMaxIdleTime
* @covers Guzzle\Http\Curl\CurlFactory::clean
* @covers Guzzle\Http\Curl\CurlFactory::getConnectionsPerHost
* @depends testReleasesAllHandles
*/
public function testPurgesConnectionsThatAreTooStaleBasedOnMaxIdleTime()
@ -712,4 +715,23 @@ class CurlFactoryTest extends \Guzzle\Tests\GuzzleTestCase
$this->assertEquals(0, $h->getUseCount());
$this->assertNotSame($curlHandle, $h->getHandle());
}
/**
* @covers Guzzle\Http\Curl\CurlFactory::getConnectionsPerHost
*/
public function testSkipsHostsThatDoNotMatch()
{
$f = CurlFactory::getInstance();
$f->releaseAllHandles(true);
$request1 = RequestFactory::get('http://www.yahoo.com/');
$request1->getCurlHandle();
$request2 = RequestFactory::get('http://www.google.com/');
$request2->getCurlHandle();
$this->assertEquals(1, $f->getConnectionsPerHost(null, 'www.yahoo.com:80'));
$this->assertEquals(1, $f->getConnectionsPerHost(null, 'www.google.com:80'));
$this->assertEquals(0, $f->getConnectionsPerHost(null, 'foo.com:80'));
$f->releaseAllHandles(true);
}
}