1
0
mirror of https://github.com/guzzle/guzzle.git synced 2025-02-24 10:03:27 +01:00

[Tests] Add coverage to Guzzle\Guzzle

This commit is contained in:
Michael Dowling 2011-04-15 15:38:57 -05:00
parent 330bf7b22a
commit 99264d1ad6
2 changed files with 7 additions and 10 deletions

View File

@ -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)',
@ -44,7 +43,6 @@ class Guzzle
$version['host']
);
}
// @codeCoverageIgnoreEnd
return self::$userAgent;
}
@ -69,13 +67,11 @@ class Guzzle
*/
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;

View File

@ -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());
}
@ -34,7 +33,6 @@ class GuzzleTest extends GuzzleTestCase
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'));
@ -76,10 +74,13 @@ class GuzzleTest extends GuzzleTestCase
*/
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);
}
/**