Skip to content

Commit

Permalink
[Tests] Add coverage to Guzzle\Guzzle
Browse files Browse the repository at this point in the history
  • Loading branch information
mtdowling committed Apr 15, 2011
1 parent 330bf7b commit 99264d1
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 10 deletions.
8 changes: 2 additions & 6 deletions src/Guzzle/Guzzle.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class Guzzle
*/
public static function getDefaultUserAgent()
{
// @codeCoverageIgnoreStart
if (!self::$userAgent) {
$version = self::getCurlInfo();
self::$userAgent = sprintf('Guzzle/%s (Language=PHP/%s; curl=%s; Host=%s)',
Expand All @@ -44,8 +43,7 @@ public static function getDefaultUserAgent()
$version['host']
);
}
// @codeCoverageIgnoreEnd


return self::$userAgent;
}

Expand All @@ -69,14 +67,12 @@ public static function getDefaultUserAgent()
*/
public static function getCurlInfo($type = null)
{
// @codeCoverageIgnoreStart
if (!self::$curl) {
self::$curl = curl_version();
// Check if CURLOPT_FOLLOWLOCATION is available
self::$curl['follow_location'] = !ini_get('open_basedir');
}
// @codeCoverageIgnoreEnd


if (!$type) {
return self::$curl;
} else if (isset(self::$curl[$type])) {
Expand Down
9 changes: 5 additions & 4 deletions tests/Guzzle/Tests/GuzzleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,10 @@ class GuzzleTest extends GuzzleTestCase
*/
public function testGetDefaultUserAgent()
{
Guzzle::reset();
$version = curl_version();
$agent = sprintf('Guzzle/%s (Language=PHP/%s; curl=%s; Host=%s)', Guzzle::VERSION, \PHP_VERSION, $version['version'], $version['host']);

$this->assertEquals($agent, Guzzle::getDefaultUserAgent());

// Get it from cache this time
$this->assertEquals($agent, Guzzle::getDefaultUserAgent());
}
Expand All @@ -34,7 +33,6 @@ public function testGetDefaultUserAgent()
public function testGetHttpDate()
{
$fmt = 'D, d M Y H:i:s \G\M\T';

$this->assertEquals(gmdate($fmt), Guzzle::getHttpDate('now'));
$this->assertEquals(gmdate($fmt), Guzzle::getHttpDate(strtotime('now')));
$this->assertEquals(gmdate($fmt, strtotime('+1 day')), Guzzle::getHttpDate('+1 day'));
Expand Down Expand Up @@ -76,10 +74,13 @@ public function testInjectsConfigData($output, $input, $config)
*/
public function testCachesCurlInfo()
{
Guzzle::reset();
$c = curl_version();
$this->assertInternalType('array', Guzzle::getCurlInfo());
$info = Guzzle::getCurlInfo();
$this->assertInternalType('array', $info);
$this->assertEquals(false, Guzzle::getCurlInfo('ewfewfewfe'));
$this->assertEquals($c['version'], Guzzle::getCurlInfo('version'));
$this->assertSame(Guzzle::getCurlInfo(), $info);
}

/**
Expand Down

0 comments on commit 99264d1

Please sign in to comment.