mirror of
https://github.com/guzzle/guzzle.git
synced 2025-02-26 11:05:28 +01:00
Adopting composer for dependency management Updating LICENSE, travis build file, making better use of git ignores, and remove unused build target Removing @author tags. Use the commit history for a changelog. Moving files from build folder to / Adding min build target to product a Guzzle only phar with no autoloader [Common] Accepting ZF1 or ZF2 cache in ZendCacheAdapter [Common] Optimizing Stream wrapper and EntityBody abstractions. [Common] [Http] Migrating from Guzzle event system to the Symfony2 event dispatcher [Common] Moved Inflector and Inspector to Service namespace [Http] Simplifying Guzzle\Guzzle curl detection [Http] Removing Guzzle\Http\Pool and now using Guzzle\Http\Curl\CurlMulti [Http] The helper methods from Guzzle\Http\Message\RequestFactory have been removed to prevent confusion and encourage developers to use Guzzle\Http\Client to create requests. [Http] Clients can now send one or more requests in an array using the send() method, so the batch() method was removed. [Http] Updating curl multi to allow blocking calls while sending other transfers [Http] Making the Request::hasHeader method more intuitive. Guzzle\Http\Message\AbstractMessage::hasHeader() now returns true if the header is found using exact matching. If the header is found using a regex or case-insensitive match, then it will return the name of the found header. [Http] Removing content-type guessing from EntityBody based on file extension and solely using finfo. [Http] Adding basic auth plugin [Http] Cleaning up CookieJar and CurlMulti [Http] Removing custom rawurlencode from QueryString because PHP 5.3 now properly deals with tilde characters. [Http] Minor optimization to parsing messages in RequestFactory [Http] Adding Guzzle\Http\Client for developers that don't need commands or service descriptions [Http] Making it easier to set a global User-Agent header for a Guzzle\Http\Client [Http] Fixing the discrepancies between the ClientInterface and Guzzle\Http\Client [Http] Adding the ability to set and retrieve tokenized headers from Requests and Responses [Service] Ditching NIH filters and using the Symfony2 validator [Service] Moving most service building logic to the ServiceBuilder::factory method so that it is easier to build custom config readers. [Service] Allowing deep nested command inheritance. [Service] Cleaning up Inflector caching. [Service] Getting rid of concept of can_batch because everything is now sent in parallel. [Service] Adding a JSON description builder. [Service] Cleaning up ResourceIteratorApplyBatched. [Service] Removing caching stuff from ServiceBuilder because the data being cached is extremely fast to generate. [Service] Added a method to serialize the ServiceDescription in case a ServiceDescription needs to be cached in an application. [Service] Making description builders use static methods. [Service] Adding support to include other description files for XML and JSON description builders. [Service] Adding support for filters to ApiCommands [Service] Using {{}} instead of $. to reference other services as a dependency for another service
92 lines
2.8 KiB
PHP
92 lines
2.8 KiB
PHP
<?php
|
|
|
|
namespace Guzzle\Tests;
|
|
|
|
use Guzzle\Guzzle;
|
|
use Guzzle\Common\Collection;
|
|
|
|
class GuzzleTest extends GuzzleTestCase
|
|
{
|
|
/**
|
|
* @covers Guzzle\Guzzle
|
|
*/
|
|
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());
|
|
}
|
|
|
|
/**
|
|
* @covers Guzzle\Guzzle::getHttpDate
|
|
*/
|
|
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'));
|
|
}
|
|
|
|
public function dataProvider()
|
|
{
|
|
return array(
|
|
array('this_is_a_test', '{{ a }}_is_a_{{ b }}', array(
|
|
'a' => 'this',
|
|
'b' => 'test'
|
|
)),
|
|
array('this_is_a_test', '{{abc}}_is_a_{{ 0 }}', array(
|
|
'abc' => 'this',
|
|
0 => 'test'
|
|
)),
|
|
array('this_is_a_test', '{{ abc }}_is_{{ not_found }}a_{{ 0 }}', array(
|
|
'abc' => 'this',
|
|
0 => 'test'
|
|
)),
|
|
array('this_is_a_test', 'this_is_a_test', array(
|
|
'abc' => 'this'
|
|
)),
|
|
array('_is_a_', '{{ abc }}_is_{{ not_found }}a_{{ 0 }}', array()),
|
|
);
|
|
}
|
|
|
|
/**
|
|
* @covers Guzzle\Guzzle::inject
|
|
* @dataProvider dataProvider
|
|
*/
|
|
public function testInjectsConfigData($output, $input, $config)
|
|
{
|
|
$this->assertEquals($output, Guzzle::inject($input, new Collection($config)));
|
|
}
|
|
|
|
/**
|
|
* @covers Guzzle\Guzzle::getCurlInfo
|
|
*/
|
|
public function testCachesCurlInfo()
|
|
{
|
|
Guzzle::reset();
|
|
$c = curl_version();
|
|
$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);
|
|
}
|
|
|
|
/**
|
|
* @covers Guzzle\Guzzle::getCurlInfo
|
|
* @covers Guzzle\Guzzle::reset
|
|
*/
|
|
public function testDeterminesIfCurlCanFollowLocation()
|
|
{
|
|
Guzzle::reset();
|
|
if (!ini_get('open_basedir')) {
|
|
$this->assertTrue(Guzzle::getCurlInfo('follow_location'));
|
|
} else {
|
|
$this->assertFalse(Guzzle::getCurlInfo('follow_location'));
|
|
}
|
|
}
|
|
} |