summaryrefslogtreecommitdiff
path: root/vendor/guzzle/guzzle/tests/Guzzle
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/guzzle/guzzle/tests/Guzzle')
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/AbstractBatchDecoratorTest.php33
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchBuilderTest.php86
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureDivisorTest.php36
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureTransferTest.php52
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchCommandTransferTest.php83
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchRequestTransferTest.php80
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchSizeDivisorTest.php24
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchTest.php91
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/ExceptionBufferingBatchTest.php45
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/FlushingBatchTest.php40
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/HistoryBatchTest.php26
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/NotifyingBatchTest.php45
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterFactoryTest.php64
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterTest.php68
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/ClosureCacheAdapterTest.php94
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/NullCacheAdapterTest.php20
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php58
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/AbstractHasDispatcherTest.php63
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/CollectionTest.php529
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/EventTest.php62
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/BatchTransferExceptionTest.php21
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php66
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/VersionTest.php27
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/GuzzleTestCase.php235
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/AbstractEntityBodyDecoratorTest.php34
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/CachingEntityBodyTest.php249
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ClientTest.php601
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlHandleTest.php947
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiProxyTest.php110
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiTest.php455
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlVersionTest.php39
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/RequestMediatorTest.php67
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/EntityBodyTest.php182
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/CurlExceptionTest.php27
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/ExceptionTest.php66
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/MultiTransferExceptionTest.php51
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/IoEmittingEntityBodyTest.php47
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/AbstractMessageTest.php136
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/EntityEnclosingRequestTest.php434
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/HeaderFactoryTest.php29
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/LinkTest.php63
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparison.php135
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparisonTest.php115
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderTest.php162
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/PostFileTest.php88
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestFactoryTest.php616
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestTest.php639
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/ResponseTest.php677
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/MimetypesTest.php31
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/CommaAggregatorTest.php30
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/DuplicateAggregatorTest.php30
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/PhpAggregatorTest.php32
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryStringTest.php233
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ReadLimitEntityBodyTest.php81
-rwxr-xr-xvendor/guzzle/guzzle/tests/Guzzle/Tests/Http/RedirectPluginTest.php277
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Server.php191
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/StaticClientTest.php67
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/UrlTest.php303
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/server.js146
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/InflectorTest.php37
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/MemoizingInflectorTest.php46
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php45
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/AppendIteratorTest.php29
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/ChunkedIteratorTest.php52
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/FilterIteratorTest.php28
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MapIteratorTest.php28
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MethodProxyIteratorTest.php28
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ArrayLogAdapterTest.php23
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ClosureLogAdapterTest.php30
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/MessageFormatterTest.php143
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/PsrLogAdapterTest.php25
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/Zf2LogAdapterTest.php51
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/CustomResponseModel.php21
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ErrorResponseMock.php25
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ExceptionMock.php11
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockMulti.php11
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockObserver.php65
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockSubject.php7
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserProvider.php381
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserTest.php22
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserProvider.php225
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserTest.php58
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/PeclHttpMessageParserTest.php36
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/ParserRegistryTest.php33
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/AbstractUriTemplateTest.php113
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/PeclUriTemplateTest.php27
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/UriTemplateTest.php106
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Async/AsyncPluginTest.php93
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/AbstractBackoffStrategyTest.php86
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffLoggerTest.php110
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffPluginTest.php297
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CallbackBackoffStrategyTest.php31
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ConstantBackoffStrategyTest.php20
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CurlBackoffStrategyTest.php36
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ExponentialBackoffStrategyTest.php23
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/HttpBackoffStrategyTest.php47
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/LinearBackoffStrategyTest.php21
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ReasonPhraseBackoffStrategyTest.php32
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/TruncatedBackoffStrategyTest.php30
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CachePluginTest.php441
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CallbackCanCacheStrategyTest.php72
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php193
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCanCacheStrategyTest.php40
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultRevalidationTest.php248
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DenyRevalidationTest.php19
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/SkipRevalidationTest.php19
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/ArrayCookieJarTest.php385
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/FileCookieJarTest.php63
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php134
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieTest.php223
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php39
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/ErrorResponse/ErrorResponsePluginTest.php137
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/History/HistoryPluginTest.php140
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Log/LogPluginTest.php95
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/CommandContentMd5PluginTest.php97
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/Md5ValidatorPluginTest.php120
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Mock/MockPluginTest.php199
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Oauth/OauthPluginTest.php345
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/AbstractConfigLoaderTest.php149
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderLoaderTest.php177
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderTest.php317
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/CachingConfigLoaderTest.php43
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/ClientTest.php320
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/AbstractCommandTest.php16
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php54
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/CommandTest.php445
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultRequestSerializerTest.php122
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultResponseParserTest.php59
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/AliasFactoryTest.php76
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/CompositeFactoryTest.php124
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ConcreteClassFactoryTest.php49
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/MapFactoryTest.php37
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ServiceDescriptionFactoryTest.php68
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php110
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/BodyVisitorTest.php63
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/HeaderVisitorTest.php48
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/JsonVisitorTest.php60
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFieldVisitorTest.php33
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFileVisitorTest.php54
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php48
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/ResponseBodyVisitorTest.php20
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/XmlVisitorTest.php558
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/AbstractResponseVisitorTest.php29
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/BodyVisitorTest.php21
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/HeaderVisitorTest.php98
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/JsonVisitorTest.php157
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/ReasonPhraseVisitorTest.php21
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/StatusCodeVisitorTest.php21
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/XmlVisitorTest.php431
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/VisitorFlyweightTest.php53
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationCommandTest.php102
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationResponseParserTest.php335
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/OperationTest.php308
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ParameterTest.php411
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaFormatterTest.php61
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaValidatorTest.php326
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionLoaderTest.php177
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionTest.php240
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/CommandTransferExceptionTest.php66
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/InconsistentClientTransferExceptionTest.php15
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/ValidationExceptionTest.php17
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php31
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php32
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php30
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php7
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php36
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php42
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/CompositeResourceIteratorFactoryTest.php37
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/MapResourceIteratorFactoryTest.php40
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ModelTest.php65
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorClassFactoryTest.php41
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorTest.php184
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/PhpStreamRequestFactoryTest.php172
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/StreamTest.php189
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/FileBody.txt0
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/bar.json3
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/baz.json3
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/foo.json8
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/recursive.json3
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/mock_response3
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json1.json18
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json2.json11
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/services.json71
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service.json40
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service2.json7
-rw-r--r--vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service_3.json40
186 files changed, 21931 insertions, 0 deletions
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/AbstractBatchDecoratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/AbstractBatchDecoratorTest.php
new file mode 100644
index 0000000..951738d
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/AbstractBatchDecoratorTest.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\Batch;
+
+/**
+ * @covers Guzzle\Batch\AbstractBatchDecorator
+ */
+class AbstractBatchDecoratorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testProxiesToWrappedObject()
+ {
+ $batch = new Batch(
+ $this->getMock('Guzzle\Batch\BatchTransferInterface'),
+ $this->getMock('Guzzle\Batch\BatchDivisorInterface')
+ );
+
+ $decoratorA = $this->getMockBuilder('Guzzle\Batch\AbstractBatchDecorator')
+ ->setConstructorArgs(array($batch))
+ ->getMockForAbstractClass();
+
+ $decoratorB = $this->getMockBuilder('Guzzle\Batch\AbstractBatchDecorator')
+ ->setConstructorArgs(array($decoratorA))
+ ->getMockForAbstractClass();
+
+ $decoratorA->add('foo');
+ $this->assertFalse($decoratorB->isEmpty());
+ $this->assertFalse($batch->isEmpty());
+ $this->assertEquals(array($decoratorB, $decoratorA), $decoratorB->getDecorators());
+ $this->assertEquals(array(), $decoratorB->flush());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchBuilderTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchBuilderTest.php
new file mode 100644
index 0000000..4da09d3
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchBuilderTest.php
@@ -0,0 +1,86 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\BatchBuilder;
+
+/**
+ * @covers Guzzle\Batch\BatchBuilder
+ */
+class BatchBuilderTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private function getMockTransfer()
+ {
+ return $this->getMock('Guzzle\Batch\BatchTransferInterface');
+ }
+
+ private function getMockDivisor()
+ {
+ return $this->getMock('Guzzle\Batch\BatchDivisorInterface');
+ }
+
+ private function getMockBatchBuilder()
+ {
+ return BatchBuilder::factory()
+ ->transferWith($this->getMockTransfer())
+ ->createBatchesWith($this->getMockDivisor());
+ }
+
+ public function testFactoryCreatesInstance()
+ {
+ $builder = BatchBuilder::factory();
+ $this->assertInstanceOf('Guzzle\Batch\BatchBuilder', $builder);
+ }
+
+ public function testAddsAutoFlush()
+ {
+ $batch = $this->getMockBatchBuilder()->autoFlushAt(10)->build();
+ $this->assertInstanceOf('Guzzle\Batch\FlushingBatch', $batch);
+ }
+
+ public function testAddsExceptionBuffering()
+ {
+ $batch = $this->getMockBatchBuilder()->bufferExceptions()->build();
+ $this->assertInstanceOf('Guzzle\Batch\ExceptionBufferingBatch', $batch);
+ }
+
+ public function testAddHistory()
+ {
+ $batch = $this->getMockBatchBuilder()->keepHistory()->build();
+ $this->assertInstanceOf('Guzzle\Batch\HistoryBatch', $batch);
+ }
+
+ public function testAddsNotify()
+ {
+ $batch = $this->getMockBatchBuilder()->notify(function() {})->build();
+ $this->assertInstanceOf('Guzzle\Batch\NotifyingBatch', $batch);
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\RuntimeException
+ */
+ public function testTransferStrategyMustBeSet()
+ {
+ $batch = BatchBuilder::factory()->createBatchesWith($this->getMockDivisor())->build();
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\RuntimeException
+ */
+ public function testDivisorStrategyMustBeSet()
+ {
+ $batch = BatchBuilder::factory()->transferWith($this->getMockTransfer())->build();
+ }
+
+ public function testTransfersRequests()
+ {
+ $batch = BatchBuilder::factory()->transferRequests(10)->build();
+ $this->assertInstanceOf('Guzzle\Batch\BatchRequestTransfer', $this->readAttribute($batch, 'transferStrategy'));
+ }
+
+ public function testTransfersCommands()
+ {
+ $batch = BatchBuilder::factory()->transferCommands(10)->build();
+ $this->assertInstanceOf('Guzzle\Batch\BatchCommandTransfer', $this->readAttribute($batch, 'transferStrategy'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureDivisorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureDivisorTest.php
new file mode 100644
index 0000000..753db7d
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureDivisorTest.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\BatchClosureDivisor;
+
+/**
+ * @covers Guzzle\Batch\BatchClosureDivisor
+ */
+class BatchClosureDivisorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testEnsuresCallableIsCallable()
+ {
+ $d = new BatchClosureDivisor(new \stdClass());
+ }
+
+ public function testDividesBatch()
+ {
+ $queue = new \SplQueue();
+ $queue[] = 'foo';
+ $queue[] = 'baz';
+
+ $d = new BatchClosureDivisor(function (\SplQueue $queue, $context) {
+ return array(
+ array('foo'),
+ array('baz')
+ );
+ }, 'Bar!');
+
+ $batches = $d->createBatches($queue);
+ $this->assertEquals(array(array('foo'), array('baz')), $batches);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureTransferTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureTransferTest.php
new file mode 100644
index 0000000..6ba7ae0
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchClosureTransferTest.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\BatchClosureTransfer;
+
+/**
+ * @covers Guzzle\Batch\BatchClosureTransfer
+ */
+class BatchClosureTransferTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var \Guzzle\Batch\BatchClosureTransfer The transfer fixture */
+ protected $transferStrategy;
+
+ /** @var array|null An array for keeping track of items passed into the transfer closure */
+ protected $itemsTransferred;
+
+ protected function setUp()
+ {
+ $this->itemsTransferred = null;
+ $itemsTransferred =& $this->itemsTransferred;
+
+ $this->transferStrategy = new BatchClosureTransfer(function (array $batch) use (&$itemsTransferred) {
+ $itemsTransferred = $batch;
+ return;
+ });
+ }
+
+ public function testTransfersBatch()
+ {
+ $batchedItems = array('foo', 'bar', 'baz');
+ $this->transferStrategy->transfer($batchedItems);
+
+ $this->assertEquals($batchedItems, $this->itemsTransferred);
+ }
+
+ public function testTransferBailsOnEmptyBatch()
+ {
+ $batchedItems = array();
+ $this->transferStrategy->transfer($batchedItems);
+
+ $this->assertNull($this->itemsTransferred);
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testEnsuresCallableIsCallable()
+ {
+ $foo = new BatchClosureTransfer('uh oh!');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchCommandTransferTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchCommandTransferTest.php
new file mode 100644
index 0000000..a04efab
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchCommandTransferTest.php
@@ -0,0 +1,83 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\BatchCommandTransfer;
+use Guzzle\Service\Client;
+use Guzzle\Tests\Service\Mock\Command\MockCommand as Mc;
+
+/**
+ * @covers Guzzle\Batch\BatchCommandTransfer
+ */
+class BatchCommandTransferTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testCreatesBatchesBasedOnClient()
+ {
+ $client1 = new Client('http://www.example.com');
+ $client2 = new Client('http://www.example.com');
+
+ $commands = array(new Mc(), new Mc(), new Mc(), new Mc(), new Mc());
+
+ $queue = new \SplQueue();
+ foreach ($commands as $i => $command) {
+ if ($i % 2) {
+ $command->setClient($client1);
+ } else {
+ $command->setClient($client2);
+ }
+ $queue[] = $command;
+ }
+
+ $batch = new BatchCommandTransfer(2);
+ $this->assertEquals(array(
+ array($commands[0], $commands[2]),
+ array($commands[4]),
+ array($commands[1], $commands[3])
+ ), $batch->createBatches($queue));
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testEnsuresAllItemsAreCommands()
+ {
+ $queue = new \SplQueue();
+ $queue[] = 'foo';
+ $batch = new BatchCommandTransfer(2);
+ $batch->createBatches($queue);
+ }
+
+ public function testTransfersBatches()
+ {
+ $client = $this->getMockBuilder('Guzzle\Service\Client')
+ ->setMethods(array('send'))
+ ->getMock();
+ $client->expects($this->once())
+ ->method('send');
+ $command = new Mc();
+ $command->setClient($client);
+ $batch = new BatchCommandTransfer(2);
+ $batch->transfer(array($command));
+ }
+
+ public function testDoesNotTransfersEmptyBatches()
+ {
+ $batch = new BatchCommandTransfer(2);
+ $batch->transfer(array());
+ }
+
+ /**
+ * @expectedException Guzzle\Service\Exception\InconsistentClientTransferException
+ */
+ public function testEnsuresAllCommandsUseTheSameClient()
+ {
+ $batch = new BatchCommandTransfer(2);
+ $client1 = new Client('http://www.example.com');
+ $client2 = new Client('http://www.example.com');
+ $command1 = new Mc();
+ $command1->setClient($client1);
+ $command2 = new Mc();
+ $command2->setClient($client2);
+ $batch->transfer(array($command1, $command2));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchRequestTransferTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchRequestTransferTest.php
new file mode 100644
index 0000000..dec7bd5
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchRequestTransferTest.php
@@ -0,0 +1,80 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\BatchRequestTransfer;
+use Guzzle\Http\Client;
+use Guzzle\Http\Curl\CurlMulti;
+
+/**
+ * @covers Guzzle\Batch\BatchRequestTransfer
+ */
+class BatchRequestTransferTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testCreatesBatchesBasedOnCurlMultiHandles()
+ {
+ $client1 = new Client('http://www.example.com');
+ $client1->setCurlMulti(new CurlMulti());
+
+ $client2 = new Client('http://www.example.com');
+ $client2->setCurlMulti(new CurlMulti());
+
+ $request1 = $client1->get();
+ $request2 = $client2->get();
+ $request3 = $client1->get();
+ $request4 = $client2->get();
+ $request5 = $client1->get();
+
+ $queue = new \SplQueue();
+ $queue[] = $request1;
+ $queue[] = $request2;
+ $queue[] = $request3;
+ $queue[] = $request4;
+ $queue[] = $request5;
+
+ $batch = new BatchRequestTransfer(2);
+ $this->assertEquals(array(
+ array($request1, $request3),
+ array($request3),
+ array($request2, $request4)
+ ), $batch->createBatches($queue));
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testEnsuresAllItemsAreRequests()
+ {
+ $queue = new \SplQueue();
+ $queue[] = 'foo';
+ $batch = new BatchRequestTransfer(2);
+ $batch->createBatches($queue);
+ }
+
+ public function testTransfersBatches()
+ {
+ $client = new Client('http://127.0.0.1:123');
+ $request = $client->get();
+ // For some reason... PHP unit clones the request, which emits a request.clone event. This causes the
+ // 'sorted' property of the event dispatcher to contain an array in the cloned request that is not present in
+ // the original.
+ $request->dispatch('request.clone');
+
+ $multi = $this->getMock('Guzzle\Http\Curl\CurlMultiInterface');
+ $client->setCurlMulti($multi);
+ $multi->expects($this->once())
+ ->method('add')
+ ->with($request);
+ $multi->expects($this->once())
+ ->method('send');
+
+ $batch = new BatchRequestTransfer(2);
+ $batch->transfer(array($request));
+ }
+
+ public function testDoesNotTransfersEmptyBatches()
+ {
+ $batch = new BatchRequestTransfer(2);
+ $batch->transfer(array());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchSizeDivisorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchSizeDivisorTest.php
new file mode 100644
index 0000000..5542228
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchSizeDivisorTest.php
@@ -0,0 +1,24 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\BatchSizeDivisor;
+
+/**
+ * @covers Guzzle\Batch\BatchSizeDivisor
+ */
+class BatchSizeDivisorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testDividesBatch()
+ {
+ $queue = new \SplQueue();
+ $queue[] = 'foo';
+ $queue[] = 'baz';
+ $queue[] = 'bar';
+ $d = new BatchSizeDivisor(3);
+ $this->assertEquals(3, $d->getSize());
+ $d->setSize(2);
+ $batches = $d->createBatches($queue);
+ $this->assertEquals(array(array('foo', 'baz'), array('bar')), $batches);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchTest.php
new file mode 100644
index 0000000..296f57a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/BatchTest.php
@@ -0,0 +1,91 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\Batch;
+use Guzzle\Batch\Exception\BatchTransferException;
+
+/**
+ * @covers Guzzle\Batch\Batch
+ */
+class BatchTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private function getMockTransfer()
+ {
+ return $this->getMock('Guzzle\Batch\BatchTransferInterface');
+ }
+
+ private function getMockDivisor()
+ {
+ return $this->getMock('Guzzle\Batch\BatchDivisorInterface');
+ }
+
+ public function testAddsItemsToQueue()
+ {
+ $batch = new Batch($this->getMockTransfer(), $this->getMockDivisor());
+ $this->assertSame($batch, $batch->add('foo'));
+ $this->assertEquals(1, count($batch));
+ }
+
+ public function testFlushReturnsItems()
+ {
+ $transfer = $this->getMockTransfer();
+ $transfer->expects($this->exactly(2))
+ ->method('transfer');
+
+ $divisor = $this->getMockDivisor();
+ $divisor->expects($this->once())
+ ->method('createBatches')
+ ->will($this->returnValue(array(array('foo', 'baz'), array('bar'))));
+
+ $batch = new Batch($transfer, $divisor);
+
+ $batch->add('foo')->add('baz')->add('bar');
+ $items = $batch->flush();
+
+ $this->assertEquals(array('foo', 'baz', 'bar'), $items);
+ }
+
+ public function testThrowsExceptionContainingTheFailedBatch()
+ {
+ $called = 0;
+ $originalException = new \Exception('Foo!');
+
+ $transfer = $this->getMockTransfer();
+ $transfer->expects($this->exactly(2))
+ ->method('transfer')
+ ->will($this->returnCallback(function () use (&$called, $originalException) {
+ if (++$called == 2) {
+ throw $originalException;
+ }
+ }));
+
+ $divisor = $this->getMockDivisor();
+ $batch = new Batch($transfer, $divisor);
+
+ // PHPunit clones objects before passing them to a callback.
+ // Horrible hack to get around this!
+ $queue = $this->readAttribute($batch, 'queue');
+
+ $divisor->expects($this->once())
+ ->method('createBatches')
+ ->will($this->returnCallback(function ($batch) use ($queue) {
+ foreach ($queue as $item) {
+ $items[] = $item;
+ }
+ return array_chunk($items, 2);
+ }));
+
+ $batch->add('foo')->add('baz')->add('bar')->add('bee')->add('boo');
+ $this->assertFalse($batch->isEmpty());
+
+ try {
+ $items = $batch->flush();
+ $this->fail('Expected exception');
+ } catch (BatchTransferException $e) {
+ $this->assertEquals($originalException, $e->getPrevious());
+ $this->assertEquals(array('bar', 'bee'), array_values($e->getBatch()));
+ $this->assertEquals(1, count($batch));
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/ExceptionBufferingBatchTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/ExceptionBufferingBatchTest.php
new file mode 100644
index 0000000..fd810b1
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/ExceptionBufferingBatchTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\ExceptionBufferingBatch;
+use Guzzle\Batch\Batch;
+use Guzzle\Batch\BatchSizeDivisor;
+
+/**
+ * @covers Guzzle\Batch\ExceptionBufferingBatch
+ */
+class ExceptionBufferingBatchTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testFlushesEntireBatchWhileBufferingErroredBatches()
+ {
+ $t = $this->getMockBuilder('Guzzle\Batch\BatchTransferInterface')
+ ->setMethods(array('transfer'))
+ ->getMock();
+
+ $d = new BatchSizeDivisor(1);
+ $batch = new Batch($t, $d);
+
+ $called = 0;
+ $t->expects($this->exactly(3))
+ ->method('transfer')
+ ->will($this->returnCallback(function ($batch) use (&$called) {
+ if (++$called === 2) {
+ throw new \Exception('Foo');
+ }
+ }));
+
+ $decorator = new ExceptionBufferingBatch($batch);
+ $decorator->add('foo')->add('baz')->add('bar');
+ $result = $decorator->flush();
+
+ $e = $decorator->getExceptions();
+ $this->assertEquals(1, count($e));
+ $this->assertEquals(array('baz'), $e[0]->getBatch());
+
+ $decorator->clearExceptions();
+ $this->assertEquals(0, count($decorator->getExceptions()));
+
+ $this->assertEquals(array('foo', 'bar'), $result);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/FlushingBatchTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/FlushingBatchTest.php
new file mode 100644
index 0000000..9b37a48
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/FlushingBatchTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\FlushingBatch;
+use Guzzle\Batch\Batch;
+
+/**
+ * @covers Guzzle\Batch\FlushingBatch
+ */
+class FlushingBatchTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testFlushesWhenSizeMeetsThreshold()
+ {
+ $t = $this->getMock('Guzzle\Batch\BatchTransferInterface', array('transfer'));
+ $d = $this->getMock('Guzzle\Batch\BatchDivisorInterface', array('createBatches'));
+
+ $batch = new Batch($t, $d);
+ $queue = $this->readAttribute($batch, 'queue');
+
+ $d->expects($this->exactly(2))
+ ->method('createBatches')
+ ->will($this->returnCallback(function () use ($queue) {
+ $items = array();
+ foreach ($queue as $item) {
+ $items[] = $item;
+ }
+ return array($items);
+ }));
+
+ $t->expects($this->exactly(2))
+ ->method('transfer');
+
+ $flush = new FlushingBatch($batch, 3);
+ $this->assertEquals(3, $flush->getThreshold());
+ $flush->setThreshold(2);
+ $flush->add('foo')->add('baz')->add('bar')->add('bee')->add('boo');
+ $this->assertEquals(1, count($flush));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/HistoryBatchTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/HistoryBatchTest.php
new file mode 100644
index 0000000..60d6f95
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/HistoryBatchTest.php
@@ -0,0 +1,26 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\HistoryBatch;
+use Guzzle\Batch\Batch;
+
+/**
+ * @covers Guzzle\Batch\HistoryBatch
+ */
+class HistoryBatchTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testMaintainsHistoryOfItemsAddedToBatch()
+ {
+ $batch = new Batch(
+ $this->getMock('Guzzle\Batch\BatchTransferInterface'),
+ $this->getMock('Guzzle\Batch\BatchDivisorInterface')
+ );
+
+ $history = new HistoryBatch($batch);
+ $history->add('foo')->add('baz');
+ $this->assertEquals(array('foo', 'baz'), $history->getHistory());
+ $history->clearHistory();
+ $this->assertEquals(array(), $history->getHistory());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/NotifyingBatchTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/NotifyingBatchTest.php
new file mode 100644
index 0000000..69a8900
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Batch/NotifyingBatchTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Guzzle\Tests\Batch;
+
+use Guzzle\Batch\NotifyingBatch;
+use Guzzle\Batch\Batch;
+
+/**
+ * @covers Guzzle\Batch\NotifyingBatch
+ */
+class NotifyingBatchTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testNotifiesAfterFlush()
+ {
+ $batch = $this->getMock('Guzzle\Batch\Batch', array('flush'), array(
+ $this->getMock('Guzzle\Batch\BatchTransferInterface'),
+ $this->getMock('Guzzle\Batch\BatchDivisorInterface')
+ ));
+
+ $batch->expects($this->once())
+ ->method('flush')
+ ->will($this->returnValue(array('foo', 'baz')));
+
+ $data = array();
+ $decorator = new NotifyingBatch($batch, function ($batch) use (&$data) {
+ $data[] = $batch;
+ });
+
+ $decorator->add('foo')->add('baz');
+ $decorator->flush();
+ $this->assertEquals(array(array('foo', 'baz')), $data);
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testEnsuresCallableIsValid()
+ {
+ $batch = new Batch(
+ $this->getMock('Guzzle\Batch\BatchTransferInterface'),
+ $this->getMock('Guzzle\Batch\BatchDivisorInterface')
+ );
+ $decorator = new NotifyingBatch($batch, 'foo');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterFactoryTest.php
new file mode 100644
index 0000000..c4140a9
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterFactoryTest.php
@@ -0,0 +1,64 @@
+<?php
+
+namespace Guzzle\Tests\Cache;
+
+use Guzzle\Cache\CacheAdapterFactory;
+use Guzzle\Cache\DoctrineCacheAdapter;
+use Doctrine\Common\Cache\ArrayCache;
+use Zend\Cache\StorageFactory;
+
+/**
+ * @covers Guzzle\Cache\CacheAdapterFactory
+ */
+class CacheAdapterFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var ArrayCache */
+ private $cache;
+
+ /** @var DoctrineCacheAdapter */
+ private $adapter;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setup()
+ {
+ parent::setUp();
+ $this->cache = new ArrayCache();
+ $this->adapter = new DoctrineCacheAdapter($this->cache);
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testEnsuresConfigIsObject()
+ {
+ CacheAdapterFactory::fromCache(array());
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testEnsuresKnownType()
+ {
+ CacheAdapterFactory::fromCache(new \stdClass());
+ }
+
+ public function cacheProvider()
+ {
+ return array(
+ array(new DoctrineCacheAdapter(new ArrayCache()), 'Guzzle\Cache\DoctrineCacheAdapter'),
+ array(new ArrayCache(), 'Guzzle\Cache\DoctrineCacheAdapter'),
+ array(StorageFactory::factory(array('adapter' => 'memory')), 'Guzzle\Cache\Zf2CacheAdapter'),
+ );
+ }
+
+ /**
+ * @dataProvider cacheProvider
+ */
+ public function testCreatesNullCacheAdapterByDefault($cache, $type)
+ {
+ $adapter = CacheAdapterFactory::fromCache($cache);
+ $this->assertInstanceOf($type, $adapter);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterTest.php
new file mode 100644
index 0000000..3e30ddd
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/CacheAdapterTest.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Guzzle\Tests\Cache;
+
+use Guzzle\Cache\DoctrineCacheAdapter;
+use Doctrine\Common\Cache\ArrayCache;
+
+/**
+ * @covers Guzzle\Cache\DoctrineCacheAdapter
+ * @covers Guzzle\Cache\AbstractCacheAdapter
+ */
+class CacheAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var ArrayCache */
+ private $cache;
+
+ /** @var DoctrineCacheAdapter */
+ private $adapter;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->cache = new ArrayCache();
+ $this->adapter = new DoctrineCacheAdapter($this->cache);
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->adapter = null;
+ $this->cache = null;
+ parent::tearDown();
+ }
+
+ public function testGetCacheObject()
+ {
+ $this->assertEquals($this->cache, $this->adapter->getCacheObject());
+ }
+
+ public function testSave()
+ {
+ $this->assertTrue($this->adapter->save('test', 'data', 1000));
+ }
+
+ public function testFetch()
+ {
+ $this->assertTrue($this->adapter->save('test', 'data', 1000));
+ $this->assertEquals('data', $this->adapter->fetch('test'));
+ }
+
+ public function testContains()
+ {
+ $this->assertTrue($this->adapter->save('test', 'data', 1000));
+ $this->assertTrue($this->adapter->contains('test'));
+ }
+
+ public function testDelete()
+ {
+ $this->assertTrue($this->adapter->save('test', 'data', 1000));
+ $this->assertTrue($this->adapter->delete('test'));
+ $this->assertFalse($this->adapter->contains('test'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/ClosureCacheAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/ClosureCacheAdapterTest.php
new file mode 100644
index 0000000..12de65b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/ClosureCacheAdapterTest.php
@@ -0,0 +1,94 @@
+<?php
+
+namespace Guzzle\Tests\Cache;
+
+use Guzzle\Cache\ClosureCacheAdapter;
+
+/**
+ * @covers Guzzle\Cache\ClosureCacheAdapter
+ */
+class ClosureCacheAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var ClosureCacheAdapter */
+ private $adapter;
+
+ /** Array of callables to use for testing */
+ private $callables;
+
+ /** Cache data for testing */
+ public $data = array();
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+
+ $that = $this;
+ $this->callables = array(
+ 'contains' => function($id, $options = array()) use ($that) {
+ return array_key_exists($id, $that->data);
+ },
+ 'delete' => function($id, $options = array()) use ($that) {
+ unset($that->data[$id]);
+ return true;
+ },
+ 'fetch' => function($id, $options = array()) use ($that) {
+ return array_key_exists($id, $that->data) ? $that->data[$id] : null;
+ },
+ 'save' => function($id, $data, $lifeTime, $options = array()) use ($that) {
+ $that->data[$id] = $data;
+ return true;
+ }
+ );
+
+ $this->adapter = new ClosureCacheAdapter($this->callables);
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->cache = null;
+ $this->callables = null;
+ parent::tearDown();
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testEnsuresCallablesArePresent()
+ {
+ $callables = $this->callables;
+ unset($callables['delete']);
+ $cache = new ClosureCacheAdapter($callables);
+ }
+
+ public function testAllCallablesMustBePresent()
+ {
+ $cache = new ClosureCacheAdapter($this->callables);
+ }
+
+ public function testCachesDataUsingCallables()
+ {
+ $this->assertTrue($this->adapter->save('test', 'data', 1000));
+ $this->assertEquals('data', $this->adapter->fetch('test'));
+ }
+
+ public function testChecksIfCacheContainsKeys()
+ {
+ $this->adapter->save('test', 'data', 1000);
+ $this->assertTrue($this->adapter->contains('test'));
+ $this->assertFalse($this->adapter->contains('foo'));
+ }
+
+ public function testDeletesFromCacheByKey()
+ {
+ $this->adapter->save('test', 'data', 1000);
+ $this->assertTrue($this->adapter->contains('test'));
+ $this->adapter->delete('test');
+ $this->assertFalse($this->adapter->contains('test'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/NullCacheAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/NullCacheAdapterTest.php
new file mode 100644
index 0000000..e05df3f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/NullCacheAdapterTest.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Guzzle\Tests\Common\Cache;
+
+use Guzzle\Cache\NullCacheAdapter;
+
+/**
+ * @covers Guzzle\Cache\NullCacheAdapter
+ */
+class NullCacheAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testNullCacheAdapter()
+ {
+ $c = new NullCacheAdapter();
+ $this->assertEquals(false, $c->contains('foo'));
+ $this->assertEquals(true, $c->delete('foo'));
+ $this->assertEquals(false, $c->fetch('foo'));
+ $this->assertEquals(true, $c->save('foo', 'bar'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php
new file mode 100644
index 0000000..9077c12
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Cache/Zf2CacheAdapterTest.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Guzzle\Tests\Cache;
+
+use Guzzle\Cache\Zf2CacheAdapter;
+use Zend\Cache\StorageFactory;
+
+/**
+ * @covers Guzzle\Cache\Zf2CacheAdapter
+ */
+class Zf2CacheAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private $cache;
+ private $adapter;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->cache = StorageFactory::factory(array(
+ 'adapter' => 'memory'
+ ));
+ $this->adapter = new Zf2CacheAdapter($this->cache);
+ }
+
+ /**
+ * Cleans up the environment after running a test.
+ */
+ protected function tearDown()
+ {
+ $this->adapter = null;
+ $this->cache = null;
+ parent::tearDown();
+ }
+
+ public function testCachesDataUsingCallables()
+ {
+ $this->assertTrue($this->adapter->save('test', 'data', 1000));
+ $this->assertEquals('data', $this->adapter->fetch('test'));
+ }
+
+ public function testChecksIfCacheContainsKeys()
+ {
+ $this->adapter->save('test', 'data', 1000);
+ $this->assertTrue($this->adapter->contains('test'));
+ $this->assertFalse($this->adapter->contains('foo'));
+ }
+
+ public function testDeletesFromCacheByKey()
+ {
+ $this->adapter->save('test', 'data', 1000);
+ $this->assertTrue($this->adapter->contains('test'));
+ $this->adapter->delete('test');
+ $this->assertFalse($this->adapter->contains('test'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/AbstractHasDispatcherTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/AbstractHasDispatcherTest.php
new file mode 100644
index 0000000..19d12e6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/AbstractHasDispatcherTest.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Guzzle\Tests\Common;
+
+use Guzzle\Common\Event;
+use Guzzle\Common\AbstractHasDispatcher;
+use Symfony\Component\EventDispatcher\EventDispatcher;
+
+/**
+ * @covers Guzzle\Common\AbstractHasDispatcher
+ */
+class AbstractHasAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testDoesNotRequireRegisteredEvents()
+ {
+ $this->assertEquals(array(), AbstractHasDispatcher::getAllEvents());
+ }
+
+ public function testAllowsDispatcherToBeInjected()
+ {
+ $d = new EventDispatcher();
+ $mock = $this->getMockForAbstractClass('Guzzle\Common\AbstractHasDispatcher');
+ $this->assertSame($mock, $mock->setEventDispatcher($d));
+ $this->assertSame($d, $mock->getEventDispatcher());
+ }
+
+ public function testCreatesDefaultEventDispatcherIfNeeded()
+ {
+ $mock = $this->getMockForAbstractClass('Guzzle\Common\AbstractHasDispatcher');
+ $this->assertInstanceOf('Symfony\Component\EventDispatcher\EventDispatcher', $mock->getEventDispatcher());
+ }
+
+ public function testHelperDispatchesEvents()
+ {
+ $data = array();
+ $mock = $this->getMockForAbstractClass('Guzzle\Common\AbstractHasDispatcher');
+ $mock->getEventDispatcher()->addListener('test', function(Event $e) use (&$data) {
+ $data = $e->getIterator()->getArrayCopy();
+ });
+ $mock->dispatch('test', array(
+ 'param' => 'abc'
+ ));
+ $this->assertEquals(array(
+ 'param' => 'abc',
+ ), $data);
+ }
+
+ public function testHelperAttachesSubscribers()
+ {
+ $mock = $this->getMockForAbstractClass('Guzzle\Common\AbstractHasDispatcher');
+ $subscriber = $this->getMockForAbstractClass('Symfony\Component\EventDispatcher\EventSubscriberInterface');
+
+ $dispatcher = $this->getMockBuilder('Symfony\Component\EventDispatcher\EventDispatcher')
+ ->setMethods(array('addSubscriber'))
+ ->getMock();
+
+ $dispatcher->expects($this->once())
+ ->method('addSubscriber');
+
+ $mock->setEventDispatcher($dispatcher);
+ $mock->addSubscriber($subscriber);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/CollectionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/CollectionTest.php
new file mode 100644
index 0000000..0648a02
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/CollectionTest.php
@@ -0,0 +1,529 @@
+<?php
+
+namespace Guzzle\Tests\Common;
+
+use Guzzle\Common\Collection;
+use Guzzle\Common\Exception\InvalidArgumentException;
+use Guzzle\Http\QueryString;
+
+/**
+ * @covers Guzzle\Common\Collection
+ */
+class CollectionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var Collection */
+ protected $coll;
+
+ protected function setUp()
+ {
+ $this->coll = new Collection();
+ }
+
+ public function testConstructorCanBeCalledWithNoParams()
+ {
+ $this->coll = new Collection();
+ $p = $this->coll->getAll();
+ $this->assertEmpty($p, '-> Collection must be empty when no data is passed');
+ }
+
+ public function testConstructorCanBeCalledWithParams()
+ {
+ $testData = array(
+ 'test' => 'value',
+ 'test_2' => 'value2'
+ );
+ $this->coll = new Collection($testData);
+ $this->assertEquals($this->coll->getAll(), $testData, '-> getAll() must return the data passed in the constructor');
+ $this->assertEquals($this->coll->getAll(), $this->coll->toArray());
+ }
+
+ public function testImplementsIteratorAggregate()
+ {
+ $this->coll->set('key', 'value');
+ $this->assertInstanceOf('ArrayIterator', $this->coll->getIterator());
+ $this->assertEquals(1, count($this->coll));
+ $total = 0;
+ foreach ($this->coll as $key => $value) {
+ $this->assertEquals('key', $key);
+ $this->assertEquals('value', $value);
+ $total++;
+ }
+ $this->assertEquals(1, $total);
+ }
+
+ public function testCanAddValuesToExistingKeysByUsingArray()
+ {
+ $this->coll->add('test', 'value1');
+ $this->assertEquals($this->coll->getAll(), array('test' => 'value1'));
+ $this->coll->add('test', 'value2');
+ $this->assertEquals($this->coll->getAll(), array('test' => array('value1', 'value2')));
+ $this->coll->add('test', 'value3');
+ $this->assertEquals($this->coll->getAll(), array('test' => array('value1', 'value2', 'value3')));
+ }
+
+ public function testHandlesMergingInDisparateDataSources()
+ {
+ $params = array(
+ 'test' => 'value1',
+ 'test2' => 'value2',
+ 'test3' => array('value3', 'value4')
+ );
+ $this->coll->merge($params);
+ $this->assertEquals($this->coll->getAll(), $params);
+
+ // Pass the same object to itself
+ $this->assertEquals($this->coll->merge($this->coll), $this->coll);
+ }
+
+ public function testCanClearAllDataOrSpecificKeys()
+ {
+ $this->coll->merge(array(
+ 'test' => 'value1',
+ 'test2' => 'value2'
+ ));
+
+ // Clear a specific parameter by name
+ $this->coll->remove('test');
+
+ $this->assertEquals($this->coll->getAll(), array(
+ 'test2' => 'value2'
+ ));
+
+ // Clear all parameters
+ $this->coll->clear();
+
+ $this->assertEquals($this->coll->getAll(), array());
+ }
+
+ public function testGetsValuesByKey()
+ {
+ $this->assertNull($this->coll->get('test'));
+ $this->coll->add('test', 'value');
+ $this->assertEquals('value', $this->coll->get('test'));
+ $this->coll->set('test2', 'v2');
+ $this->coll->set('test3', 'v3');
+ $this->assertEquals(array(
+ 'test' => 'value',
+ 'test2' => 'v2'
+ ), $this->coll->getAll(array('test', 'test2')));
+ }
+
+ public function testProvidesKeys()
+ {
+ $this->assertEquals(array(), $this->coll->getKeys());
+ $this->coll->merge(array(
+ 'test1' => 'value1',
+ 'test2' => 'value2'
+ ));
+ $this->assertEquals(array('test1', 'test2'), $this->coll->getKeys());
+ // Returns the cached array previously returned
+ $this->assertEquals(array('test1', 'test2'), $this->coll->getKeys());
+ $this->coll->remove('test1');
+ $this->assertEquals(array('test2'), $this->coll->getKeys());
+ $this->coll->add('test3', 'value3');
+ $this->assertEquals(array('test2', 'test3'), $this->coll->getKeys());
+ }
+
+ public function testChecksIfHasKey()
+ {
+ $this->assertFalse($this->coll->hasKey('test'));
+ $this->coll->add('test', 'value');
+ $this->assertEquals(true, $this->coll->hasKey('test'));
+ $this->coll->add('test2', 'value2');
+ $this->assertEquals(true, $this->coll->hasKey('test'));
+ $this->assertEquals(true, $this->coll->hasKey('test2'));
+ $this->assertFalse($this->coll->hasKey('testing'));
+ $this->assertEquals(false, $this->coll->hasKey('AB-C', 'junk'));
+ }
+
+ public function testChecksIfHasValue()
+ {
+ $this->assertFalse($this->coll->hasValue('value'));
+ $this->coll->add('test', 'value');
+ $this->assertEquals('test', $this->coll->hasValue('value'));
+ $this->coll->add('test2', 'value2');
+ $this->assertEquals('test', $this->coll->hasValue('value'));
+ $this->assertEquals('test2', $this->coll->hasValue('value2'));
+ $this->assertFalse($this->coll->hasValue('val'));
+ }
+
+ public function testCanGetAllValuesByArray()
+ {
+ $this->coll->add('foo', 'bar');
+ $this->coll->add('tEsT', 'value');
+ $this->coll->add('tesTing', 'v2');
+ $this->coll->add('key', 'v3');
+ $this->assertNull($this->coll->get('test'));
+ $this->assertEquals(array(
+ 'foo' => 'bar',
+ 'tEsT' => 'value',
+ 'tesTing' => 'v2'
+ ), $this->coll->getAll(array(
+ 'foo', 'tesTing', 'tEsT'
+ )));
+ }
+
+ public function testImplementsCount()
+ {
+ $data = new Collection();
+ $this->assertEquals(0, $data->count());
+ $data->add('key', 'value');
+ $this->assertEquals(1, count($data));
+ $data->add('key', 'value2');
+ $this->assertEquals(1, count($data));
+ $data->add('key_2', 'value3');
+ $this->assertEquals(2, count($data));
+ }
+
+ public function testAddParamsByMerging()
+ {
+ $params = array(
+ 'test' => 'value1',
+ 'test2' => 'value2',
+ 'test3' => array('value3', 'value4')
+ );
+
+ // Add some parameters
+ $this->coll->merge($params);
+
+ // Add more parameters by merging them in
+ $this->coll->merge(array(
+ 'test' => 'another',
+ 'different_key' => 'new value'
+ ));
+
+ $this->assertEquals(array(
+ 'test' => array('value1', 'another'),
+ 'test2' => 'value2',
+ 'test3' => array('value3', 'value4'),
+ 'different_key' => 'new value'
+ ), $this->coll->getAll());
+ }
+
+ public function testAllowsFunctionalFilter()
+ {
+ $this->coll->merge(array(
+ 'fruit' => 'apple',
+ 'number' => 'ten',
+ 'prepositions' => array('about', 'above', 'across', 'after'),
+ 'same_number' => 'ten'
+ ));
+
+ $filtered = $this->coll->filter(function($key, $value) {
+ return $value == 'ten';
+ });
+
+ $this->assertNotEquals($filtered, $this->coll);
+
+ $this->assertEquals(array(
+ 'number' => 'ten',
+ 'same_number' => 'ten'
+ ), $filtered->getAll());
+ }
+
+ public function testAllowsFunctionalMapping()
+ {
+ $this->coll->merge(array(
+ 'number_1' => 1,
+ 'number_2' => 2,
+ 'number_3' => 3
+ ));
+
+ $mapped = $this->coll->map(function($key, $value) {
+ return $value * $value;
+ });
+
+ $this->assertNotEquals($mapped, $this->coll);
+
+ $this->assertEquals(array(
+ 'number_1' => 1,
+ 'number_2' => 4,
+ 'number_3' => 9
+ ), $mapped->getAll());
+ }
+
+ public function testImplementsArrayAccess()
+ {
+ $this->coll->merge(array(
+ 'k1' => 'v1',
+ 'k2' => 'v2'
+ ));
+
+ $this->assertTrue($this->coll->offsetExists('k1'));
+ $this->assertFalse($this->coll->offsetExists('Krull'));
+
+ $this->coll->offsetSet('k3', 'v3');
+ $this->assertEquals('v3', $this->coll->offsetGet('k3'));
+ $this->assertEquals('v3', $this->coll->get('k3'));
+
+ $this->coll->offsetUnset('k1');
+ $this->assertFalse($this->coll->offsetExists('k1'));
+ }
+
+ public function testUsesStaticWhenCreatingNew()
+ {
+ $qs = new QueryString(array(
+ 'a' => 'b',
+ 'c' => 'd'
+ ));
+
+ $this->assertInstanceOf('Guzzle\\Http\\QueryString', $qs->map(function($a, $b) {}));
+ $this->assertInstanceOf('Guzzle\\Common\\Collection', $qs->map(function($a, $b) {}, array(), false));
+
+ $this->assertInstanceOf('Guzzle\\Http\\QueryString', $qs->filter(function($a, $b) {}));
+ $this->assertInstanceOf('Guzzle\\Common\\Collection', $qs->filter(function($a, $b) {}, false));
+ }
+
+ public function testCanReplaceAllData()
+ {
+ $this->assertSame($this->coll, $this->coll->replace(array(
+ 'a' => '123'
+ )));
+
+ $this->assertEquals(array(
+ 'a' => '123'
+ ), $this->coll->getAll());
+ }
+
+ 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_a_{0}', array(
+ 'abc' => 'this',
+ 0 => 'test'
+ )),
+ array('this_is_a_test', 'this_is_a_test', array(
+ 'abc' => 'this'
+ )),
+ array('{abc}_is_{not_found}a_{0}', '{abc}_is_{not_found}a_{0}', array())
+ );
+ }
+
+ /**
+ * @dataProvider dataProvider
+ */
+ public function testInjectsConfigData($output, $input, $config)
+ {
+ $collection = new Collection($config);
+ $this->assertEquals($output, $collection->inject($input));
+ }
+
+ public function testCanSearchByKey()
+ {
+ $collection = new Collection(array(
+ 'foo' => 'bar',
+ 'BaZ' => 'pho'
+ ));
+
+ $this->assertEquals('foo', $collection->keySearch('FOO'));
+ $this->assertEquals('BaZ', $collection->keySearch('baz'));
+ $this->assertEquals(false, $collection->keySearch('Bar'));
+ }
+
+ public function testPreparesFromConfig()
+ {
+ $c = Collection::fromConfig(array(
+ 'a' => '123',
+ 'base_url' => 'http://www.test.com/'
+ ), array(
+ 'a' => 'xyz',
+ 'b' => 'lol'
+ ), array('a'));
+
+ $this->assertInstanceOf('Guzzle\Common\Collection', $c);
+ $this->assertEquals(array(
+ 'a' => '123',
+ 'b' => 'lol',
+ 'base_url' => 'http://www.test.com/'
+ ), $c->getAll());
+
+ try {
+ $c = Collection::fromConfig(array(), array(), array('a'));
+ $this->fail('Exception not throw when missing config');
+ } catch (InvalidArgumentException $e) {
+ }
+ }
+
+ function falseyDataProvider()
+ {
+ return array(
+ array(false, false),
+ array(null, null),
+ array('', ''),
+ array(array(), array()),
+ array(0, 0),
+ );
+ }
+
+ /**
+ * @dataProvider falseyDataProvider
+ */
+ public function testReturnsCorrectData($a, $b)
+ {
+ $c = new Collection(array('value' => $a));
+ $this->assertSame($b, $c->get('value'));
+ }
+
+ public function testRetrievesNestedKeysUsingPath()
+ {
+ $data = array(
+ 'foo' => 'bar',
+ 'baz' => array(
+ 'mesa' => array(
+ 'jar' => 'jar'
+ )
+ )
+ );
+ $collection = new Collection($data);
+ $this->assertEquals('bar', $collection->getPath('foo'));
+ $this->assertEquals('jar', $collection->getPath('baz/mesa/jar'));
+ $this->assertNull($collection->getPath('wewewf'));
+ $this->assertNull($collection->getPath('baz/mesa/jar/jar'));
+ }
+
+ public function testFalseyKeysStillDescend()
+ {
+ $collection = new Collection(array(
+ '0' => array(
+ 'a' => 'jar'
+ ),
+ 1 => 'other'
+ ));
+ $this->assertEquals('jar', $collection->getPath('0/a'));
+ $this->assertEquals('other', $collection->getPath('1'));
+ }
+
+ public function getPathProvider()
+ {
+ $data = array(
+ 'foo' => 'bar',
+ 'baz' => array(
+ 'mesa' => array(
+ 'jar' => 'jar',
+ 'array' => array('a', 'b', 'c')
+ ),
+ 'bar' => array(
+ 'baz' => 'bam',
+ 'array' => array('d', 'e', 'f')
+ )
+ ),
+ 'bam' => array(
+ array('foo' => 1),
+ array('foo' => 2),
+ array('array' => array('h', 'i'))
+ )
+ );
+ $c = new Collection($data);
+
+ return array(
+ // Simple path selectors
+ array($c, 'foo', 'bar'),
+ array($c, 'baz', $data['baz']),
+ array($c, 'bam', $data['bam']),
+ array($c, 'baz/mesa', $data['baz']['mesa']),
+ array($c, 'baz/mesa/jar', 'jar'),
+ // Merge everything two levels under baz
+ array($c, 'baz/*', array(
+ 'jar' => 'jar',
+ 'array' => array_merge($data['baz']['mesa']['array'], $data['baz']['bar']['array']),
+ 'baz' => 'bam'
+ )),
+ // Does not barf on missing keys
+ array($c, 'fefwfw', null),
+ // Does not barf when a wildcard does not resolve correctly
+ array($c, '*/*/*/*/*/wefwfe', array()),
+ // Allows custom separator
+ array($c, '*|mesa', $data['baz']['mesa'], '|'),
+ // Merge all 'array' keys two levels under baz (the trailing * does not hurt the results)
+ array($c, 'baz/*/array/*', array_merge($data['baz']['mesa']['array'], $data['baz']['bar']['array'])),
+ // Merge all 'array' keys two levels under baz
+ array($c, 'baz/*/array', array_merge($data['baz']['mesa']['array'], $data['baz']['bar']['array'])),
+ array($c, 'baz/mesa/array', $data['baz']['mesa']['array']),
+ // Having a trailing * does not hurt the results
+ array($c, 'baz/mesa/array/*', $data['baz']['mesa']['array']),
+ // Merge of anything one level deep
+ array($c, '*', array_merge(array('bar'), $data['baz'], $data['bam'])),
+ // Funky merge of anything two levels deep
+ array($c, '*/*', array(
+ 'jar' => 'jar',
+ 'array' => array('a', 'b', 'c', 'd', 'e', 'f', 'h', 'i'),
+ 'baz' => 'bam',
+ 'foo' => array(1, 2)
+ )),
+ // Funky merge of all 'array' keys that are two levels deep
+ array($c, '*/*/array', array('a', 'b', 'c', 'd', 'e', 'f', 'h', 'i'))
+ );
+ }
+
+ /**
+ * @dataProvider getPathProvider
+ */
+ public function testGetPath(Collection $c, $path, $expected, $separator = '/')
+ {
+ $this->assertEquals($expected, $c->getPath($path, $separator));
+ }
+
+ public function testOverridesSettings()
+ {
+ $c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
+ $c->overwriteWith(array('foo' => 10, 'bar' => 300));
+ $this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->getAll());
+ }
+
+ public function testOverwriteWithCollection()
+ {
+ $c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
+ $b = new Collection(array('foo' => 10, 'bar' => 300));
+ $c->overwriteWith($b);
+ $this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->getAll());
+ }
+
+ public function testOverwriteWithTraversable()
+ {
+ $c = new Collection(array('foo' => 1, 'baz' => 2, 'bar' => 3));
+ $b = new Collection(array('foo' => 10, 'bar' => 300));
+ $c->overwriteWith($b->getIterator());
+ $this->assertEquals(array('foo' => 10, 'baz' => 2, 'bar' => 300), $c->getAll());
+ }
+
+ public function testCanSetNestedPathValueThatDoesNotExist()
+ {
+ $c = new Collection(array());
+ $c->setPath('foo/bar/baz/123', 'hi');
+ $this->assertEquals('hi', $c['foo']['bar']['baz']['123']);
+ }
+
+ public function testCanSetNestedPathValueThatExists()
+ {
+ $c = new Collection(array('foo' => array('bar' => 'test')));
+ $c->setPath('foo/bar', 'hi');
+ $this->assertEquals('hi', $c['foo']['bar']);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ */
+ public function testVerifiesNestedPathIsValidAtExactLevel()
+ {
+ $c = new Collection(array('foo' => 'bar'));
+ $c->setPath('foo/bar', 'hi');
+ $this->assertEquals('hi', $c['foo']['bar']);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ */
+ public function testVerifiesThatNestedPathIsValidAtAnyLevel()
+ {
+ $c = new Collection(array('foo' => 'bar'));
+ $c->setPath('foo/bar/baz', 'test');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/EventTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/EventTest.php
new file mode 100644
index 0000000..5484e14
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/EventTest.php
@@ -0,0 +1,62 @@
+<?php
+
+namespace Guzzle\Tests\Common;
+
+use Guzzle\Common\Event;
+
+/**
+ * @covers Guzzle\Common\Event
+ */
+class EventTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @return Event
+ */
+ private function getEvent()
+ {
+ return new Event(array(
+ 'test' => '123',
+ 'other' => '456',
+ 'event' => 'test.notify'
+ ));
+ }
+
+ public function testAllowsParameterInjection()
+ {
+ $event = new Event(array(
+ 'test' => '123'
+ ));
+ $this->assertEquals('123', $event['test']);
+ }
+
+ public function testImplementsArrayAccess()
+ {
+ $event = $this->getEvent();
+ $this->assertEquals('123', $event['test']);
+ $this->assertNull($event['foobar']);
+
+ $this->assertTrue($event->offsetExists('test'));
+ $this->assertFalse($event->offsetExists('foobar'));
+
+ unset($event['test']);
+ $this->assertFalse($event->offsetExists('test'));
+
+ $event['test'] = 'new';
+ $this->assertEquals('new', $event['test']);
+ }
+
+ public function testImplementsIteratorAggregate()
+ {
+ $event = $this->getEvent();
+ $this->assertInstanceOf('ArrayIterator', $event->getIterator());
+ }
+
+ public function testConvertsToArray()
+ {
+ $this->assertEquals(array(
+ 'test' => '123',
+ 'other' => '456',
+ 'event' => 'test.notify'
+ ), $this->getEvent()->toArray());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/BatchTransferExceptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/BatchTransferExceptionTest.php
new file mode 100644
index 0000000..c72a2a6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/BatchTransferExceptionTest.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Guzzle\Tests\Common\Exception;
+
+use Guzzle\Batch\Exception\BatchTransferException;
+
+class BatchTransferExceptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testContainsBatch()
+ {
+ $e = new \Exception('Baz!');
+ $t = $this->getMock('Guzzle\Batch\BatchTransferInterface');
+ $d = $this->getMock('Guzzle\Batch\BatchDivisorInterface');
+ $transferException = new BatchTransferException(array('foo'), array(1, 2), $e, $t, $d);
+ $this->assertEquals(array('foo'), $transferException->getBatch());
+ $this->assertSame($t, $transferException->getTransferStrategy());
+ $this->assertSame($d, $transferException->getDivisorStrategy());
+ $this->assertSame($e, $transferException->getPrevious());
+ $this->assertEquals(array(1, 2), $transferException->getTransferredItems());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php
new file mode 100644
index 0000000..2aecf2a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Guzzle\Tests\Common\Exception;
+
+use Guzzle\Common\Exception\ExceptionCollection;
+
+class ExceptionCollectionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private function getExceptions()
+ {
+ return array(
+ new \Exception('Test'),
+ new \Exception('Testing')
+ );
+ }
+
+ public function testAggregatesExceptions()
+ {
+ $e = new ExceptionCollection();
+ $exceptions = $this->getExceptions();
+ $e->add($exceptions[0]);
+ $e->add($exceptions[1]);
+ $this->assertContains("(Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $e->getMessage());
+ $this->assertContains(" Test\n\n #0 ./", $e->getMessage());
+ $this->assertSame($exceptions[0], $e->getFirst());
+ }
+
+ public function testCanSetExceptions()
+ {
+ $ex = new \Exception('foo');
+ $e = new ExceptionCollection();
+ $e->setExceptions(array($ex));
+ $this->assertSame($ex, $e->getFirst());
+ }
+
+ public function testActsAsArray()
+ {
+ $e = new ExceptionCollection();
+ $exceptions = $this->getExceptions();
+ $e->add($exceptions[0]);
+ $e->add($exceptions[1]);
+ $this->assertEquals(2, count($e));
+ $this->assertEquals($exceptions, $e->getIterator()->getArrayCopy());
+ }
+
+ public function testCanAddSelf()
+ {
+ $e1 = new ExceptionCollection();
+ $e1->add(new \Exception("Test"));
+ $e2 = new ExceptionCollection('Meta description!');
+ $e2->add(new \Exception("Test 2"));
+ $e3 = new ExceptionCollection();
+ $e3->add(new \Exception('Baz'));
+ $e2->add($e3);
+ $e1->add($e2);
+ $message = $e1->getMessage();
+ $this->assertContains("(Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
+ $this->assertContains("\n Test\n\n #0 ", $message);
+ $this->assertContains("\n\n(Guzzle\\Common\\Exception\\ExceptionCollection) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
+ $this->assertContains("\n\n Meta description!\n\n", $message);
+ $this->assertContains(" (Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
+ $this->assertContains("\n Test 2\n\n #0 ", $message);
+ $this->assertContains(" (Exception) ./tests/Guzzle/Tests/Common/Exception/ExceptionCollectionTest.php line ", $message);
+ $this->assertContains(" Baz\n\n #0", $message);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/VersionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/VersionTest.php
new file mode 100644
index 0000000..c3a81d1
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Common/VersionTest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Guzzle\Tests\Common;
+
+use Guzzle\Common\Version;
+
+/**
+ * @covers Guzzle\Common\Version
+ */
+class VersionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException \PHPUnit_Framework_Error_Deprecated
+ */
+ public function testEmitsWarnings()
+ {
+ Version::$emitWarnings = true;
+ Version::warn('testing!');
+ }
+
+ public function testCanSilenceWarnings()
+ {
+ Version::$emitWarnings = false;
+ Version::warn('testing!');
+ Version::$emitWarnings = true;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/GuzzleTestCase.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/GuzzleTestCase.php
new file mode 100644
index 0000000..d89c5f0
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/GuzzleTestCase.php
@@ -0,0 +1,235 @@
+<?php
+
+namespace Guzzle\Tests;
+
+use Guzzle\Common\HasDispatcherInterface;
+use Guzzle\Common\Event;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Tests\Http\Message\HeaderComparison;
+use Guzzle\Plugin\Mock\MockPlugin;
+use Guzzle\Http\Client;
+use Guzzle\Service\Builder\ServiceBuilderInterface;
+use Guzzle\Service\Builder\ServiceBuilder;
+use Guzzle\Tests\Mock\MockObserver;
+use Guzzle\Tests\Http\Server;
+use RuntimeException;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * Base testcase class for all Guzzle testcases.
+ */
+abstract class GuzzleTestCase extends \PHPUnit_Framework_TestCase
+{
+ protected static $mockBasePath;
+ public static $serviceBuilder;
+ public static $server;
+
+ private $requests = array();
+ public $mockObserver;
+
+ /**
+ * Get the global server object used throughout the unit tests of Guzzle
+ *
+ * @return Server
+ */
+ public static function getServer()
+ {
+ if (!self::$server) {
+ self::$server = new Server();
+ if (self::$server->isRunning()) {
+ self::$server->flush();
+ } else {
+ self::$server->start();
+ }
+ }
+
+ return self::$server;
+ }
+
+ /**
+ * Set the service builder to use for tests
+ *
+ * @param ServiceBuilderInterface $builder Service builder
+ */
+ public static function setServiceBuilder(ServiceBuilderInterface $builder)
+ {
+ self::$serviceBuilder = $builder;
+ }
+
+ /**
+ * Get a service builder object that can be used throughout the service tests
+ *
+ * @return ServiceBuilder
+ */
+ public static function getServiceBuilder()
+ {
+ if (!self::$serviceBuilder) {
+ throw new RuntimeException('No service builder has been set via setServiceBuilder()');
+ }
+
+ return self::$serviceBuilder;
+ }
+
+ /**
+ * Check if an event dispatcher has a subscriber
+ *
+ * @param HasDispatcherInterface $dispatcher
+ * @param EventSubscriberInterface $subscriber
+ *
+ * @return bool
+ */
+ protected function hasSubscriber(HasDispatcherInterface $dispatcher, EventSubscriberInterface $subscriber)
+ {
+ $class = get_class($subscriber);
+ $all = array_keys(call_user_func(array($class, 'getSubscribedEvents')));
+
+ foreach ($all as $i => $event) {
+ foreach ($dispatcher->getEventDispatcher()->getListeners($event) as $e) {
+ if ($e[0] === $subscriber) {
+ unset($all[$i]);
+ break;
+ }
+ }
+ }
+
+ return count($all) == 0;
+ }
+
+ /**
+ * Get a wildcard observer for an event dispatcher
+ *
+ * @param HasDispatcherInterface $hasDispatcher
+ *
+ * @return MockObserver
+ */
+ public function getWildcardObserver(HasDispatcherInterface $hasDispatcher)
+ {
+ $class = get_class($hasDispatcher);
+ $o = new MockObserver();
+ $events = call_user_func(array($class, 'getAllEvents'));
+ foreach ($events as $event) {
+ $hasDispatcher->getEventDispatcher()->addListener($event, array($o, 'update'));
+ }
+
+ return $o;
+ }
+
+ /**
+ * Set the mock response base path
+ *
+ * @param string $path Path to mock response folder
+ *
+ * @return GuzzleTestCase
+ */
+ public static function setMockBasePath($path)
+ {
+ self::$mockBasePath = $path;
+ }
+
+ /**
+ * Mark a request as being mocked
+ *
+ * @param RequestInterface $request
+ *
+ * @return self
+ */
+ public function addMockedRequest(RequestInterface $request)
+ {
+ $this->requests[] = $request;
+
+ return $this;
+ }
+
+ /**
+ * Get all of the mocked requests
+ *
+ * @return array
+ */
+ public function getMockedRequests()
+ {
+ return $this->requests;
+ }
+
+ /**
+ * Get a mock response for a client by mock file name
+ *
+ * @param string $path Relative path to the mock response file
+ *
+ * @return Response
+ */
+ public function getMockResponse($path)
+ {
+ return $path instanceof Response
+ ? $path
+ : MockPlugin::getMockFile(self::$mockBasePath . DIRECTORY_SEPARATOR . $path);
+ }
+
+ /**
+ * Set a mock response from a mock file on the next client request.
+ *
+ * This method assumes that mock response files are located under the
+ * Command/Mock/ directory of the Service being tested
+ * (e.g. Unfuddle/Command/Mock/). A mock response is added to the next
+ * request sent by the client.
+ *
+ * @param Client $client Client object to modify
+ * @param string $paths Path to files within the Mock folder of the service
+ *
+ * @return MockPlugin returns the created mock plugin
+ */
+ public function setMockResponse(Client $client, $paths)
+ {
+ $this->requests = array();
+ $that = $this;
+ $mock = new MockPlugin(null, true);
+ $client->getEventDispatcher()->removeSubscriber($mock);
+ $mock->getEventDispatcher()->addListener('mock.request', function(Event $event) use ($that) {
+ $that->addMockedRequest($event['request']);
+ });
+
+ if ($paths instanceof Response) {
+ // A single response instance has been specified, create an array with that instance
+ // as the only element for the following loop to work as expected
+ $paths = array($paths);
+ }
+
+ foreach ((array) $paths as $path) {
+ $mock->addResponse($this->getMockResponse($path));
+ }
+
+ $client->getEventDispatcher()->addSubscriber($mock);
+
+ return $mock;
+ }
+
+ /**
+ * Compare HTTP headers and use special markup to filter values
+ * A header prefixed with '!' means it must not exist
+ * A header prefixed with '_' means it must be ignored
+ * A header value of '*' means anything after the * will be ignored
+ *
+ * @param array $filteredHeaders Array of special headers
+ * @param array $actualHeaders Array of headers to check against
+ *
+ * @return array|bool Returns an array of the differences or FALSE if none
+ */
+ public function compareHeaders($filteredHeaders, $actualHeaders)
+ {
+ $comparison = new HeaderComparison();
+
+ return $comparison->compare($filteredHeaders, $actualHeaders);
+ }
+
+ /**
+ * Case insensitive assertContains
+ *
+ * @param string $needle Search string
+ * @param string $haystack Search this
+ * @param string $message Optional failure message
+ */
+ public function assertContainsIns($needle, $haystack, $message = null)
+ {
+ $this->assertContains(strtolower($needle), strtolower($haystack), $message);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/AbstractEntityBodyDecoratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/AbstractEntityBodyDecoratorTest.php
new file mode 100644
index 0000000..20feaa8
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/AbstractEntityBodyDecoratorTest.php
@@ -0,0 +1,34 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\EntityBody;
+
+/**
+ * @covers Guzzle\Http\AbstractEntityBodyDecorator
+ */
+class AbstractEntityBodyDecoratorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testDecoratesEntityBody()
+ {
+ $e = EntityBody::factory();
+ $mock = $this->getMockForAbstractClass('Guzzle\Http\AbstractEntityBodyDecorator', array($e));
+
+ $this->assertSame($e->getStream(), $mock->getStream());
+ $this->assertSame($e->getContentLength(), $mock->getContentLength());
+ $this->assertSame($e->getSize(), $mock->getSize());
+ $this->assertSame($e->getContentMd5(), $mock->getContentMd5());
+ $this->assertSame($e->getContentType(), $mock->getContentType());
+ $this->assertSame($e->__toString(), $mock->__toString());
+ $this->assertSame($e->getUri(), $mock->getUri());
+ $this->assertSame($e->getStreamType(), $mock->getStreamType());
+ $this->assertSame($e->getWrapper(), $mock->getWrapper());
+ $this->assertSame($e->getWrapperData(), $mock->getWrapperData());
+ $this->assertSame($e->isReadable(), $mock->isReadable());
+ $this->assertSame($e->isWritable(), $mock->isWritable());
+ $this->assertSame($e->isConsumed(), $mock->isConsumed());
+ $this->assertSame($e->isLocal(), $mock->isLocal());
+ $this->assertSame($e->isSeekable(), $mock->isSeekable());
+ $this->assertSame($e->getContentEncoding(), $mock->getContentEncoding());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/CachingEntityBodyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/CachingEntityBodyTest.php
new file mode 100644
index 0000000..e6e6cdb
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/CachingEntityBodyTest.php
@@ -0,0 +1,249 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\CachingEntityBody;
+
+/**
+ * @covers Guzzle\Http\CachingEntityBody
+ */
+class CachingEntityBodyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var CachingEntityBody */
+ protected $body;
+
+ /** @var EntityBody */
+ protected $decorated;
+
+ public function setUp()
+ {
+ $this->decorated = EntityBody::factory('testing');
+ $this->body = new CachingEntityBody($this->decorated);
+ }
+
+ public function testUsesRemoteSizeIfPossible()
+ {
+ $body = EntityBody::factory('test');
+ $caching = new CachingEntityBody($body);
+ $this->assertEquals(4, $caching->getSize());
+ $this->assertEquals(4, $caching->getContentLength());
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ * @expectedExceptionMessage does not support custom stream rewind
+ */
+ public function testDoesNotAllowRewindFunction()
+ {
+ $this->body->setRewindFunction(true);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ * @expectedExceptionMessage Cannot seek to byte 10
+ */
+ public function testCannotSeekPastWhatHasBeenRead()
+ {
+ $this->body->seek(10);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ * @expectedExceptionMessage supports only SEEK_SET and SEEK_CUR
+ */
+ public function testCannotUseSeekEnd()
+ {
+ $this->body->seek(2, SEEK_END);
+ }
+
+ public function testChangingUnderlyingStreamUpdatesSizeAndStream()
+ {
+ $size = filesize(__FILE__);
+ $s = fopen(__FILE__, 'r');
+ $this->body->setStream($s, $size);
+ $this->assertEquals($size, $this->body->getSize());
+ $this->assertEquals($size, $this->decorated->getSize());
+ $this->assertSame($s, $this->body->getStream());
+ $this->assertSame($s, $this->decorated->getStream());
+ }
+
+ public function testRewindUsesSeek()
+ {
+ $a = EntityBody::factory('foo');
+ $d = $this->getMockBuilder('Guzzle\Http\CachingEntityBody')
+ ->setMethods(array('seek'))
+ ->setConstructorArgs(array($a))
+ ->getMock();
+ $d->expects($this->once())
+ ->method('seek')
+ ->with(0)
+ ->will($this->returnValue(true));
+ $d->rewind();
+ }
+
+ public function testCanSeekToReadBytes()
+ {
+ $this->assertEquals('te', $this->body->read(2));
+ $this->body->seek(0);
+ $this->assertEquals('test', $this->body->read(4));
+ $this->assertEquals(4, $this->body->ftell());
+ $this->body->seek(2);
+ $this->assertEquals(2, $this->body->ftell());
+ $this->body->seek(2, SEEK_CUR);
+ $this->assertEquals(4, $this->body->ftell());
+ $this->assertEquals('ing', $this->body->read(3));
+ }
+
+ public function testWritesToBufferStream()
+ {
+ $this->body->read(2);
+ $this->body->write('hi');
+ $this->body->rewind();
+ $this->assertEquals('tehiing', (string) $this->body);
+ }
+
+ public function testReadLinesFromBothStreams()
+ {
+ $this->body->seek($this->body->ftell());
+ $this->body->write("test\n123\nhello\n1234567890\n");
+ $this->body->rewind();
+ $this->assertEquals("test\n", $this->body->readLine(7));
+ $this->assertEquals("123\n", $this->body->readLine(7));
+ $this->assertEquals("hello\n", $this->body->readLine(7));
+ $this->assertEquals("123456", $this->body->readLine(7));
+ $this->assertEquals("7890\n", $this->body->readLine(7));
+ // We overwrote the decorated stream, so no more data
+ $this->assertEquals('', $this->body->readLine(7));
+ }
+
+ public function testSkipsOverwrittenBytes()
+ {
+ $decorated = EntityBody::factory(
+ implode("\n", array_map(function ($n) {
+ return str_pad($n, 4, '0', STR_PAD_LEFT);
+ }, range(0, 25)))
+ );
+
+ $body = new CachingEntityBody($decorated);
+
+ $this->assertEquals("0000\n", $body->readLine());
+ $this->assertEquals("0001\n", $body->readLine());
+ // Write over part of the body yet to be read, so skip some bytes
+ $this->assertEquals(5, $body->write("TEST\n"));
+ $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes'));
+ // Read, which skips bytes, then reads
+ $this->assertEquals("0003\n", $body->readLine());
+ $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes'));
+ $this->assertEquals("0004\n", $body->readLine());
+ $this->assertEquals("0005\n", $body->readLine());
+
+ // Overwrite part of the cached body (so don't skip any bytes)
+ $body->seek(5);
+ $this->assertEquals(5, $body->write("ABCD\n"));
+ $this->assertEquals(0, $this->readAttribute($body, 'skipReadBytes'));
+ $this->assertEquals("TEST\n", $body->readLine());
+ $this->assertEquals("0003\n", $body->readLine());
+ $this->assertEquals("0004\n", $body->readLine());
+ $this->assertEquals("0005\n", $body->readLine());
+ $this->assertEquals("0006\n", $body->readLine());
+ $this->assertEquals(5, $body->write("1234\n"));
+ $this->assertEquals(5, $this->readAttribute($body, 'skipReadBytes'));
+
+ // Seek to 0 and ensure the overwritten bit is replaced
+ $body->rewind();
+ $this->assertEquals("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", $body->read(50));
+
+ // Ensure that casting it to a string does not include the bit that was overwritten
+ $this->assertContains("0000\nABCD\nTEST\n0003\n0004\n0005\n0006\n1234\n0008\n0009\n", (string) $body);
+ }
+
+ public function testWrapsContentType()
+ {
+ $a = $this->getMockBuilder('Guzzle\Http\EntityBody')
+ ->setMethods(array('getContentType'))
+ ->setConstructorArgs(array(fopen(__FILE__, 'r')))
+ ->getMock();
+ $a->expects($this->once())
+ ->method('getContentType')
+ ->will($this->returnValue('foo'));
+ $d = new CachingEntityBody($a);
+ $this->assertEquals('foo', $d->getContentType());
+ }
+
+ public function testWrapsContentEncoding()
+ {
+ $a = $this->getMockBuilder('Guzzle\Http\EntityBody')
+ ->setMethods(array('getContentEncoding'))
+ ->setConstructorArgs(array(fopen(__FILE__, 'r')))
+ ->getMock();
+ $a->expects($this->once())
+ ->method('getContentEncoding')
+ ->will($this->returnValue('foo'));
+ $d = new CachingEntityBody($a);
+ $this->assertEquals('foo', $d->getContentEncoding());
+ }
+
+ public function testWrapsMetadata()
+ {
+ $a = $this->getMockBuilder('Guzzle\Http\EntityBody')
+ ->setMethods(array('getMetadata', 'getWrapper', 'getWrapperData', 'getStreamType', 'getUri'))
+ ->setConstructorArgs(array(fopen(__FILE__, 'r')))
+ ->getMock();
+
+ $a->expects($this->once())
+ ->method('getMetadata')
+ ->will($this->returnValue(array()));
+ // Called twice for getWrapper and getWrapperData
+ $a->expects($this->exactly(1))
+ ->method('getWrapper')
+ ->will($this->returnValue('wrapper'));
+ $a->expects($this->once())
+ ->method('getWrapperData')
+ ->will($this->returnValue(array()));
+ $a->expects($this->once())
+ ->method('getStreamType')
+ ->will($this->returnValue('baz'));
+ $a->expects($this->once())
+ ->method('getUri')
+ ->will($this->returnValue('path/to/foo'));
+
+ $d = new CachingEntityBody($a);
+ $this->assertEquals(array(), $d->getMetaData());
+ $this->assertEquals('wrapper', $d->getWrapper());
+ $this->assertEquals(array(), $d->getWrapperData());
+ $this->assertEquals('baz', $d->getStreamType());
+ $this->assertEquals('path/to/foo', $d->getUri());
+ }
+
+ public function testWrapsCustomData()
+ {
+ $a = $this->getMockBuilder('Guzzle\Http\EntityBody')
+ ->setMethods(array('getCustomData', 'setCustomData'))
+ ->setConstructorArgs(array(fopen(__FILE__, 'r')))
+ ->getMock();
+
+ $a->expects($this->exactly(1))
+ ->method('getCustomData')
+ ->with('foo')
+ ->will($this->returnValue('bar'));
+
+ $a->expects($this->exactly(1))
+ ->method('setCustomData')
+ ->with('foo', 'bar')
+ ->will($this->returnSelf());
+
+ $d = new CachingEntityBody($a);
+ $this->assertSame($d, $d->setCustomData('foo', 'bar'));
+ $this->assertEquals('bar', $d->getCustomData('foo'));
+ }
+
+ public function testClosesBothStreams()
+ {
+ $s = fopen('php://temp', 'r');
+ $a = EntityBody::factory($s);
+ $d = new CachingEntityBody($a);
+ $d->close();
+ $this->assertFalse(is_resource($s));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ClientTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ClientTest.php
new file mode 100644
index 0000000..4a91a18
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ClientTest.php
@@ -0,0 +1,601 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Common\Collection;
+use Guzzle\Log\ClosureLogAdapter;
+use Guzzle\Parser\UriTemplate\UriTemplate;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Log\LogPlugin;
+use Guzzle\Plugin\Mock\MockPlugin;
+use Guzzle\Http\Curl\CurlMulti;
+use Guzzle\Http\Client;
+use Guzzle\Common\Version;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Client
+ */
+class ClientTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @return LogPlugin
+ */
+ private function getLogPlugin()
+ {
+ return new LogPlugin(new ClosureLogAdapter(
+ function($message, $priority, $extras = null) {
+ echo $message . ' ' . $priority . ' ' . implode(' - ', (array) $extras) . "\n";
+ }
+ ));
+ }
+
+ public function testAcceptsConfig()
+ {
+ $client = new Client('http://www.google.com/');
+ $this->assertEquals('http://www.google.com/', $client->getBaseUrl());
+ $this->assertSame($client, $client->setConfig(array(
+ 'test' => '123'
+ )));
+ $this->assertEquals(array('test' => '123'), $client->getConfig()->getAll());
+ $this->assertEquals('123', $client->getConfig('test'));
+ $this->assertSame($client, $client->setBaseUrl('http://www.test.com/{test}'));
+ $this->assertEquals('http://www.test.com/123', $client->getBaseUrl());
+ $this->assertEquals('http://www.test.com/{test}', $client->getBaseUrl(false));
+
+ try {
+ $client->setConfig(false);
+ } catch (\InvalidArgumentException $e) {
+ }
+ }
+
+ public function testDescribesEvents()
+ {
+ $this->assertEquals(array('client.create_request'), Client::getAllEvents());
+ }
+
+ public function testConstructorCanAcceptConfig()
+ {
+ $client = new Client('http://www.test.com/', array(
+ 'data' => '123'
+ ));
+ $this->assertEquals('123', $client->getConfig('data'));
+ }
+
+ public function testCanUseCollectionAsConfig()
+ {
+ $client = new Client('http://www.google.com/');
+ $client->setConfig(new Collection(array(
+ 'api' => 'v1',
+ 'key' => 'value',
+ 'base_url' => 'http://www.google.com/'
+ )));
+ $this->assertEquals('v1', $client->getConfig('api'));
+ }
+
+ public function testExpandsUriTemplatesUsingConfig()
+ {
+ $client = new Client('http://www.google.com/');
+ $client->setConfig(array('api' => 'v1', 'key' => 'value', 'foo' => 'bar'));
+ $ref = new \ReflectionMethod($client, 'expandTemplate');
+ $ref->setAccessible(true);
+ $this->assertEquals('Testing...api/v1/key/value', $ref->invoke($client, 'Testing...api/{api}/key/{key}'));
+ }
+
+ public function testClientAttachersObserversToRequests()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+
+ $client = new Client($this->getServer()->getUrl());
+ $logPlugin = $this->getLogPlugin();
+ $client->getEventDispatcher()->addSubscriber($logPlugin);
+
+ // Get a request from the client and ensure the the observer was
+ // attached to the new request
+ $request = $client->createRequest();
+ $this->assertTrue($this->hasSubscriber($request, $logPlugin));
+ }
+
+ public function testClientReturnsValidBaseUrls()
+ {
+ $client = new Client('http://www.{foo}.{data}/', array(
+ 'data' => '123',
+ 'foo' => 'bar'
+ ));
+ $this->assertEquals('http://www.bar.123/', $client->getBaseUrl());
+ $client->setBaseUrl('http://www.google.com/');
+ $this->assertEquals('http://www.google.com/', $client->getBaseUrl());
+ }
+
+ public function testClientAddsCurlOptionsToRequests()
+ {
+ $client = new Client('http://www.test.com/', array(
+ 'api' => 'v1',
+ // Adds the option using the curl values
+ 'curl.options' => array(
+ 'CURLOPT_HTTPAUTH' => 'CURLAUTH_DIGEST',
+ 'abc' => 'foo',
+ 'blacklist' => 'abc',
+ 'debug' => true
+ )
+ ));
+
+ $request = $client->createRequest();
+ $options = $request->getCurlOptions();
+ $this->assertEquals(CURLAUTH_DIGEST, $options->get(CURLOPT_HTTPAUTH));
+ $this->assertEquals('foo', $options->get('abc'));
+ $this->assertEquals('abc', $options->get('blacklist'));
+ }
+
+ public function testClientAllowsFineGrainedSslControlButIsSecureByDefault()
+ {
+ $client = new Client('https://www.secure.com/');
+
+ // secure by default
+ $request = $client->createRequest();
+ $options = $request->getCurlOptions();
+ $this->assertTrue($options->get(CURLOPT_SSL_VERIFYPEER));
+
+ // set a capath if you prefer
+ $client = new Client('https://www.secure.com/');
+ $client->setSslVerification(__DIR__);
+ $request = $client->createRequest();
+ $options = $request->getCurlOptions();
+ $this->assertSame(__DIR__, $options->get(CURLOPT_CAPATH));
+ }
+
+ public function testConfigSettingsControlSslConfiguration()
+ {
+ // Use the default ca certs on the system
+ $client = new Client('https://www.secure.com/', array('ssl.certificate_authority' => 'system'));
+ $this->assertNull($client->getConfig('curl.options'));
+ // Can set the cacert value as well
+ $client = new Client('https://www.secure.com/', array('ssl.certificate_authority' => false));
+ $options = $client->getConfig('curl.options');
+ $this->assertArrayNotHasKey(CURLOPT_CAINFO, $options);
+ $this->assertSame(false, $options[CURLOPT_SSL_VERIFYPEER]);
+ $this->assertSame(0, $options[CURLOPT_SSL_VERIFYHOST]);
+ }
+
+ public function testClientAllowsUnsafeOperationIfRequested()
+ {
+ // be really unsafe if you insist
+ $client = new Client('https://www.secure.com/', array(
+ 'api' => 'v1'
+ ));
+
+ $client->setSslVerification(false);
+ $request = $client->createRequest();
+ $options = $request->getCurlOptions();
+ $this->assertFalse($options->get(CURLOPT_SSL_VERIFYPEER));
+ $this->assertNull($options->get(CURLOPT_CAINFO));
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ */
+ public function testThrowsExceptionForInvalidCertificate()
+ {
+ $client = new Client('https://www.secure.com/');
+ $client->setSslVerification('/path/to/missing/file');
+ }
+
+ public function testClientAllowsSettingSpecificSslCaInfo()
+ {
+ // set a file other than the provided cacert.pem
+ $client = new Client('https://www.secure.com/', array(
+ 'api' => 'v1'
+ ));
+
+ $client->setSslVerification(__FILE__);
+ $request = $client->createRequest();
+ $options = $request->getCurlOptions();
+ $this->assertSame(__FILE__, $options->get(CURLOPT_CAINFO));
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testClientPreventsInadvertentInsecureVerifyHostSetting()
+ {
+ // set a file other than the provided cacert.pem
+ $client = new Client('https://www.secure.com/', array(
+ 'api' => 'v1'
+ ));
+ $client->setSslVerification(__FILE__, true, true);
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testClientPreventsInvalidVerifyPeerSetting()
+ {
+ // set a file other than the provided cacert.pem
+ $client = new Client('https://www.secure.com/', array(
+ 'api' => 'v1'
+ ));
+ $client->setSslVerification(__FILE__, 'yes');
+ }
+
+ public function testClientAddsParamsToRequests()
+ {
+ Version::$emitWarnings = false;
+ $client = new Client('http://www.example.com', array(
+ 'api' => 'v1',
+ 'request.params' => array(
+ 'foo' => 'bar',
+ 'baz' => 'jar'
+ )
+ ));
+ $request = $client->createRequest();
+ $this->assertEquals('bar', $request->getParams()->get('foo'));
+ $this->assertEquals('jar', $request->getParams()->get('baz'));
+ Version::$emitWarnings = true;
+ }
+
+ public function urlProvider()
+ {
+ $u = $this->getServer()->getUrl() . 'base/';
+ $u2 = $this->getServer()->getUrl() . 'base?z=1';
+ return array(
+ array($u, '', $u),
+ array($u, 'relative/path/to/resource', $u . 'relative/path/to/resource'),
+ array($u, 'relative/path/to/resource?a=b&c=d', $u . 'relative/path/to/resource?a=b&c=d'),
+ array($u, '/absolute/path/to/resource', $this->getServer()->getUrl() . 'absolute/path/to/resource'),
+ array($u, '/absolute/path/to/resource?a=b&c=d', $this->getServer()->getUrl() . 'absolute/path/to/resource?a=b&c=d'),
+ array($u2, '/absolute/path/to/resource?a=b&c=d', $this->getServer()->getUrl() . 'absolute/path/to/resource?a=b&c=d&z=1'),
+ array($u2, 'relative/path/to/resource', $this->getServer()->getUrl() . 'base/relative/path/to/resource?z=1'),
+ array($u2, 'relative/path/to/resource?another=query', $this->getServer()->getUrl() . 'base/relative/path/to/resource?another=query&z=1')
+ );
+ }
+
+ /**
+ * @dataProvider urlProvider
+ */
+ public function testBuildsRelativeUrls($baseUrl, $url, $result)
+ {
+ $client = new Client($baseUrl);
+ $this->assertEquals($result, $client->get($url)->getUrl());
+ }
+
+ public function testAllowsConfigsToBeChangedAndInjectedInBaseUrl()
+ {
+ $client = new Client('http://{a}/{b}');
+ $this->assertEquals('http:///', $client->getBaseUrl());
+ $this->assertEquals('http://{a}/{b}', $client->getBaseUrl(false));
+ $client->setConfig(array(
+ 'a' => 'test.com',
+ 'b' => 'index.html'
+ ));
+ $this->assertEquals('http://test.com/index.html', $client->getBaseUrl());
+ }
+
+ public function testCreatesRequestsWithDefaultValues()
+ {
+ $client = new Client($this->getServer()->getUrl() . 'base');
+
+ // Create a GET request
+ $request = $client->createRequest();
+ $this->assertEquals('GET', $request->getMethod());
+ $this->assertEquals($client->getBaseUrl(), $request->getUrl());
+
+ // Create a DELETE request
+ $request = $client->createRequest('DELETE');
+ $this->assertEquals('DELETE', $request->getMethod());
+ $this->assertEquals($client->getBaseUrl(), $request->getUrl());
+
+ // Create a HEAD request with custom headers
+ $request = $client->createRequest('HEAD', 'http://www.test.com/');
+ $this->assertEquals('HEAD', $request->getMethod());
+ $this->assertEquals('http://www.test.com/', $request->getUrl());
+
+ // Create a PUT request
+ $request = $client->createRequest('PUT');
+ $this->assertEquals('PUT', $request->getMethod());
+
+ // Create a PUT request with injected config
+ $client->getConfig()->set('a', 1)->set('b', 2);
+ $request = $client->createRequest('PUT', '/path/{a}?q={b}');
+ $this->assertEquals($request->getUrl(), $this->getServer()->getUrl() . 'path/1?q=2');
+ }
+
+ public function testClientHasHelperMethodsForCreatingRequests()
+ {
+ $url = $this->getServer()->getUrl();
+ $client = new Client($url . 'base');
+ $this->assertEquals('GET', $client->get()->getMethod());
+ $this->assertEquals('PUT', $client->put()->getMethod());
+ $this->assertEquals('POST', $client->post()->getMethod());
+ $this->assertEquals('HEAD', $client->head()->getMethod());
+ $this->assertEquals('DELETE', $client->delete()->getMethod());
+ $this->assertEquals('OPTIONS', $client->options()->getMethod());
+ $this->assertEquals('PATCH', $client->patch()->getMethod());
+ $this->assertEquals($url . 'base/abc', $client->get('abc')->getUrl());
+ $this->assertEquals($url . 'zxy', $client->put('/zxy')->getUrl());
+ $this->assertEquals($url . 'zxy?a=b', $client->post('/zxy?a=b')->getUrl());
+ $this->assertEquals($url . 'base?a=b', $client->head('?a=b')->getUrl());
+ $this->assertEquals($url . 'base?a=b', $client->delete('/base?a=b')->getUrl());
+ }
+
+ public function testClientInjectsConfigsIntoUrls()
+ {
+ $client = new Client('http://www.test.com/api/v1', array(
+ 'test' => '123'
+ ));
+ $request = $client->get('relative/{test}');
+ $this->assertEquals('http://www.test.com/api/v1/relative/123', $request->getUrl());
+ }
+
+ public function testAllowsEmptyBaseUrl()
+ {
+ $client = new Client();
+ $request = $client->get('http://www.google.com/');
+ $this->assertEquals('http://www.google.com/', $request->getUrl());
+ $request->setResponse(new Response(200), true);
+ $request->send();
+ }
+
+ public function testAllowsCustomCurlMultiObjects()
+ {
+ $mock = $this->getMock('Guzzle\\Http\\Curl\\CurlMulti', array('add', 'send'));
+ $mock->expects($this->once())
+ ->method('add')
+ ->will($this->returnSelf());
+ $mock->expects($this->once())
+ ->method('send')
+ ->will($this->returnSelf());
+
+ $client = new Client();
+ $client->setCurlMulti($mock);
+
+ $request = $client->get();
+ $request->setResponse(new Response(200), true);
+ $client->send($request);
+ }
+
+ public function testClientSendsMultipleRequests()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $mock = new MockPlugin();
+
+ $responses = array(
+ new Response(200),
+ new Response(201),
+ new Response(202)
+ );
+
+ $mock->addResponse($responses[0]);
+ $mock->addResponse($responses[1]);
+ $mock->addResponse($responses[2]);
+
+ $client->getEventDispatcher()->addSubscriber($mock);
+
+ $requests = array(
+ $client->get(),
+ $client->head(),
+ $client->put('/', null, 'test')
+ );
+
+ $this->assertEquals(array(
+ $responses[0],
+ $responses[1],
+ $responses[2]
+ ), $client->send($requests));
+ }
+
+ public function testClientSendsSingleRequest()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $mock = new MockPlugin();
+ $response = new Response(200);
+ $mock->addResponse($response);
+ $client->getEventDispatcher()->addSubscriber($mock);
+ $this->assertEquals($response, $client->send($client->get()));
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\BadResponseException
+ */
+ public function testClientThrowsExceptionForSingleRequest()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $mock = new MockPlugin();
+ $response = new Response(404);
+ $mock->addResponse($response);
+ $client->getEventDispatcher()->addSubscriber($mock);
+ $client->send($client->get());
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\ExceptionCollection
+ */
+ public function testClientThrowsExceptionForMultipleRequests()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $mock = new MockPlugin();
+ $mock->addResponse(new Response(200));
+ $mock->addResponse(new Response(404));
+ $client->getEventDispatcher()->addSubscriber($mock);
+ $client->send(array($client->get(), $client->head()));
+ }
+
+ public function testQueryStringsAreNotDoubleEncoded()
+ {
+ $client = new Client('http://test.com', array(
+ 'path' => array('foo', 'bar'),
+ 'query' => 'hi there',
+ 'data' => array(
+ 'test' => 'a&b'
+ )
+ ));
+
+ $request = $client->get('{/path*}{?query,data*}');
+ $this->assertEquals('http://test.com/foo/bar?query=hi%20there&test=a%26b', $request->getUrl());
+ $this->assertEquals('hi there', $request->getQuery()->get('query'));
+ $this->assertEquals('a&b', $request->getQuery()->get('test'));
+ }
+
+ public function testQueryStringsAreNotDoubleEncodedUsingAbsolutePaths()
+ {
+ $client = new Client('http://test.com', array(
+ 'path' => array('foo', 'bar'),
+ 'query' => 'hi there',
+ ));
+ $request = $client->get('http://test.com{?query}');
+ $this->assertEquals('http://test.com?query=hi%20there', $request->getUrl());
+ $this->assertEquals('hi there', $request->getQuery()->get('query'));
+ }
+
+ public function testAllowsUriTemplateInjection()
+ {
+ $client = new Client('http://test.com');
+ $ref = new \ReflectionMethod($client, 'getUriTemplate');
+ $ref->setAccessible(true);
+ $a = $ref->invoke($client);
+ $this->assertSame($a, $ref->invoke($client));
+ $client->setUriTemplate(new UriTemplate());
+ $this->assertNotSame($a, $ref->invoke($client));
+ }
+
+ public function testAllowsCustomVariablesWhenExpandingTemplates()
+ {
+ $client = new Client('http://test.com', array('test' => 'hi'));
+ $ref = new \ReflectionMethod($client, 'expandTemplate');
+ $ref->setAccessible(true);
+ $uri = $ref->invoke($client, 'http://{test}{?query*}', array('query' => array('han' => 'solo')));
+ $this->assertEquals('http://hi?han=solo', $uri);
+ }
+
+ public function testUriArrayAllowsCustomTemplateVariables()
+ {
+ $client = new Client();
+ $vars = array(
+ 'var' => 'hi'
+ );
+ $this->assertEquals('/hi', (string) $client->createRequest('GET', array('/{var}', $vars))->getUrl());
+ $this->assertEquals('/hi', (string) $client->get(array('/{var}', $vars))->getUrl());
+ $this->assertEquals('/hi', (string) $client->put(array('/{var}', $vars))->getUrl());
+ $this->assertEquals('/hi', (string) $client->post(array('/{var}', $vars))->getUrl());
+ $this->assertEquals('/hi', (string) $client->head(array('/{var}', $vars))->getUrl());
+ $this->assertEquals('/hi', (string) $client->options(array('/{var}', $vars))->getUrl());
+ }
+
+ public function testAllowsDefaultHeaders()
+ {
+ Version::$emitWarnings = false;
+ $default = array('X-Test' => 'Hi!');
+ $other = array('X-Other' => 'Foo');
+
+ $client = new Client();
+ $client->setDefaultHeaders($default);
+ $this->assertEquals($default, $client->getDefaultHeaders()->getAll());
+ $client->setDefaultHeaders(new Collection($default));
+ $this->assertEquals($default, $client->getDefaultHeaders()->getAll());
+
+ $request = $client->createRequest('GET', null, $other);
+ $this->assertEquals('Hi!', $request->getHeader('X-Test'));
+ $this->assertEquals('Foo', $request->getHeader('X-Other'));
+
+ $request = $client->createRequest('GET', null, new Collection($other));
+ $this->assertEquals('Hi!', $request->getHeader('X-Test'));
+ $this->assertEquals('Foo', $request->getHeader('X-Other'));
+
+ $request = $client->createRequest('GET');
+ $this->assertEquals('Hi!', $request->getHeader('X-Test'));
+ Version::$emitWarnings = true;
+ }
+
+ public function testDontReuseCurlMulti()
+ {
+ $client1 = new Client();
+ $client2 = new Client();
+ $this->assertNotSame($client1->getCurlMulti(), $client2->getCurlMulti());
+ }
+
+ public function testGetDefaultUserAgent()
+ {
+ $client = new Client();
+ $agent = $this->readAttribute($client, 'userAgent');
+ $version = curl_version();
+ $testAgent = sprintf('Guzzle/%s curl/%s PHP/%s', Version::VERSION, $version['version'], PHP_VERSION);
+ $this->assertEquals($agent, $testAgent);
+
+ $client->setUserAgent('foo');
+ $this->assertEquals('foo', $this->readAttribute($client, 'userAgent'));
+ }
+
+ public function testOverwritesUserAgent()
+ {
+ $client = new Client();
+ $request = $client->createRequest('GET', 'http://www.foo.com', array('User-agent' => 'foo'));
+ $this->assertEquals('foo', (string) $request->getHeader('User-Agent'));
+ }
+
+ public function testUsesDefaultUserAgent()
+ {
+ $client = new Client();
+ $request = $client->createRequest('GET', 'http://www.foo.com');
+ $this->assertContains('Guzzle/', (string) $request->getHeader('User-Agent'));
+ }
+
+ public function testCanSetDefaultRequestOptions()
+ {
+ $client = new Client();
+ $client->getConfig()->set('request.options', array(
+ 'query' => array('test' => '123', 'other' => 'abc'),
+ 'headers' => array('Foo' => 'Bar', 'Baz' => 'Bam')
+ ));
+ $request = $client->createRequest('GET', 'http://www.foo.com?test=hello', array('Foo' => 'Test'));
+ // Explicit options on a request should overrule default options
+ $this->assertEquals('Test', (string) $request->getHeader('Foo'));
+ $this->assertEquals('hello', $request->getQuery()->get('test'));
+ // Default options should still be set
+ $this->assertEquals('abc', $request->getQuery()->get('other'));
+ $this->assertEquals('Bam', (string) $request->getHeader('Baz'));
+ }
+
+ public function testCanSetSetOptionsOnRequests()
+ {
+ $client = new Client();
+ $request = $client->createRequest('GET', 'http://www.foo.com?test=hello', array('Foo' => 'Test'), null, array(
+ 'cookies' => array('michael' => 'test')
+ ));
+ $this->assertEquals('test', $request->getCookie('michael'));
+ }
+
+ public function testHasDefaultOptionsHelperMethods()
+ {
+ $client = new Client();
+ // With path
+ $client->setDefaultOption('headers/foo', 'bar');
+ $this->assertEquals('bar', $client->getDefaultOption('headers/foo'));
+ // With simple key
+ $client->setDefaultOption('allow_redirects', false);
+ $this->assertFalse($client->getDefaultOption('allow_redirects'));
+
+ $this->assertEquals(array(
+ 'headers' => array('foo' => 'bar'),
+ 'allow_redirects' => false
+ ), $client->getConfig('request.options'));
+
+ $request = $client->get('/');
+ $this->assertEquals('bar', $request->getHeader('foo'));
+ }
+
+ public function testHeadCanUseOptions()
+ {
+ $client = new Client();
+ $head = $client->head('http://www.foo.com', array(), array('query' => array('foo' => 'bar')));
+ $this->assertEquals('bar', $head->getQuery()->get('foo'));
+ }
+
+ public function testCanSetRelativeUrlStartingWithHttp()
+ {
+ $client = new Client('http://www.foo.com');
+ $this->assertEquals(
+ 'http://www.foo.com/httpfoo',
+ $client->createRequest('GET', 'httpfoo')->getUrl()
+ );
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlHandleTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlHandleTest.php
new file mode 100644
index 0000000..5bf28de
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlHandleTest.php
@@ -0,0 +1,947 @@
+<?php
+
+namespace Guzzle\Tests\Http\Curl;
+
+use Guzzle\Common\Collection;
+use Guzzle\Common\Event;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\QueryString;
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Http\Curl\CurlHandle;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Curl\CurlHandle
+ */
+class CurlHandleTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public $requestHandle;
+
+ protected function updateForHandle(RequestInterface $request)
+ {
+ $that = $this;
+ $request->getEventDispatcher()->addListener('request.sent', function (Event $e) use ($that) {
+ $that->requestHandle = $e['handle'];
+ });
+
+ return $request;
+ }
+
+ public function setUp()
+ {
+ $this->requestHandle = null;
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testConstructorExpectsCurlResource()
+ {
+ $h = new CurlHandle(false, array());
+ }
+
+ public function testConstructorExpectsProperOptions()
+ {
+ $h = curl_init($this->getServer()->getUrl());
+ try {
+ $ha = new CurlHandle($h, false);
+ $this->fail('Expected InvalidArgumentException');
+ } catch (\InvalidArgumentException $e) {
+ }
+
+ $ha = new CurlHandle($h, array(
+ CURLOPT_URL => $this->getServer()->getUrl()
+ ));
+ $this->assertEquals($this->getServer()->getUrl(), $ha->getOptions()->get(CURLOPT_URL));
+
+ $ha = new CurlHandle($h, new Collection(array(
+ CURLOPT_URL => $this->getServer()->getUrl()
+ )));
+ $this->assertEquals($this->getServer()->getUrl(), $ha->getOptions()->get(CURLOPT_URL));
+ }
+
+ public function testConstructorInitializesObject()
+ {
+ $handle = curl_init($this->getServer()->getUrl());
+ $h = new CurlHandle($handle, array(
+ CURLOPT_URL => $this->getServer()->getUrl()
+ ));
+ $this->assertSame($handle, $h->getHandle());
+ $this->assertInstanceOf('Guzzle\\Http\\Url', $h->getUrl());
+ $this->assertEquals($this->getServer()->getUrl(), (string) $h->getUrl());
+ $this->assertEquals($this->getServer()->getUrl(), $h->getOptions()->get(CURLOPT_URL));
+ }
+
+ public function testStoresStdErr()
+ {
+ $request = RequestFactory::getInstance()->create('GET', 'http://test.com');
+ $request->getCurlOptions()->set('debug', true);
+ $h = CurlHandle::factory($request);
+ $this->assertEquals($h->getStderr(true), $h->getOptions()->get(CURLOPT_STDERR));
+ $this->assertInternalType('resource', $h->getStderr(true));
+ $this->assertInternalType('string', $h->getStderr(false));
+ $r = $h->getStderr(true);
+ fwrite($r, 'test');
+ $this->assertEquals('test', $h->getStderr(false));
+ }
+
+ public function testStoresCurlErrorNumber()
+ {
+ $h = new CurlHandle(curl_init('http://test.com'), array(CURLOPT_URL => 'http://test.com'));
+ $this->assertEquals(CURLE_OK, $h->getErrorNo());
+ $h->setErrorNo(CURLE_OPERATION_TIMEOUTED);
+ $this->assertEquals(CURLE_OPERATION_TIMEOUTED, $h->getErrorNo());
+ }
+
+ public function testAccountsForMissingStdErr()
+ {
+ $handle = curl_init('http://www.test.com/');
+ $h = new CurlHandle($handle, array(
+ CURLOPT_URL => 'http://www.test.com/'
+ ));
+ $this->assertNull($h->getStderr(false));
+ }
+
+ public function testDeterminesIfResourceIsAvailable()
+ {
+ $handle = curl_init($this->getServer()->getUrl());
+ $h = new CurlHandle($handle, array());
+ $this->assertTrue($h->isAvailable());
+
+ // Mess it up by closing the handle
+ curl_close($handle);
+ $this->assertFalse($h->isAvailable());
+
+ // Mess it up by unsetting the handle
+ $handle = null;
+ $this->assertFalse($h->isAvailable());
+ }
+
+ public function testWrapsErrorsAndInfo()
+ {
+ if (!defined('CURLOPT_TIMEOUT_MS')) {
+ $this->markTestSkipped('Update curl');
+ }
+
+ $settings = array(
+ CURLOPT_PORT => 123,
+ CURLOPT_CONNECTTIMEOUT_MS => 1,
+ CURLOPT_TIMEOUT_MS => 1
+ );
+
+ $handle = curl_init($this->getServer()->getUrl());
+ curl_setopt_array($handle, $settings);
+ $h = new CurlHandle($handle, $settings);
+ @curl_exec($handle);
+
+ $errors = array(
+ "couldn't connect to host",
+ 'timeout was reached',
+ 'connection time-out',
+ 'connect() timed out!',
+ 'failed connect to 127.0.0.1:123; connection refused',
+ 'failed to connect to 127.0.0.1 port 123: connection refused'
+ );
+ $this->assertTrue(in_array(strtolower($h->getError()), $errors), $h->getError() . ' was not the error');
+
+ $this->assertTrue($h->getErrorNo() > 0);
+
+ $this->assertEquals($this->getServer()->getUrl(), $h->getInfo(CURLINFO_EFFECTIVE_URL));
+ $this->assertInternalType('array', $h->getInfo());
+
+ curl_close($handle);
+ $this->assertEquals(null, $h->getInfo('url'));
+ }
+
+ public function testGetInfoWithoutDebugMode()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get($this->getServer()->getUrl());
+ $response = $request->send();
+
+ $info = $response->getInfo();
+ $this->assertFalse(empty($info));
+ $this->assertEquals($this->getServer()->getUrl(), $info['url']);
+ }
+
+ public function testWrapsCurlOptions()
+ {
+ $handle = curl_init($this->getServer()->getUrl());
+ $h = new CurlHandle($handle, array(
+ CURLOPT_AUTOREFERER => true,
+ CURLOPT_BUFFERSIZE => 1024
+ ));
+
+ $this->assertEquals(true, $h->getOptions()->get(CURLOPT_AUTOREFERER));
+ $this->assertEquals(1024, $h->getOptions()->get(CURLOPT_BUFFERSIZE));
+ }
+
+ /**
+ * Data provider for factory tests
+ *
+ * @return array
+ */
+ public function dataProvider()
+ {
+ $testFile = __DIR__ . '/../../../../../phpunit.xml.dist';
+
+ $postBody = new QueryString(array('file' => '@' . $testFile));
+ $qs = new QueryString(array(
+ 'x' => 'y',
+ 'z' => 'a'
+ ));
+
+ $client = new Client();
+ $userAgent = $client->getDefaultUserAgent();
+ $auth = base64_encode('michael:123');
+ $testFileSize = filesize($testFile);
+
+ $tests = array(
+ // Send a regular GET
+ array('GET', 'http://www.google.com/', null, null, array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_HTTPHEADER => array('Accept:', 'Host: www.google.com', 'User-Agent: ' . $userAgent),
+ )),
+ // Test that custom request methods can be used
+ array('TRACE', 'http://www.google.com/', null, null, array(
+ CURLOPT_CUSTOMREQUEST => 'TRACE'
+ )),
+ // Send a GET using a port
+ array('GET', 'http://127.0.0.1:8080', null, null, array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_PORT => 8080,
+ CURLOPT_HTTPHEADER => array('Accept:', 'Host: 127.0.0.1:8080', 'User-Agent: ' . $userAgent),
+ )),
+ // Send a HEAD request
+ array('HEAD', 'http://www.google.com/', null, null, array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_HTTPHEADER => array('Accept:', 'Host: www.google.com', 'User-Agent: ' . $userAgent),
+ CURLOPT_NOBODY => 1
+ )),
+ // Send a GET using basic auth
+ array('GET', 'https://michael:123@127.0.0.1/index.html?q=2', null, null, array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_HTTPHEADER => array(
+ 'Accept:',
+ 'Host: 127.0.0.1',
+ 'Authorization: Basic ' . $auth,
+ 'User-Agent: ' . $userAgent
+ ),
+ CURLOPT_PORT => 443
+ )),
+ // Send a GET request with custom headers
+ array('GET', 'http://127.0.0.1:8124/', array(
+ 'x-test-data' => 'Guzzle'
+ ), null, array(
+ CURLOPT_PORT => 8124,
+ CURLOPT_HTTPHEADER => array(
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'x-test-data: Guzzle',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'x-test-data' => 'Guzzle'
+ )),
+ // Send a POST using a query string
+ array('POST', 'http://127.0.0.1:8124/post.php', null, $qs, array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_POSTFIELDS => 'x=y&z=a',
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Length' => '7',
+ '!Expect' => null,
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
+ '!Transfer-Encoding' => null
+ )),
+ // Send a PUT using raw data
+ array('PUT', 'http://127.0.0.1:8124/put.php', null, EntityBody::factory(fopen($testFile, 'r+')), array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_READFUNCTION => 'callback',
+ CURLOPT_INFILESIZE => filesize($testFile),
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ '!Expect' => null,
+ 'Content-Length' => $testFileSize,
+ '!Transfer-Encoding' => null
+ )),
+ // Send a POST request using an array of fields
+ array('POST', 'http://127.0.0.1:8124/post.php', null, array(
+ 'x' => 'y',
+ 'a' => 'b'
+ ), array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_POST => 1,
+ CURLOPT_POSTFIELDS => 'x=y&a=b',
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'Content-Type: application/x-www-form-urlencoded; charset=utf-8',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Length' => '7',
+ '!Expect' => null,
+ 'Content-Type' => 'application/x-www-form-urlencoded; charset=utf-8',
+ '!Transfer-Encoding' => null
+ )),
+ // Send a POST request with raw POST data and a custom content-type
+ array('POST', 'http://127.0.0.1:8124/post.php', array(
+ 'Content-Type' => 'application/json'
+ ), '{"hi":"there"}', array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_UPLOAD => true,
+ CURLOPT_INFILESIZE => 14,
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'Content-Type: application/json',
+ 'User-Agent: ' . $userAgent
+ ),
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Type' => 'application/json',
+ '!Expect' => null,
+ 'Content-Length' => '14',
+ '!Transfer-Encoding' => null
+ )),
+ // Send a POST request with raw POST data, a custom content-type, and use chunked encoding
+ array('POST', 'http://127.0.0.1:8124/post.php', array(
+ 'Content-Type' => 'application/json',
+ 'Transfer-Encoding' => 'chunked'
+ ), '{"hi":"there"}', array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_UPLOAD => true,
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'Transfer-Encoding: chunked',
+ 'Content-Type: application/json',
+ 'User-Agent: ' . $userAgent
+ ),
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Type' => 'application/json',
+ '!Expect' => null,
+ 'Transfer-Encoding' => 'chunked',
+ '!Content-Length' => ''
+ )),
+ // Send a POST request with no body
+ array('POST', 'http://127.0.0.1:8124/post.php', null, '', array(
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Length' => '0',
+ '!Transfer-Encoding' => null
+ )),
+ // Send a POST request with empty post fields
+ array('POST', 'http://127.0.0.1:8124/post.php', null, array(), array(
+ CURLOPT_CUSTOMREQUEST => 'POST',
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Length' => '0',
+ '!Transfer-Encoding' => null
+ )),
+ // Send a PATCH request
+ array('PATCH', 'http://127.0.0.1:8124/patch.php', null, 'body', array(
+ CURLOPT_INFILESIZE => 4,
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'User-Agent: ' . $userAgent
+ )
+ )),
+ // Send a DELETE request with a body
+ array('DELETE', 'http://127.0.0.1:8124/delete.php', null, 'body', array(
+ CURLOPT_CUSTOMREQUEST => 'DELETE',
+ CURLOPT_INFILESIZE => 4,
+ CURLOPT_HTTPHEADER => array (
+ 'Expect:',
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Length' => '4',
+ '!Expect' => null,
+ '!Transfer-Encoding' => null
+ )),
+
+ /**
+ * Send a request with empty path and a fragment - the fragment must be
+ * stripped out before sending it to curl
+ *
+ * @issue 453
+ * @link https://github.com/guzzle/guzzle/issues/453
+ */
+ array('GET', 'http://www.google.com#head', null, null, array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_HTTPHEADER => array('Accept:', 'Host: www.google.com', 'User-Agent: ' . $userAgent),
+ )),
+ );
+
+ $postTest = array('POST', 'http://127.0.0.1:8124/post.php', null, $postBody, array(
+ CURLOPT_RETURNTRANSFER => 0,
+ CURLOPT_HEADER => 0,
+ CURLOPT_CONNECTTIMEOUT => 150,
+ CURLOPT_WRITEFUNCTION => 'callback',
+ CURLOPT_HEADERFUNCTION => 'callback',
+ CURLOPT_POST => 1,
+ CURLOPT_POSTFIELDS => array(
+ 'file' => '@' . $testFile . ';filename=phpunit.xml.dist;type=application/octet-stream'
+ ),
+ CURLOPT_HTTPHEADER => array (
+ 'Accept:',
+ 'Host: 127.0.0.1:8124',
+ 'Content-Type: multipart/form-data',
+ 'Expect: 100-Continue',
+ 'User-Agent: ' . $userAgent
+ )
+ ), array(
+ 'Host' => '*',
+ 'User-Agent' => '*',
+ 'Content-Length' => '*',
+ 'Expect' => '100-Continue',
+ 'Content-Type' => 'multipart/form-data; boundary=*',
+ '!Transfer-Encoding' => null
+ ));
+
+ if (version_compare(phpversion(), '5.5.0', '>=')) {
+ $postTest[4][CURLOPT_POSTFIELDS] = array(
+ 'file' => new \CurlFile($testFile, 'application/octet-stream', 'phpunit.xml.dist')
+ );
+ }
+
+ $tests[] = $postTest;
+
+ return $tests;
+ }
+
+ /**
+ * @dataProvider dataProvider
+ */
+ public function testFactoryCreatesCurlBasedOnRequest($method, $url, $headers, $body, $options, $expectedHeaders = null)
+ {
+ $client = new Client();
+ $request = $client->createRequest($method, $url, $headers, $body);
+ $request->getCurlOptions()->set('debug', true);
+
+ $originalRequest = clone $request;
+ $curlTest = clone $request;
+ $handle = CurlHandle::factory($curlTest);
+
+ $this->assertInstanceOf('Guzzle\\Http\\Curl\\CurlHandle', $handle);
+ $o = $handle->getOptions()->getAll();
+
+ // Headers are case-insensitive
+ if (isset($o[CURLOPT_HTTPHEADER])) {
+ $o[CURLOPT_HTTPHEADER] = array_map('strtolower', $o[CURLOPT_HTTPHEADER]);
+ }
+ if (isset($options[CURLOPT_HTTPHEADER])) {
+ $options[CURLOPT_HTTPHEADER] = array_map('strtolower', $options[CURLOPT_HTTPHEADER]);
+ }
+
+ $check = 0;
+ foreach ($options as $key => $value) {
+ $check++;
+ $this->assertArrayHasKey($key, $o, '-> Check number ' . $check);
+ if ($key != CURLOPT_HTTPHEADER && $key != CURLOPT_POSTFIELDS && (is_array($o[$key])) || $o[$key] instanceof \Closure) {
+ $this->assertEquals('callback', $value, '-> Check number ' . $check);
+ } else {
+ $this->assertTrue($value == $o[$key], '-> Check number ' . $check . ' - ' . var_export($value, true) . ' != ' . var_export($o[$key], true));
+ }
+ }
+
+ // If we are testing the actual sent headers
+ if ($expectedHeaders) {
+
+ // Send the request to the test server
+ $client = new Client($this->getServer()->getUrl());
+ $request->setClient($client);
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request->send();
+
+ // Get the request that was sent and create a request that we expected
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals($method, $requests[0]->getMethod());
+
+ $test = $this->compareHeaders($expectedHeaders, $requests[0]->getHeaders());
+ $this->assertFalse($test, $test . "\nSent: \n" . $request . "\n\n" . $requests[0]);
+
+ // Ensure only one Content-Length header is sent
+ if ($request->getHeader('Content-Length')) {
+ $this->assertEquals((string) $request->getHeader('Content-Length'), (string) $requests[0]->getHeader('Content-Length'));
+ }
+ }
+ }
+
+ public function testFactoryUsesSpecifiedProtocol()
+ {
+ $request = RequestFactory::getInstance()->create('GET', 'http://127.0.0.1:8124/');
+ $request->setProtocolVersion('1.1');
+ $handle = CurlHandle::factory($request);
+ $options = $handle->getOptions();
+ $this->assertEquals(CURL_HTTP_VERSION_1_1, $options[CURLOPT_HTTP_VERSION]);
+ }
+
+ public function testUploadsPutData()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put('/');
+ $request->getCurlOptions()->set('debug', true);
+ $request->setBody(EntityBody::factory('test'), 'text/plain', false);
+ $request->getCurlOptions()->set('progress', true);
+
+ $o = $this->getWildcardObserver($request);
+ $request->send();
+
+ // Make sure that the events were dispatched
+ $this->assertTrue($o->has('curl.callback.progress'));
+
+ // Ensure that the request was received exactly as intended
+ $r = $this->getServer()->getReceivedRequests(true);
+ $this->assertFalse($r[0]->hasHeader('Transfer-Encoding'));
+ $this->assertEquals(4, (string) $r[0]->getHeader('Content-Length'));
+ $sent = strtolower($r[0]);
+ $this->assertContains('put / http/1.1', $sent);
+ $this->assertContains('host: 127.0.0.1', $sent);
+ $this->assertContains('user-agent:', $sent);
+ $this->assertContains('content-type: text/plain', $sent);
+ }
+
+ public function testUploadsPutDataUsingChunkedEncodingWhenLengthCannotBeDetermined()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi"
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put('/');
+ $request->setBody(EntityBody::factory(fopen($this->getServer()->getUrl(), 'r')), 'text/plain');
+ $request->send();
+
+ $r = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('chunked', $r[1]->getHeader('Transfer-Encoding'));
+ $this->assertFalse($r[1]->hasHeader('Content-Length'));
+ }
+
+ public function testUploadsPutDataUsingChunkedEncodingWhenForced()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put('/', array('Transfer-Encoding' => 'chunked'), 'hi!');
+ $request->send();
+
+ $r = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('chunked', $r[0]->getHeader('Transfer-Encoding'));
+ $this->assertFalse($r[0]->hasHeader('Content-Length'));
+ $this->assertEquals('hi!', $r[0]->getBody(true));
+ }
+
+ public function testSendsPostRequestsWithFields()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+
+ $request = RequestFactory::getInstance()->create('POST', $this->getServer()->getUrl());
+ $request->getCurlOptions()->set('debug', true);
+ $request->setClient(new Client());
+ $request->addPostFields(array(
+ 'a' => 'b',
+ 'c' => 'ay! ~This is a test, isn\'t it?'
+ ));
+ $request->send();
+
+ // Make sure that the request was sent correctly
+ $r = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('a=b&c=ay%21%20~This%20is%20a%20test%2C%20isn%27t%20it%3F', (string) $r[0]->getBody());
+ $this->assertFalse($r[0]->hasHeader('Transfer-Encoding'));
+ $this->assertEquals(56, (string) $r[0]->getHeader('Content-Length'));
+ $sent = strtolower($r[0]);
+ $this->assertContains('post / http/1.1', $sent);
+ $this->assertContains('content-type: application/x-www-form-urlencoded; charset=utf-8', $sent);
+ }
+
+ public function testSendsPostRequestsWithFiles()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+
+ $request = RequestFactory::getInstance()->create('POST', $this->getServer()->getUrl());
+ $request->getCurlOptions()->set('debug', true);
+ $request->setClient(new Client());
+ $request->addPostFiles(array(
+ 'foo' => __FILE__,
+ ));
+ $request->addPostFields(array(
+ 'bar' => 'baz',
+ 'arr' => array('a' => 1, 'b' => 2),
+ ));
+ $this->updateForHandle($request);
+ $request->send();
+
+ // Ensure the CURLOPT_POSTFIELDS option was set properly
+ $options = $this->requestHandle->getOptions()->getAll();
+ if (version_compare(phpversion(), '5.5.0', '<')) {
+ $this->assertContains('@' . __FILE__ . ';filename=CurlHandleTest.php;type=text/x-', $options[CURLOPT_POSTFIELDS]['foo']);
+ } else{
+ $this->assertInstanceOf('CURLFile', $options[CURLOPT_POSTFIELDS]['foo']);
+ }
+ $this->assertEquals('baz', $options[CURLOPT_POSTFIELDS]['bar']);
+ $this->assertEquals('1', $options[CURLOPT_POSTFIELDS]['arr[a]']);
+ $this->assertEquals('2', $options[CURLOPT_POSTFIELDS]['arr[b]']);
+ // Ensure that a Content-Length header was sent by cURL
+ $this->assertTrue($request->hasHeader('Content-Length'));
+ }
+
+ public function testCurlConfigurationOptionsAreSet()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', $this->getServer()->getUrl());
+ $request->setClient(new Client('http://www.example.com'));
+ $request->getCurlOptions()->set(CURLOPT_CONNECTTIMEOUT, 99);
+ $request->getCurlOptions()->set('curl.fake_opt', 99);
+ $request->getCurlOptions()->set(CURLOPT_PORT, 8181);
+ $handle = CurlHandle::factory($request);
+ $this->assertEquals(99, $handle->getOptions()->get(CURLOPT_CONNECTTIMEOUT));
+ $this->assertEquals(8181, $handle->getOptions()->get(CURLOPT_PORT));
+ $this->assertNull($handle->getOptions()->get('curl.fake_opt'));
+ $this->assertNull($handle->getOptions()->get('fake_opt'));
+ }
+
+ public function testEnsuresRequestsHaveResponsesWhenUpdatingFromTransfer()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', $this->getServer()->getUrl());
+ $handle = CurlHandle::factory($request);
+ $handle->updateRequestFromTransfer($request);
+ }
+
+ public function testCanSendBodyAsString()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put('/', null, 'foo');
+ $request->getCurlOptions()->set('body_as_string', true);
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(false);
+ $this->assertContains('PUT /', $requests[0]);
+ $this->assertContains("\nfoo", $requests[0]);
+ $this->assertContains('content-length: 3', $requests[0]);
+ $this->assertNotContains('content-type', $requests[0]);
+ }
+
+ public function testCanSendPostBodyAsString()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->post('/', null, 'foo');
+ $request->getCurlOptions()->set('body_as_string', true);
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(false);
+ $this->assertContains('POST /', $requests[0]);
+ $this->assertContains("\nfoo", $requests[0]);
+ $this->assertContains('content-length: 3', $requests[0]);
+ $this->assertNotContains('content-type', $requests[0]);
+ }
+
+ public function testAllowsWireTransferInfoToBeEnabled()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', $this->getServer()->getUrl());
+ $request->getCurlOptions()->set('debug', true);
+ $handle = CurlHandle::factory($request);
+ $this->assertNotNull($handle->getOptions()->get(CURLOPT_STDERR));
+ $this->assertNotNull($handle->getOptions()->get(CURLOPT_VERBOSE));
+ }
+
+ public function testAddsCustomCurlOptions()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', $this->getServer()->getUrl());
+ $request->getCurlOptions()->set(CURLOPT_TIMEOUT, 200);
+ $handle = CurlHandle::factory($request);
+ $this->assertEquals(200, $handle->getOptions()->get(CURLOPT_TIMEOUT));
+ }
+
+ public function testSendsPostUploadsWithContentDispositionHeaders()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\n\r\nContent-Length: 0\r\n\r\n");
+
+ $fileToUpload = dirname(dirname(__DIR__)) . DIRECTORY_SEPARATOR . 'TestData' . DIRECTORY_SEPARATOR . 'test_service.json';
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->post();
+ $request->addPostFile('foo', $fileToUpload, 'application/json');
+ $request->addPostFile('foo', __FILE__);
+
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $body = (string) $requests[0]->getBody();
+
+ $this->assertContains('Content-Disposition: form-data; name="foo[0]"; filename="', $body);
+ $this->assertContains('Content-Type: application/json', $body);
+ $this->assertContains('Content-Type: text/x-', $body);
+ $this->assertContains('Content-Disposition: form-data; name="foo[1]"; filename="', $body);
+ }
+
+ public function requestMethodProvider()
+ {
+ return array(array('POST'), array('PUT'), array('PATCH'));
+ }
+
+ /**
+ * @dataProvider requestMethodProvider
+ */
+ public function testSendsRequestsWithNoBodyUsingContentLengthZero($method)
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $client = new Client($this->getServer()->getUrl());
+ $client->createRequest($method)->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertFalse($requests[0]->hasHeader('Transfer-Encoding'));
+ $this->assertTrue($requests[0]->hasHeader('Content-Length'));
+ $this->assertEquals('0', (string) $requests[0]->getHeader('Content-Length'));
+ }
+
+ /**
+ * @dataProvider provideCurlConfig
+ */
+ public function testParseCurlConfigConvertsStringKeysToConstantKeys($options, $expected)
+ {
+ $actual = CurlHandle::parseCurlConfig($options);
+ $this->assertEquals($expected, $actual);
+ }
+
+ /**
+ * Data provider for curl configurations
+ *
+ * @return array
+ */
+ public function provideCurlConfig()
+ {
+ return array(
+ // Conversion of option name to constant value
+ array(
+ array(
+ 'CURLOPT_PORT' => 10,
+ 'CURLOPT_TIMEOUT' => 99
+ ),
+ array(
+ CURLOPT_PORT => 10,
+ CURLOPT_TIMEOUT => 99
+ )
+ ),
+ // Keeps non constant options
+ array(
+ array('debug' => true),
+ array('debug' => true)
+ ),
+ // Conversion of constant names to constant values
+ array(
+ array('debug' => 'CURLPROXY_HTTP'),
+ array('debug' => CURLPROXY_HTTP)
+ )
+ );
+ }
+
+ public function testSeeksToBeginningOfStreamWhenSending()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put('/', null, 'test');
+ $request->send();
+ $request->send();
+
+ $received = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals(2, count($received));
+ $this->assertEquals('test', (string) $received[0]->getBody());
+ $this->assertEquals('test', (string) $received[1]->getBody());
+ }
+
+ public function testAllowsCurloptEncodingToBeSet()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get('/', null);
+ $request->getCurlOptions()->set(CURLOPT_ENCODING, '');
+ $this->updateForHandle($request);
+ $request->send();
+ $options = $this->requestHandle->getOptions()->getAll();
+ $this->assertSame('', $options[CURLOPT_ENCODING]);
+ $received = $this->getServer()->getReceivedRequests(false);
+ $this->assertContainsIns('accept: */*', $received[0]);
+ $this->assertContainsIns('accept-encoding: ', $received[0]);
+ }
+
+ public function testSendsExpectHeaderWhenSizeIsGreaterThanCutoff()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put('/', null, 'test');
+ // Start sending the expect header to 2 bytes
+ $this->updateForHandle($request);
+ $request->setExpectHeaderCutoff(2)->send();
+ $options = $this->requestHandle->getOptions()->getAll();
+ $this->assertContains('Expect: 100-Continue', $options[CURLOPT_HTTPHEADER]);
+ $received = $this->getServer()->getReceivedRequests(false);
+ $this->assertContainsIns('expect: 100-continue', $received[0]);
+ }
+
+ public function testSetsCurloptEncodingWhenAcceptEncodingHeaderIsSet()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata");
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get('/', array(
+ 'Accept' => 'application/json',
+ 'Accept-Encoding' => 'gzip, deflate',
+ ));
+ $this->updateForHandle($request);
+ $request->send();
+ $options = $this->requestHandle->getOptions()->getAll();
+ $this->assertSame('gzip, deflate', $options[CURLOPT_ENCODING]);
+ $received = $this->getServer()->getReceivedRequests(false);
+ $this->assertContainsIns('accept: application/json', $received[0]);
+ $this->assertContainsIns('accept-encoding: gzip, deflate', $received[0]);
+ }
+
+ public function testSendsPostFieldsForNonPostRequests()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\n\r\nContent-Length: 0\r\n\r\n");
+
+ $client = new Client();
+ $request = $client->put($this->getServer()->getUrl(), null, array(
+ 'foo' => 'baz',
+ 'baz' => 'bar'
+ ));
+
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('PUT', $requests[0]->getMethod());
+ $this->assertEquals(
+ 'application/x-www-form-urlencoded; charset=utf-8',
+ (string) $requests[0]->getHeader('Content-Type')
+ );
+ $this->assertEquals(15, (string) $requests[0]->getHeader('Content-Length'));
+ $this->assertEquals('foo=baz&baz=bar', (string) $requests[0]->getBody());
+ }
+
+ public function testSendsPostFilesForNonPostRequests()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\n\r\nContent-Length: 0\r\n\r\n");
+
+ $client = new Client();
+ $request = $client->put($this->getServer()->getUrl(), null, array(
+ 'foo' => '@' . __FILE__
+ ));
+
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('PUT', $requests[0]->getMethod());
+ $this->assertContains('multipart/form-data', (string) $requests[0]->getHeader('Content-Type'));
+ $this->assertContains('testSendsPostFilesForNonPostRequests', (string) $requests[0]->getBody());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiProxyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiProxyTest.php
new file mode 100644
index 0000000..e04141c
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiProxyTest.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace Guzzle\Tests\Http\Curl;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Curl\CurlMultiProxy;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Curl\CurlMultiProxy
+ */
+class CurlMultiProxyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ const SELECT_TIMEOUT = 23.1;
+
+ const MAX_HANDLES = 2;
+
+ /** @var \Guzzle\Http\Curl\CurlMultiProxy */
+ private $multi;
+
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->multi = new CurlMultiProxy(self::MAX_HANDLES, self::SELECT_TIMEOUT);
+ }
+
+ public function tearDown()
+ {
+ unset($this->multi);
+ }
+
+ public function testConstructorSetsMaxHandles()
+ {
+ $m = new CurlMultiProxy(self::MAX_HANDLES, self::SELECT_TIMEOUT);
+ $this->assertEquals(self::MAX_HANDLES, $this->readAttribute($m, 'maxHandles'));
+ }
+
+ public function testConstructorSetsSelectTimeout()
+ {
+ $m = new CurlMultiProxy(self::MAX_HANDLES, self::SELECT_TIMEOUT);
+ $this->assertEquals(self::SELECT_TIMEOUT, $this->readAttribute($m, 'selectTimeout'));
+ }
+
+ public function testAddingRequestsAddsToQueue()
+ {
+ $r = new Request('GET', 'http://www.foo.com');
+ $this->assertSame($this->multi, $this->multi->add($r));
+ $this->assertEquals(1, count($this->multi));
+ $this->assertEquals(array($r), $this->multi->all());
+
+ $this->assertTrue($this->multi->remove($r));
+ $this->assertFalse($this->multi->remove($r));
+ $this->assertEquals(0, count($this->multi));
+ }
+
+ public function testResetClearsState()
+ {
+ $r = new Request('GET', 'http://www.foo.com');
+ $this->multi->add($r);
+ $this->multi->reset();
+ $this->assertEquals(0, count($this->multi));
+ }
+
+ public function testSendWillSendQueuedRequestsFirst()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $events = array();
+ $client->getCurlMulti()->getEventDispatcher()->addListener(
+ CurlMultiProxy::ADD_REQUEST,
+ function ($e) use (&$events) {
+ $events[] = $e;
+ }
+ );
+ $request = $client->get();
+ $request->getEventDispatcher()->addListener('request.complete', function () use ($client) {
+ $client->get('/foo')->send();
+ });
+ $request->send();
+ $received = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals(2, count($received));
+ $this->assertEquals($this->getServer()->getUrl(), $received[0]->getUrl());
+ $this->assertEquals($this->getServer()->getUrl() . 'foo', $received[1]->getUrl());
+ $this->assertEquals(2, count($events));
+ }
+
+ public function testTrimsDownMaxHandleCount()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 307 OK\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $client->setCurlMulti(new CurlMultiProxy(self::MAX_HANDLES, self::SELECT_TIMEOUT));
+ $request = $client->get();
+ $request->send();
+ $this->assertEquals(200, $request->getResponse()->getStatusCode());
+ $handles = $this->readAttribute($client->getCurlMulti(), 'handles');
+ $this->assertEquals(2, count($handles));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiTest.php
new file mode 100644
index 0000000..1272281
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlMultiTest.php
@@ -0,0 +1,455 @@
+<?php
+
+namespace Guzzle\Tests\Http\Curl;
+
+use Guzzle\Common\Event;
+use Guzzle\Http\Exception\BadResponseException;
+use Guzzle\Http\Exception\MultiTransferException;
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\Curl\CurlMulti;
+use Guzzle\Http\Exception\CurlException;
+use Guzzle\Tests\Mock\MockMulti;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Curl\CurlMulti
+ */
+class CurlMultiTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var \Guzzle\Http\Curl\CurlMulti */
+ private $multi;
+
+ /**
+ * Prepares the environment before running a test.
+ */
+ protected function setUp()
+ {
+ parent::setUp();
+ $this->multi = new MockMulti();
+ }
+
+ public function tearDown()
+ {
+ unset($this->multi);
+ }
+
+ public function testConstructorCreateMultiHandle()
+ {
+ $this->assertInternalType('resource', $this->multi->getHandle());
+ $this->assertEquals('curl_multi', get_resource_type($this->multi->getHandle()));
+ }
+
+ public function testDestructorClosesMultiHandle()
+ {
+ $handle = $this->multi->getHandle();
+ $this->multi->__destruct();
+ $this->assertFalse(is_resource($handle));
+ }
+
+ public function testRequestsCanBeAddedAndCounted()
+ {
+ $multi = new CurlMulti();
+ $request1 = new Request('GET', 'http://www.google.com/');
+ $multi->add($request1);
+ $this->assertEquals(array($request1), $multi->all());
+ $request2 = new Request('POST', 'http://www.google.com/');
+ $multi->add($request2);
+ $this->assertEquals(array($request1, $request2), $multi->all());
+ $this->assertEquals(2, count($multi));
+ }
+
+ public function testRequestsCanBeRemoved()
+ {
+ $request1 = new Request('GET', 'http://www.google.com/');
+ $this->multi->add($request1);
+ $request2 = new Request('PUT', 'http://www.google.com/');
+ $this->multi->add($request2);
+ $this->assertEquals(array($request1, $request2), $this->multi->all());
+ $this->assertTrue($this->multi->remove($request1));
+ $this->assertFalse($this->multi->remove($request1));
+ $this->assertEquals(array($request2), $this->multi->all());
+ }
+
+ public function testsResetRemovesRequestsAndResetsState()
+ {
+ $this->multi->add(new Request('GET', 'http://www.google.com/'));
+ $this->multi->reset();
+ $this->assertEquals(array(), $this->multi->all());
+ }
+
+ public function testSendsRequestsThroughCurl()
+ {
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 204 No content\r\n" .
+ "Content-Length: 0\r\n" .
+ "Server: Jetty(6.1.3)\r\n\r\n",
+ "HTTP/1.1 200 OK\r\n" .
+ "Content-Type: text/html; charset=utf-8\r\n" .
+ "Content-Length: 4\r\n" .
+ "Server: Jetty(6.1.3)\r\n\r\n" .
+ "data"
+ ));
+
+ $request1 = new Request('GET', $this->getServer()->getUrl());
+ $request2 = new Request('GET', $this->getServer()->getUrl());
+ $this->multi->add($request1);
+ $this->multi->add($request2);
+ $this->multi->send();
+
+ $response1 = $request1->getResponse();
+ $response2 = $request2->getResponse();
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $response1);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $response2);
+
+ $this->assertTrue($response1->getBody(true) == 'data' || $response2->getBody(true) == 'data');
+ $this->assertTrue($response1->getBody(true) == '' || $response2->getBody(true) == '');
+ $this->assertTrue($response1->getStatusCode() == '204' || $response2->getStatusCode() == '204');
+ $this->assertNotEquals((string) $response1, (string) $response2);
+ }
+
+ public function testSendsThroughCurlAndAggregatesRequestExceptions()
+ {
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\n" .
+ "Content-Type: text/html; charset=utf-8\r\n" .
+ "Content-Length: 4\r\n" .
+ "Server: Jetty(6.1.3)\r\n" .
+ "\r\n" .
+ "data",
+ "HTTP/1.1 204 No content\r\n" .
+ "Content-Length: 0\r\n" .
+ "Server: Jetty(6.1.3)\r\n" .
+ "\r\n",
+ "HTTP/1.1 404 Not Found\r\n" .
+ "Content-Length: 0\r\n" .
+ "\r\n"
+ ));
+
+ $request1 = new Request('GET', $this->getServer()->getUrl());
+ $request2 = new Request('HEAD', $this->getServer()->getUrl());
+ $request3 = new Request('GET', $this->getServer()->getUrl());
+ $this->multi->add($request1);
+ $this->multi->add($request2);
+ $this->multi->add($request3);
+
+ try {
+ $this->multi->send();
+ $this->fail('MultiTransferException not thrown when aggregating request exceptions');
+ } catch (MultiTransferException $e) {
+
+ $this->assertTrue($e->containsRequest($request1));
+ $this->assertTrue($e->containsRequest($request2));
+ $this->assertTrue($e->containsRequest($request3));
+ $this->assertInstanceOf('ArrayIterator', $e->getIterator());
+ $this->assertEquals(1, count($e));
+ $exceptions = $e->getIterator();
+
+ $response1 = $request1->getResponse();
+ $response2 = $request2->getResponse();
+ $response3 = $request3->getResponse();
+
+ $this->assertNotEquals((string) $response1, (string) $response2);
+ $this->assertNotEquals((string) $response3, (string) $response1);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $response1);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $response2);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $response3);
+
+ $failed = $exceptions[0]->getResponse();
+ $this->assertEquals(404, $failed->getStatusCode());
+ $this->assertEquals(1, count($e));
+
+ // Test the IteratorAggregate functionality
+ foreach ($e as $except) {
+ $this->assertEquals($failed, $except->getResponse());
+ }
+
+ $this->assertEquals(1, count($e->getFailedRequests()));
+ $this->assertEquals(2, count($e->getSuccessfulRequests()));
+ $this->assertEquals(3, count($e->getAllRequests()));
+ }
+ }
+
+ public function testCurlErrorsAreCaught()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ try {
+ $request = RequestFactory::getInstance()->create('GET', 'http://127.0.0.1:9876/');
+ $request->setClient(new Client());
+ $request->getCurlOptions()->set(CURLOPT_FRESH_CONNECT, true);
+ $request->getCurlOptions()->set(CURLOPT_FORBID_REUSE, true);
+ $request->getCurlOptions()->set(CURLOPT_CONNECTTIMEOUT_MS, 5);
+ $request->send();
+ $this->fail('CurlException not thrown');
+ } catch (CurlException $e) {
+ $m = $e->getMessage();
+ $this->assertContains('[curl] ', $m);
+ $this->assertContains('[url] http://127.0.0.1:9876/', $m);
+ $this->assertInternalType('array', $e->getCurlInfo());
+ }
+ }
+
+ public function testRemovesQueuedRequests()
+ {
+ $request = RequestFactory::getInstance()->create('GET', 'http://127.0.0.1:9876/');
+ $r = new Response(200);
+ $request->setClient(new Client());
+ $request->setResponse($r, true);
+ $this->multi->add($request);
+ $this->multi->send();
+ $this->assertSame($r, $request->getResponse());
+ }
+
+ public function testRemovesQueuedRequestsAddedInTransit()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
+ $client = new Client($this->getServer()->getUrl());
+ $r = $client->get();
+ $r->getEventDispatcher()->addListener('request.receive.status_line', function (Event $event) use ($client) {
+ // Create a request using a queued response
+ $request = $client->get()->setResponse(new Response(200), true);
+ $request->send();
+ });
+ $r->send();
+ $this->assertEquals(1, count($this->getServer()->getReceivedRequests(false)));
+ }
+
+ public function testCatchesExceptionsBeforeSendingSingleRequest()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $multi = new CurlMulti();
+ $client->setCurlMulti($multi);
+ $request = $client->get();
+ $request->getEventDispatcher()->addListener('request.before_send', function() {
+ throw new \RuntimeException('Testing!');
+ });
+ try {
+ $request->send();
+ $this->fail('Did not throw');
+ } catch (\RuntimeException $e) {
+ // Ensure it was removed
+ $this->assertEquals(0, count($multi));
+ }
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\ExceptionCollection
+ * @expectedExceptionMessage Thrown before sending!
+ */
+ public function testCatchesExceptionsBeforeSendingMultipleRequests()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get();
+ $request->getEventDispatcher()->addListener('request.before_send', function() {
+ throw new \RuntimeException('Thrown before sending!');
+ });
+ $client->send(array($request));
+ }
+
+ public function testCatchesExceptionsWhenRemovingQueuedRequests()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $client = new Client($this->getServer()->getUrl());
+ $r = $client->get();
+ $r->getEventDispatcher()->addListener('request.sent', function() use ($client) {
+ // Create a request using a queued response
+ $client->get()->setResponse(new Response(404), true)->send();
+ });
+ try {
+ $r->send();
+ $this->fail('Did not throw');
+ } catch (BadResponseException $e) {
+ $this->assertCount(0, $client->getCurlMulti());
+ }
+ }
+
+ public function testCatchesExceptionsWhenRemovingQueuedRequestsBeforeSending()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $client = new Client($this->getServer()->getUrl());
+ $r = $client->get();
+ $r->getEventDispatcher()->addListener('request.before_send', function() use ($client) {
+ // Create a request using a queued response
+ $client->get()->setResponse(new Response(404), true)->send();
+ });
+ try {
+ $r->send();
+ $this->fail('Did not throw');
+ } catch (BadResponseException $e) {
+ $this->assertCount(0, $client->getCurlMulti());
+ }
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ * @expectedExceptionMessage test
+ */
+ public function testDoesNotCatchRandomExceptionsThrownDuringPerform()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $multi = $this->getMock('Guzzle\\Http\\Curl\\CurlMulti', array('perform'));
+ $multi->expects($this->once())
+ ->method('perform')
+ ->will($this->throwException(new \RuntimeException('test')));
+ $multi->add($client->get());
+ $multi->send();
+ }
+
+ public function testDoesNotSendRequestsDecliningToBeSent()
+ {
+ if (!defined('CURLOPT_TIMEOUT_MS')) {
+ $this->markTestSkipped('Update curl');
+ }
+
+ // Create a client that is bound to fail connecting
+ $client = new Client('http://127.0.0.1:123', array(
+ 'curl.CURLOPT_PORT' => 123,
+ 'curl.CURLOPT_CONNECTTIMEOUT_MS' => 1,
+ ));
+
+ $request = $client->get();
+ $multi = new CurlMulti();
+ $multi->add($request);
+
+ // Listen for request exceptions, and when they occur, first change the
+ // state of the request back to transferring, and then just allow it to
+ // exception out
+ $request->getEventDispatcher()->addListener('request.exception', function(Event $event) use ($multi) {
+ $retries = $event['request']->getParams()->get('retries');
+ // Allow the first failure to retry
+ if ($retries == 0) {
+ $event['request']->setState('transfer');
+ $event['request']->getParams()->set('retries', 1);
+ // Remove the request to try again
+ $multi->remove($event['request']);
+ $multi->add($event['request']);
+ }
+ });
+
+ try {
+ $multi->send();
+ $this->fail('Did not throw an exception at all!?!');
+ } catch (\Exception $e) {
+ $this->assertEquals(1, $request->getParams()->get('retries'));
+ }
+ }
+
+ public function testDoesNotThrowExceptionsWhenRequestsRecoverWithRetry()
+ {
+ $this->getServer()->flush();
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get();
+ $request->getEventDispatcher()->addListener('request.before_send', function(Event $event) {
+ $event['request']->setResponse(new Response(200));
+ });
+
+ $multi = new CurlMulti();
+ $multi->add($request);
+ $multi->send();
+ $this->assertEquals(0, count($this->getServer()->getReceivedRequests(false)));
+ }
+
+ public function testDoesNotThrowExceptionsWhenRequestsRecoverWithSuccess()
+ {
+ // Attempt a port that 99.9% is not listening
+ $client = new Client('http://127.0.0.1:123');
+ $request = $client->get();
+ // Ensure it times out quickly if needed
+ $request->getCurlOptions()->set(CURLOPT_TIMEOUT_MS, 1)->set(CURLOPT_CONNECTTIMEOUT_MS, 1);
+
+ $request->getEventDispatcher()->addListener('request.exception', function(Event $event) use (&$count) {
+ $event['request']->setResponse(new Response(200));
+ });
+
+ $multi = new CurlMulti();
+ $multi->add($request);
+ $multi->send();
+
+ // Ensure that the exception was caught, and the response was set manually
+ $this->assertEquals(200, $request->getResponse()->getStatusCode());
+ }
+
+ public function testHardResetReopensMultiHandle()
+ {
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+
+ $stream = fopen('php://temp', 'w+');
+ $client = new Client($this->getServer()->getUrl());
+ $client->getConfig()->set('curl.CURLOPT_VERBOSE', true)->set('curl.CURLOPT_STDERR', $stream);
+
+ $request = $client->get();
+ $multi = new CurlMulti();
+ $multi->add($request);
+ $multi->send();
+ $multi->reset(true);
+ $multi->add($request);
+ $multi->send();
+
+ rewind($stream);
+ $this->assertNotContains('Re-using existing connection', stream_get_contents($stream));
+ }
+
+ public function testThrowsMeaningfulExceptionsForCurlMultiErrors()
+ {
+ $multi = new CurlMulti();
+
+ // Set the state of the multi object to sending to trigger the exception
+ $reflector = new \ReflectionMethod('Guzzle\Http\Curl\CurlMulti', 'checkCurlResult');
+ $reflector->setAccessible(true);
+
+ // Successful
+ $reflector->invoke($multi, 0);
+
+ // Known error
+ try {
+ $reflector->invoke($multi, CURLM_BAD_HANDLE);
+ $this->fail('Expected an exception here');
+ } catch (CurlException $e) {
+ $this->assertContains('The passed-in handle is not a valid CURLM handle.', $e->getMessage());
+ $this->assertContains('CURLM_BAD_HANDLE', $e->getMessage());
+ $this->assertContains(strval(CURLM_BAD_HANDLE), $e->getMessage());
+ }
+
+ // Unknown error
+ try {
+ $reflector->invoke($multi, 255);
+ $this->fail('Expected an exception here');
+ } catch (CurlException $e) {
+ $this->assertEquals('Unexpected cURL error: 255', $e->getMessage());
+ }
+ }
+
+ public function testRequestBeforeSendIncludesContentLengthHeaderIfEmptyBody()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request = new Request('PUT', $this->getServer()->getUrl());
+ $that = $this;
+ $request->getEventDispatcher()->addListener('request.before_send', function ($event) use ($that) {
+ $that->assertEquals(0, $event['request']->getHeader('Content-Length'));
+ });
+ $this->multi->add($request);
+ $this->multi->send();
+ }
+
+ public function testRemovesConflictingTransferEncodingHeader()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put('/', null, fopen($this->getServer()->getUrl(), 'r'));
+ $request->setHeader('Content-Length', 4);
+ $request->send();
+ $received = $this->getServer()->getReceivedRequests(true);
+ $this->assertFalse($received[1]->hasHeader('Transfer-Encoding'));
+ $this->assertEquals(4, (string) $received[1]->getHeader('Content-Length'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlVersionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlVersionTest.php
new file mode 100644
index 0000000..c7b5ee6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/CurlVersionTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Guzzle\Tests\Http\Curl;
+
+use Guzzle\Http\Curl\CurlVersion;
+
+/**
+ * @covers Guzzle\Http\Curl\CurlVersion
+ */
+class CurlVersionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testCachesCurlInfo()
+ {
+ $info = curl_version();
+ $instance = CurlVersion::getInstance();
+
+ // Clear out the info cache
+ $refObject = new \ReflectionObject($instance);
+ $refProperty = $refObject->getProperty('version');
+ $refProperty->setAccessible(true);
+ $refProperty->setValue($instance, array());
+
+ $this->assertEquals($info, $instance->getAll());
+ $this->assertEquals($info, $instance->getAll());
+
+ $this->assertEquals($info['version'], $instance->get('version'));
+ $this->assertFalse($instance->get('foo'));
+ }
+
+ public function testIsSingleton()
+ {
+ $refObject = new \ReflectionClass('Guzzle\Http\Curl\CurlVersion');
+ $refProperty = $refObject->getProperty('instance');
+ $refProperty->setAccessible(true);
+ $refProperty->setValue(null, null);
+
+ $this->assertInstanceOf('Guzzle\Http\Curl\CurlVersion', CurlVersion::getInstance());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/RequestMediatorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/RequestMediatorTest.php
new file mode 100644
index 0000000..c69e0c9
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Curl/RequestMediatorTest.php
@@ -0,0 +1,67 @@
+<?php
+
+namespace Guzzle\Tests\Http\Curl;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Curl\RequestMediator;
+
+/**
+ * @covers Guzzle\Http\Curl\RequestMediator
+ */
+class RequestMediatorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public $events = array();
+
+ public function event($event)
+ {
+ $this->events[] = $event;
+ }
+
+ public function testEmitsEvents()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://www.example.com');
+ $request->setBody('foo');
+ $request->setResponse(new Response(200));
+
+ // Ensure that IO events are emitted
+ $request->getCurlOptions()->set('emit_io', true);
+
+ // Attach listeners for each event type
+ $request->getEventDispatcher()->addListener('curl.callback.progress', array($this, 'event'));
+ $request->getEventDispatcher()->addListener('curl.callback.read', array($this, 'event'));
+ $request->getEventDispatcher()->addListener('curl.callback.write', array($this, 'event'));
+
+ $mediator = new RequestMediator($request, true);
+
+ $mediator->progress('a', 'b', 'c', 'd');
+ $this->assertEquals(1, count($this->events));
+ $this->assertEquals('curl.callback.progress', $this->events[0]->getName());
+
+ $this->assertEquals(3, $mediator->writeResponseBody('foo', 'bar'));
+ $this->assertEquals(2, count($this->events));
+ $this->assertEquals('curl.callback.write', $this->events[1]->getName());
+ $this->assertEquals('bar', $this->events[1]['write']);
+ $this->assertSame($request, $this->events[1]['request']);
+
+ $this->assertEquals('foo', $mediator->readRequestBody('a', 'b', 3));
+ $this->assertEquals(3, count($this->events));
+ $this->assertEquals('curl.callback.read', $this->events[2]->getName());
+ $this->assertEquals('foo', $this->events[2]['read']);
+ $this->assertSame($request, $this->events[2]['request']);
+ }
+
+ public function testDoesNotUseRequestResponseBodyWhenNotCustom()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 307 Foo\r\nLocation: /foo\r\nContent-Length: 2\r\n\r\nHI",
+ "HTTP/1.1 301 Foo\r\nLocation: /foo\r\nContent-Length: 2\r\n\r\nFI",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest",
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $response = $client->get()->send();
+ $this->assertEquals('test', $response->getBody(true));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/EntityBodyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/EntityBodyTest.php
new file mode 100644
index 0000000..124a44d
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/EntityBodyTest.php
@@ -0,0 +1,182 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\QueryString;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\EntityBody
+ */
+class EntityBodyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testFactoryThrowsException()
+ {
+ $body = EntityBody::factory(false);
+ }
+
+ public function testFactory()
+ {
+ $body = EntityBody::factory('data');
+ $this->assertEquals('data', (string) $body);
+ $this->assertEquals(4, $body->getContentLength());
+ $this->assertEquals('PHP', $body->getWrapper());
+ $this->assertEquals('TEMP', $body->getStreamType());
+
+ $handle = fopen(__DIR__ . '/../../../../phpunit.xml.dist', 'r');
+ if (!$handle) {
+ $this->fail('Could not open test file');
+ }
+ $body = EntityBody::factory($handle);
+ $this->assertEquals(__DIR__ . '/../../../../phpunit.xml.dist', $body->getUri());
+ $this->assertTrue($body->isLocal());
+ $this->assertEquals(__DIR__ . '/../../../../phpunit.xml.dist', $body->getUri());
+ $this->assertEquals(filesize(__DIR__ . '/../../../../phpunit.xml.dist'), $body->getContentLength());
+
+ // make sure that a body will return as the same object
+ $this->assertTrue($body === EntityBody::factory($body));
+ }
+
+ public function testFactoryCreatesTempStreamByDefault()
+ {
+ $body = EntityBody::factory('');
+ $this->assertEquals('PHP', $body->getWrapper());
+ $this->assertEquals('TEMP', $body->getStreamType());
+ $body = EntityBody::factory();
+ $this->assertEquals('PHP', $body->getWrapper());
+ $this->assertEquals('TEMP', $body->getStreamType());
+ }
+
+ public function testFactoryCanCreateFromObject()
+ {
+ $body = EntityBody::factory(new QueryString(array('foo' => 'bar')));
+ $this->assertEquals('foo=bar', (string) $body);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testFactoryEnsuresObjectsHaveToStringMethod()
+ {
+ EntityBody::factory(new \stdClass('a'));
+ }
+
+ public function testHandlesCompression()
+ {
+ $body = EntityBody::factory('testing 123...testing 123');
+ $this->assertFalse($body->getContentEncoding(), '-> getContentEncoding() must initially return FALSE');
+ $size = $body->getContentLength();
+ $body->compress();
+ $this->assertEquals('gzip', $body->getContentEncoding(), '-> getContentEncoding() must return the correct encoding after compressing');
+ $this->assertEquals(gzdeflate('testing 123...testing 123'), (string) $body);
+ $this->assertTrue($body->getContentLength() < $size);
+ $this->assertTrue($body->uncompress());
+ $this->assertEquals('testing 123...testing 123', (string) $body);
+ $this->assertFalse($body->getContentEncoding(), '-> getContentEncoding() must reset to FALSE');
+
+ if (in_array('bzip2.*', stream_get_filters())) {
+ $this->assertTrue($body->compress('bzip2.compress'));
+ $this->assertEquals('compress', $body->getContentEncoding(), '-> compress() must set \'compress\' as the Content-Encoding');
+ }
+
+ $this->assertFalse($body->compress('non-existent'), '-> compress() must return false when a non-existent stream filter is used');
+
+ // Release the body
+ unset($body);
+
+ // Use gzip compression on the initial content. This will include a
+ // gzip header which will need to be stripped when deflating the stream
+ $body = EntityBody::factory(gzencode('test'));
+ $this->assertSame($body, $body->setStreamFilterContentEncoding('zlib.deflate'));
+ $this->assertTrue($body->uncompress('zlib.inflate'));
+ $this->assertEquals('test', (string) $body);
+ unset($body);
+
+ // Test using a very long string
+ $largeString = '';
+ for ($i = 0; $i < 25000; $i++) {
+ $largeString .= chr(rand(33, 126));
+ }
+ $body = EntityBody::factory($largeString);
+ $this->assertEquals($largeString, (string) $body);
+ $this->assertTrue($body->compress());
+ $this->assertNotEquals($largeString, (string) $body);
+ $compressed = (string) $body;
+ $this->assertTrue($body->uncompress());
+ $this->assertEquals($largeString, (string) $body);
+ $this->assertEquals($compressed, gzdeflate($largeString));
+
+ $body = EntityBody::factory(fopen(__DIR__ . '/../TestData/compress_test', 'w'));
+ $this->assertFalse($body->compress());
+ unset($body);
+
+ unlink(__DIR__ . '/../TestData/compress_test');
+ }
+
+ public function testDeterminesContentType()
+ {
+ // Test using a string/temp stream
+ $body = EntityBody::factory('testing 123...testing 123');
+ $this->assertNull($body->getContentType());
+
+ // Use a local file
+ $body = EntityBody::factory(fopen(__FILE__, 'r'));
+ $this->assertContains('text/x-', $body->getContentType());
+ }
+
+ public function testCreatesMd5Checksum()
+ {
+ $body = EntityBody::factory('testing 123...testing 123');
+ $this->assertEquals(md5('testing 123...testing 123'), $body->getContentMd5());
+
+ $server = $this->getServer()->enqueue(
+ "HTTP/1.1 200 OK" . "\r\n" .
+ "Content-Length: 3" . "\r\n\r\n" .
+ "abc"
+ );
+
+ $body = EntityBody::factory(fopen($this->getServer()->getUrl(), 'r'));
+ $this->assertFalse($body->getContentMd5());
+ }
+
+ public function testSeeksToOriginalPosAfterMd5()
+ {
+ $body = EntityBody::factory('testing 123');
+ $body->seek(4);
+ $this->assertEquals(md5('testing 123'), $body->getContentMd5());
+ $this->assertEquals(4, $body->ftell());
+ $this->assertEquals('ing 123', $body->read(1000));
+ }
+
+ public function testGetTypeFormBodyFactoring()
+ {
+ $body = EntityBody::factory(array('key1' => 'val1', 'key2' => 'val2'));
+ $this->assertEquals('key1=val1&key2=val2', (string) $body);
+ }
+
+ public function testAllowsCustomRewind()
+ {
+ $body = EntityBody::factory('foo');
+ $rewound = false;
+ $body->setRewindFunction(function ($body) use (&$rewound) {
+ $rewound = true;
+ return $body->seek(0);
+ });
+ $body->seek(2);
+ $this->assertTrue($body->rewind());
+ $this->assertTrue($rewound);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testCustomRewindFunctionMustBeCallable()
+ {
+ $body = EntityBody::factory();
+ $body->setRewindFunction('foo');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/CurlExceptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/CurlExceptionTest.php
new file mode 100644
index 0000000..df3e4b7
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/CurlExceptionTest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Guzzle\Tests\Http\Exception;
+
+use Guzzle\Http\Exception\CurlException;
+use Guzzle\Http\Curl\CurlHandle;
+
+/**
+ * @covers Guzzle\Http\Exception\CurlException
+ */
+class CurlExceptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testStoresCurlError()
+ {
+ $e = new CurlException();
+ $this->assertNull($e->getError());
+ $this->assertNull($e->getErrorNo());
+ $this->assertSame($e, $e->setError('test', 12));
+ $this->assertEquals('test', $e->getError());
+ $this->assertEquals(12, $e->getErrorNo());
+
+ $handle = new CurlHandle(curl_init(), array());
+ $e->setCurlHandle($handle);
+ $this->assertSame($handle, $e->getCurlHandle());
+ $handle->close();
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/ExceptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/ExceptionTest.php
new file mode 100644
index 0000000..12cfd36
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/ExceptionTest.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Guzzle\Tests\Http\Exception;
+
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Exception\RequestException;
+use Guzzle\Http\Exception\BadResponseException;
+
+class ExceptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @covers Guzzle\Http\Exception\RequestException
+ */
+ public function testRequestException()
+ {
+ $e = new RequestException('Message');
+ $request = new Request('GET', 'http://www.guzzle-project.com/');
+ $e->setRequest($request);
+ $this->assertEquals($request, $e->getRequest());
+ }
+
+ /**
+ * @covers Guzzle\Http\Exception\BadResponseException
+ */
+ public function testBadResponseException()
+ {
+ $e = new BadResponseException('Message');
+ $response = new Response(200);
+ $e->setResponse($response);
+ $this->assertEquals($response, $e->getResponse());
+ }
+
+ /**
+ * @covers Guzzle\Http\Exception\BadResponseException::factory
+ */
+ public function testCreatesGenericErrorExceptionOnError()
+ {
+ $request = new Request('GET', 'http://www.example.com');
+ $response = new Response(307);
+ $e = BadResponseException::factory($request, $response);
+ $this->assertInstanceOf('Guzzle\Http\Exception\BadResponseException', $e);
+ }
+
+ /**
+ * @covers Guzzle\Http\Exception\BadResponseException::factory
+ */
+ public function testCreatesClientErrorExceptionOnClientError()
+ {
+ $request = new Request('GET', 'http://www.example.com');
+ $response = new Response(404);
+ $e = BadResponseException::factory($request, $response);
+ $this->assertInstanceOf('Guzzle\Http\Exception\ClientErrorResponseException', $e);
+ }
+
+ /**
+ * @covers Guzzle\Http\Exception\BadResponseException::factory
+ */
+ public function testCreatesServerErrorExceptionOnServerError()
+ {
+ $request = new Request('GET', 'http://www.example.com');
+ $response = new Response(503);
+ $e = BadResponseException::factory($request, $response);
+ $this->assertInstanceOf('Guzzle\Http\Exception\ServerErrorResponseException', $e);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/MultiTransferExceptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/MultiTransferExceptionTest.php
new file mode 100644
index 0000000..fa4ec26
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Exception/MultiTransferExceptionTest.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Guzzle\Tests\Http\Exception;
+
+use Guzzle\Http\Exception\MultiTransferException;
+use Guzzle\Http\Curl\CurlHandle;
+use Guzzle\Http\Message\Request;
+
+/**
+ * @covers Guzzle\Http\Exception\MultiTransferException
+ */
+class MultiTransferExceptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testHasRequests()
+ {
+ $r1 = new Request('GET', 'http://www.foo.com');
+ $r2 = new Request('GET', 'http://www.foo.com');
+ $e = new MultiTransferException();
+ $e->addSuccessfulRequest($r1);
+ $e->addFailedRequest($r2);
+ $this->assertEquals(array($r1), $e->getSuccessfulRequests());
+ $this->assertEquals(array($r2), $e->getSuccessfulRequests());
+ $this->assertEquals(array($r1, $r2), $e->getAllRequests());
+ $this->assertTrue($e->containsRequest($r1));
+ $this->assertTrue($e->containsRequest($r2));
+ $this->assertFalse($e->containsRequest(new Request('POST', '/foo')));
+ }
+
+ public function testCanSetRequests()
+ {
+ $s = array($r1 = new Request('GET', 'http://www.foo.com'));
+ $f = array($r2 = new Request('GET', 'http://www.foo.com'));
+ $e = new MultiTransferException();
+ $e->setSuccessfulRequests($s);
+ $e->setFailedRequests($f);
+ $this->assertEquals(array($r1), $e->getSuccessfulRequests());
+ $this->assertEquals(array($r2), $e->getSuccessfulRequests());
+ }
+
+ public function testAssociatesExceptionsWithRequests()
+ {
+ $r1 = new Request('GET', 'http://www.foo.com');
+ $re1 = new \Exception('foo');
+ $re2 = new \Exception('bar');
+ $e = new MultiTransferException();
+ $e->add($re2);
+ $e->addFailedRequestWithException($r1, $re1);
+ $this->assertSame($re1, $e->getExceptionForFailedRequest($r1));
+ $this->assertNull($e->getExceptionForFailedRequest(new Request('POST', '/foo')));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/IoEmittingEntityBodyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/IoEmittingEntityBodyTest.php
new file mode 100644
index 0000000..cd6355f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/IoEmittingEntityBodyTest.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\IoEmittingEntityBody;
+
+/**
+ * @covers Guzzle\Http\IoEmittingEntityBody
+ */
+class IoEmittingEntityBodyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $body;
+ protected $decorated;
+
+ public function setUp()
+ {
+ $this->decorated = EntityBody::factory('hello');
+ $this->body = new IoEmittingEntityBody($this->decorated);
+ }
+
+ public function testEmitsReadEvents()
+ {
+ $e = null;
+ $this->body->getEventDispatcher()->addListener('body.read', function ($event) use (&$e) {
+ $e = $event;
+ });
+ $this->assertEquals('hel', $this->body->read(3));
+ $this->assertEquals('hel', $e['read']);
+ $this->assertEquals(3, $e['length']);
+ $this->assertSame($this->body, $e['body']);
+ }
+
+ public function testEmitsWriteEvents()
+ {
+ $e = null;
+ $this->body->getEventDispatcher()->addListener('body.write', function ($event) use (&$e) {
+ $e = $event;
+ });
+ $this->body->seek(0, SEEK_END);
+ $this->assertEquals(5, $this->body->write('there'));
+ $this->assertEquals('there', $e['write']);
+ $this->assertEquals(5, $e['result']);
+ $this->assertSame($this->body, $e['body']);
+ $this->assertEquals('hellothere', (string) $this->body);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/AbstractMessageTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/AbstractMessageTest.php
new file mode 100644
index 0000000..9447d8c
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/AbstractMessageTest.php
@@ -0,0 +1,136 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message;
+
+use Guzzle\Http\Message\Header;
+use Guzzle\Http\Message\Request;
+use Guzzle\Common\Collection;
+
+/**
+ * @covers Guzzle\Http\Message\AbstractMessage
+ */
+class AbstractMessageTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var Request Request object */
+ private $request;
+
+ /** @var AbstractMessage */
+ private $mock;
+
+ public function setUp()
+ {
+ parent::setUp();
+ $this->mock = $this->getMockForAbstractClass('Guzzle\Http\Message\AbstractMessage');
+ }
+
+ public function tearDown()
+ {
+ $this->mock = $this->request = null;
+ }
+
+ public function testGetParams()
+ {
+ $request = new Request('GET', 'http://example.com');
+ $this->assertInstanceOf('Guzzle\\Common\\Collection', $request->getParams());
+ }
+
+ public function testAddHeaders()
+ {
+ $this->mock->setHeader('A', 'B');
+
+ $this->assertEquals($this->mock, $this->mock->addHeaders(array(
+ 'X-Data' => '123'
+ )));
+
+ $this->assertTrue($this->mock->hasHeader('X-Data') !== false);
+ $this->assertTrue($this->mock->hasHeader('A') !== false);
+ }
+
+ public function testAllowsHeaderToSetAsHeader()
+ {
+ $h = new Header('A', 'B');
+ $this->mock->setHeader('A', $h);
+ $this->assertSame($h, $this->mock->getHeader('A'));
+ }
+
+ public function testGetHeader()
+ {
+ $this->mock->setHeader('Test', '123');
+ $this->assertEquals('123', $this->mock->getHeader('Test'));
+ }
+
+ public function testGetHeaders()
+ {
+ $this->assertSame($this->mock, $this->mock->setHeaders(array('a' => 'b', 'c' => 'd')));
+ $h = $this->mock->getHeaders();
+ $this->assertArrayHasKey('a', $h->toArray());
+ $this->assertArrayHasKey('c', $h->toArray());
+ $this->assertInstanceOf('Guzzle\Http\Message\Header\HeaderInterface', $h->get('a'));
+ $this->assertInstanceOf('Guzzle\Http\Message\Header\HeaderInterface', $h->get('c'));
+ }
+
+ public function testGetHeaderLinesUsesGlue()
+ {
+ $this->mock->setHeaders(array('a' => 'b', 'c' => 'd'));
+ $this->mock->addHeader('a', 'e');
+ $this->mock->getHeader('a')->setGlue('!');
+ $this->assertEquals(array(
+ 'a: b! e',
+ 'c: d'
+ ), $this->mock->getHeaderLines());
+ }
+
+ public function testHasHeader()
+ {
+ $this->assertFalse($this->mock->hasHeader('Foo'));
+ $this->mock->setHeader('Foo', 'Bar');
+ $this->assertEquals(true, $this->mock->hasHeader('Foo'));
+ $this->mock->setHeader('foo', 'yoo');
+ $this->assertEquals(true, $this->mock->hasHeader('Foo'));
+ $this->assertEquals(true, $this->mock->hasHeader('foo'));
+ $this->assertEquals(false, $this->mock->hasHeader('bar'));
+ }
+
+ public function testRemoveHeader()
+ {
+ $this->mock->setHeader('Foo', 'Bar');
+ $this->assertEquals(true, $this->mock->hasHeader('Foo'));
+ $this->mock->removeHeader('Foo');
+ $this->assertFalse($this->mock->hasHeader('Foo'));
+ }
+
+ public function testReturnsNullWhenHeaderIsNotFound()
+ {
+ $this->assertNull($this->mock->getHeader('foo'));
+ }
+
+ public function testAddingHeadersPreservesOriginalHeaderCase()
+ {
+ $this->mock->addHeaders(array(
+ 'test' => '123',
+ 'Test' => 'abc'
+ ));
+ $this->mock->addHeader('test', '456');
+ $this->mock->addHeader('test', '789');
+
+ $header = $this->mock->getHeader('test');
+ $this->assertContains('123', $header->toArray());
+ $this->assertContains('456', $header->toArray());
+ $this->assertContains('789', $header->toArray());
+ $this->assertContains('abc', $header->toArray());
+ }
+
+ public function testCanStoreEmptyHeaders()
+ {
+ $this->mock->setHeader('Content-Length', 0);
+ $this->assertTrue($this->mock->hasHeader('Content-Length'));
+ $this->assertEquals(0, (string) $this->mock->getHeader('Content-Length'));
+ }
+
+ public function testCanSetCustomHeaderFactory()
+ {
+ $f = new Header\HeaderFactory();
+ $this->mock->setHeaderFactory($f);
+ $this->assertSame($f, $this->readAttribute($this->mock, 'headerFactory'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/EntityEnclosingRequestTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/EntityEnclosingRequestTest.php
new file mode 100644
index 0000000..191b022
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/EntityEnclosingRequestTest.php
@@ -0,0 +1,434 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\RedirectPlugin;
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Http\Message\PostFile;
+use Guzzle\Http\QueryString;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Message\EntityEnclosingRequest
+ */
+class EntityEnclosingRequestTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $client;
+
+ public function setUp()
+ {
+ $this->client = new Client();
+ }
+
+ public function tearDown()
+ {
+ $this->client = null;
+ }
+
+ public function testConstructorConfiguresRequest()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com', array(
+ 'X-Test' => '123'
+ ));
+ $request->setBody('Test');
+ $this->assertEquals('123', $request->getHeader('X-Test'));
+ $this->assertNull($request->getHeader('Expect'));
+ }
+
+ public function testCanSetBodyWithoutOverridingContentType()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com', array('Content-Type' => 'foooooo'));
+ $request->setBody('{"a":"b"}');
+ $this->assertEquals('foooooo', $request->getHeader('Content-Type'));
+ }
+
+ public function testRequestIncludesBodyInMessage()
+ {
+
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.guzzle-project.com/', null, 'data');
+ $this->assertEquals("PUT / HTTP/1.1\r\n"
+ . "Host: www.guzzle-project.com\r\n"
+ . "Content-Length: 4\r\n\r\n"
+ . "data", (string) $request);
+ }
+
+ public function testRequestIncludesPostBodyInMessageOnlyWhenNoPostFiles()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/', null, array(
+ 'foo' => 'bar'
+ ));
+ $this->assertEquals("POST / HTTP/1.1\r\n"
+ . "Host: www.guzzle-project.com\r\n"
+ . "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n\r\n"
+ . "foo=bar", (string) $request);
+
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/', null, array(
+ 'foo' => '@' . __FILE__
+ ));
+ $this->assertEquals("POST / HTTP/1.1\r\n"
+ . "Host: www.guzzle-project.com\r\n"
+ . "Content-Type: multipart/form-data\r\n"
+ . "Expect: 100-Continue\r\n\r\n", (string) $request);
+ }
+
+ public function testAddsPostFieldsAndSetsContentLength()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/', null, array(
+ 'data' => '123'
+ ));
+ $this->assertEquals("POST / HTTP/1.1\r\n"
+ . "Host: www.guzzle-project.com\r\n"
+ . "Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n\r\n"
+ . "data=123", (string) $request);
+ }
+
+ public function testAddsPostFilesAndSetsContentType()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.test.com/')
+ ->addPostFiles(array(
+ 'file' => __FILE__
+ ))->addPostFields(array(
+ 'a' => 'b'
+ ));
+ $message = (string) $request;
+ $this->assertEquals('multipart/form-data', $request->getHeader('Content-Type'));
+ $this->assertEquals('100-Continue', $request->getHeader('Expect'));
+ }
+
+ public function testRequestBodyContainsPostFiles()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.test.com/');
+ $request->addPostFields(array(
+ 'test' => '123'
+ ));
+ $this->assertContains("\r\n\r\ntest=123", (string) $request);
+ }
+
+ public function testRequestBodyAddsContentLength()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.test.com/');
+ $request->setBody(EntityBody::factory('test'));
+ $this->assertEquals(4, (string) $request->getHeader('Content-Length'));
+ $this->assertFalse($request->hasHeader('Transfer-Encoding'));
+ }
+
+ public function testRequestBodyDoesNotUseContentLengthWhenChunked()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.test.com/', array(
+ 'Transfer-Encoding' => 'chunked'
+ ), 'test');
+ $this->assertNull($request->getHeader('Content-Length'));
+ $this->assertTrue($request->hasHeader('Transfer-Encoding'));
+ }
+
+ public function testRequestHasMutableBody()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.guzzle-project.com/', null, 'data');
+ $body = $request->getBody();
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $body);
+ $this->assertSame($body, $request->getBody());
+
+ $newBody = EntityBody::factory('foobar');
+ $request->setBody($newBody);
+ $this->assertEquals('foobar', (string) $request->getBody());
+ $this->assertSame($newBody, $request->getBody());
+ }
+
+ public function testSetPostFields()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/');
+ $this->assertInstanceOf('Guzzle\\Http\\QueryString', $request->getPostFields());
+
+ $fields = new QueryString(array(
+ 'a' => 'b'
+ ));
+ $request->addPostFields($fields);
+ $this->assertEquals($fields->getAll(), $request->getPostFields()->getAll());
+ $this->assertEquals(array(), $request->getPostFiles());
+ }
+
+ public function testSetPostFiles()
+ {
+ $request = RequestFactory::getInstance()->create('POST', $this->getServer()->getUrl())
+ ->setClient(new Client())
+ ->addPostFiles(array(__FILE__))
+ ->addPostFields(array(
+ 'test' => 'abc'
+ ));
+
+ $request->getCurlOptions()->set('debug', true);
+
+ $this->assertEquals(array(
+ 'test' => 'abc'
+ ), $request->getPostFields()->getAll());
+
+ $files = $request->getPostFiles();
+ $post = $files['file'][0];
+ $this->assertEquals('file', $post->getFieldName());
+ $this->assertContains('text/x-', $post->getContentType());
+ $this->assertEquals(__FILE__, $post->getFilename());
+
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request->send();
+
+ $this->assertNotNull($request->getHeader('Content-Length'));
+ $this->assertContains('multipart/form-data; boundary=', (string) $request->getHeader('Content-Type'), '-> cURL must add the boundary');
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testSetPostFilesThrowsExceptionWhenFileIsNotFound()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/')
+ ->addPostFiles(array(
+ 'file' => 'filenotfound.ini'
+ ));
+ }
+
+ /**
+ * @expectedException Guzzle\Http\Exception\RequestException
+ */
+ public function testThrowsExceptionWhenNonStringsAreAddedToPost()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/')
+ ->addPostFile('foo', new \stdClass());
+ }
+
+ public function testAllowsContentTypeInPostUploads()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/')
+ ->addPostFile('foo', __FILE__, 'text/plain');
+
+ $this->assertEquals(array(
+ new PostFile('foo', __FILE__, 'text/plain')
+ ), $request->getPostFile('foo'));
+ }
+
+ public function testGuessesContentTypeOfPostUpload()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/')
+ ->addPostFile('foo', __FILE__);
+ $file = $request->getPostFile('foo');
+ $this->assertContains('text/x-', $file[0]->getContentType());
+ }
+
+ public function testAllowsContentDispositionFieldsInPostUploadsWhenSettingInBulk()
+ {
+ $postFile = new PostFile('foo', __FILE__, 'text/x-php');
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/')
+ ->addPostFiles(array('foo' => $postFile));
+
+ $this->assertEquals(array($postFile), $request->getPostFile('foo'));
+ }
+
+ public function testPostRequestsUseApplicationXwwwForUrlEncodedForArrays()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/');
+ $request->setPostField('a', 'b');
+ $this->assertContains("\r\n\r\na=b", (string) $request);
+ $this->assertEquals('application/x-www-form-urlencoded; charset=utf-8', $request->getHeader('Content-Type'));
+ }
+
+ public function testProcessMethodAddsContentType()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/');
+ $request->setPostField('a', 'b');
+ $this->assertEquals('application/x-www-form-urlencoded; charset=utf-8', $request->getHeader('Content-Type'));
+ }
+
+ public function testPostRequestsUseMultipartFormDataWithFiles()
+ {
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.guzzle-project.com/');
+ $request->addPostFiles(array('file' => __FILE__));
+ $this->assertEquals('multipart/form-data', $request->getHeader('Content-Type'));
+ }
+
+ public function testCanSendMultipleRequestsUsingASingleRequestObject()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 201 Created\r\nContent-Length: 0\r\n\r\n",
+ ));
+
+ // Send the first request
+ $request = RequestFactory::getInstance()->create('PUT', $this->getServer()->getUrl())
+ ->setBody('test')
+ ->setClient(new Client());
+ $request->send();
+ $this->assertEquals(200, $request->getResponse()->getStatusCode());
+
+ // Send the second request
+ $request->setBody('abcdefg', 'application/json', false);
+ $request->send();
+ $this->assertEquals(201, $request->getResponse()->getStatusCode());
+
+ // Ensure that the same request was sent twice with different bodies
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals(2, count($requests));
+ $this->assertEquals(4, (string) $requests[0]->getHeader('Content-Length'));
+ $this->assertEquals(7, (string) $requests[1]->getHeader('Content-Length'));
+ }
+
+ public function testRemovingPostFieldRebuildsPostFields()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com');
+ $request->setPostField('test', 'value');
+ $request->removePostField('test');
+ $this->assertNull($request->getPostField('test'));
+ }
+
+ public function testUsesChunkedTransferWhenBodyLengthCannotBeDetermined()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com/');
+ $request->setBody(fopen($this->getServer()->getUrl(), 'r'));
+ $this->assertEquals('chunked', $request->getHeader('Transfer-Encoding'));
+ $this->assertFalse($request->hasHeader('Content-Length'));
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\RequestException
+ */
+ public function testThrowsExceptionWhenContentLengthCannotBeDeterminedAndUsingHttp1()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com/');
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request->setProtocolVersion('1.0');
+ $request->setBody(fopen($this->getServer()->getUrl(), 'r'));
+ }
+
+ public function testAllowsNestedPostData()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->addPostFields(array(
+ 'a' => array('b', 'c')
+ ));
+ $this->assertEquals(array(
+ 'a' => array('b', 'c')
+ ), $request->getPostFields()->getAll());
+ }
+
+ public function testAllowsEmptyFields()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->addPostFields(array(
+ 'a' => ''
+ ));
+ $this->assertEquals(array(
+ 'a' => ''
+ ), $request->getPostFields()->getAll());
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\RequestException
+ */
+ public function testFailsOnInvalidFiles()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->addPostFiles(array(
+ 'a' => new \stdClass()
+ ));
+ }
+
+ public function testHandlesEmptyStrings()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->addPostFields(array(
+ 'a' => '',
+ 'b' => null,
+ 'c' => 'Foo'
+ ));
+ $this->assertEquals(array(
+ 'a' => '',
+ 'b' => null,
+ 'c' => 'Foo'
+ ), $request->getPostFields()->getAll());
+ }
+
+ public function testHoldsPostFiles()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->addPostFile('foo', __FILE__);
+ $request->addPostFile(new PostFile('foo', __FILE__));
+
+ $this->assertArrayHasKey('foo', $request->getPostFiles());
+ $foo = $request->getPostFile('foo');
+ $this->assertEquals(2, count($foo));
+ $this->assertEquals(__FILE__, $foo[0]->getFilename());
+ $this->assertEquals(__FILE__, $foo[1]->getFilename());
+
+ $request->removePostFile('foo');
+ $this->assertEquals(array(), $request->getPostFiles());
+ }
+
+ public function testAllowsAtPrefixWhenAddingPostFiles()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->addPostFiles(array(
+ 'foo' => '@' . __FILE__
+ ));
+ $foo = $request->getPostFile('foo');
+ $this->assertEquals(__FILE__, $foo[0]->getFilename());
+ }
+
+ public function testSetStateToTransferWithEmptyBodySetsContentLengthToZero()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://test.com/');
+ $request->setState($request::STATE_TRANSFER);
+ $this->assertEquals('0', (string) $request->getHeader('Content-Length'));
+ }
+
+ public function testSettingExpectHeaderCutoffChangesRequest()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com/');
+ $request->setHeader('Expect', '100-Continue');
+ $request->setExpectHeaderCutoff(false);
+ $this->assertNull($request->getHeader('Expect'));
+ // There is not body, so remove the expect header
+ $request->setHeader('Expect', '100-Continue');
+ $request->setExpectHeaderCutoff(10);
+ $this->assertNull($request->getHeader('Expect'));
+ // The size is less than the cutoff
+ $request->setBody('foo');
+ $this->assertNull($request->getHeader('Expect'));
+ // The size is greater than the cutoff
+ $request->setBody('foobazbarbamboo');
+ $this->assertNotNull($request->getHeader('Expect'));
+ }
+
+ public function testStrictRedirectsCanBeSpecifiedOnEntityEnclosingRequests()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com/');
+ $request->configureRedirects(true);
+ $this->assertTrue($request->getParams()->get(RedirectPlugin::STRICT_REDIRECTS));
+ }
+
+ public function testCanDisableRedirects()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com/');
+ $request->configureRedirects(false, false);
+ $this->assertTrue($request->getParams()->get(RedirectPlugin::DISABLE));
+ }
+
+ public function testSetsContentTypeWhenSettingBodyByGuessingFromEntityBody()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com/foo');
+ $request->setBody(EntityBody::factory(fopen(__FILE__, 'r')));
+ $this->assertEquals('text/x-php', (string) $request->getHeader('Content-Type'));
+ }
+
+ public function testDoesNotCloneBody()
+ {
+ $request = new EntityEnclosingRequest('PUT', 'http://test.com/foo');
+ $request->setBody('test');
+ $newRequest = clone $request;
+ $newRequest->setBody('foo');
+ $this->assertInternalType('string', (string) $request->getBody());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/HeaderFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/HeaderFactoryTest.php
new file mode 100644
index 0000000..62ca555
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/HeaderFactoryTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message\Header;
+
+use Guzzle\Http\Message\Header\HeaderFactory;
+
+/**
+ * @covers Guzzle\Http\Message\Header\HeaderFactory
+ */
+class HeaderFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testCreatesBasicHeaders()
+ {
+ $f = new HeaderFactory();
+ $h = $f->createHeader('Foo', 'Bar');
+ $this->assertInstanceOf('Guzzle\Http\Message\Header', $h);
+ $this->assertEquals('Foo', $h->getName());
+ $this->assertEquals('Bar', (string) $h);
+ }
+
+ public function testCreatesSpecificHeaders()
+ {
+ $f = new HeaderFactory();
+ $h = $f->createHeader('Link', '<http>; rel="test"');
+ $this->assertInstanceOf('Guzzle\Http\Message\Header\Link', $h);
+ $this->assertEquals('Link', $h->getName());
+ $this->assertEquals('<http>; rel="test"', (string) $h);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/LinkTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/LinkTest.php
new file mode 100644
index 0000000..c834d10
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/Header/LinkTest.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message\Header;
+
+use Guzzle\Http\Message\Header\Link;
+use Guzzle\Tests\GuzzleTestCase;
+
+class LinkTest extends GuzzleTestCase
+{
+ public function testParsesLinks()
+ {
+ $link = new Link('Link', '<http:/.../front.jpeg>; rel=front; type="image/jpeg", <http://.../back.jpeg>; rel=back; type="image/jpeg", <http://.../side.jpeg?test=1>; rel=side; type="image/jpeg"');
+ $links = $link->getLinks();
+ $this->assertEquals(array(
+ array(
+ 'rel' => 'front',
+ 'type' => 'image/jpeg',
+ 'url' => 'http:/.../front.jpeg',
+ ),
+ array(
+ 'rel' => 'back',
+ 'type' => 'image/jpeg',
+ 'url' => 'http://.../back.jpeg',
+ ),
+ array(
+ 'rel' => 'side',
+ 'type' => 'image/jpeg',
+ 'url' => 'http://.../side.jpeg?test=1'
+ )
+ ), $links);
+
+ $this->assertEquals(array(
+ 'rel' => 'back',
+ 'type' => 'image/jpeg',
+ 'url' => 'http://.../back.jpeg',
+ ), $link->getLink('back'));
+
+ $this->assertTrue($link->hasLink('front'));
+ $this->assertFalse($link->hasLink('foo'));
+ }
+
+ public function testCanAddLink()
+ {
+ $link = new Link('Link', '<http://foo>; rel=a; type="image/jpeg"');
+ $link->addLink('http://test.com', 'test', array('foo' => 'bar'));
+ $this->assertEquals(
+ '<http://foo>; rel=a; type="image/jpeg", <http://test.com>; rel="test"; foo="bar"',
+ (string) $link
+ );
+ }
+
+ public function testCanParseLinksWithCommas()
+ {
+ $link = new Link('Link', '<http://example.com/TheBook/chapter1>; rel="previous"; title="start, index"');
+ $this->assertEquals(array(
+ array(
+ 'rel' => 'previous',
+ 'title' => 'start, index',
+ 'url' => 'http://example.com/TheBook/chapter1',
+ )
+ ), $link->getLinks());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparison.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparison.php
new file mode 100644
index 0000000..a3f511b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparison.php
@@ -0,0 +1,135 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message;
+
+use Guzzle\Common\Collection;
+use Guzzle\Http\Message\Header\HeaderCollection;
+
+/**
+ * Class used to compare HTTP headers using a custom DSL
+ */
+class HeaderComparison
+{
+ /**
+ * Compare HTTP headers and use special markup to filter values
+ * A header prefixed with '!' means it must not exist
+ * A header prefixed with '_' means it must be ignored
+ * A header value of '*' means anything after the * will be ignored
+ *
+ * @param array $filteredHeaders Array of special headers
+ * @param array $actualHeaders Array of headers to check against
+ *
+ * @return array|bool Returns an array of the differences or FALSE if none
+ */
+ public function compare($filteredHeaders, $actualHeaders)
+ {
+ $expected = array();
+ $ignore = array();
+ $absent = array();
+
+ if ($actualHeaders instanceof HeaderCollection) {
+ $actualHeaders = $actualHeaders->toArray();
+ }
+
+ foreach ($filteredHeaders as $k => $v) {
+ if ($k[0] == '_') {
+ // This header should be ignored
+ $ignore[] = str_replace('_', '', $k);
+ } elseif ($k[0] == '!') {
+ // This header must not be present
+ $absent[] = str_replace('!', '', $k);
+ } else {
+ $expected[$k] = $v;
+ }
+ }
+
+ return $this->compareArray($expected, $actualHeaders, $ignore, $absent);
+ }
+
+ /**
+ * Check if an array of HTTP headers matches another array of HTTP headers while taking * into account as a wildcard
+ *
+ * @param array $expected Expected HTTP headers (allows wildcard values)
+ * @param array|Collection $actual Actual HTTP header array
+ * @param array $ignore Headers to ignore from the comparison
+ * @param array $absent Array of headers that must not be present
+ *
+ * @return array|bool Returns an array of the differences or FALSE if none
+ */
+ public function compareArray(array $expected, $actual, array $ignore = array(), array $absent = array())
+ {
+ $differences = array();
+
+ // Add information about headers that were present but weren't supposed to be
+ foreach ($absent as $header) {
+ if ($this->hasKey($header, $actual)) {
+ $differences["++ {$header}"] = $actual[$header];
+ unset($actual[$header]);
+ }
+ }
+
+ // Check if expected headers are missing
+ foreach ($expected as $header => $value) {
+ if (!$this->hasKey($header, $actual)) {
+ $differences["- {$header}"] = $value;
+ }
+ }
+
+ // Flip the ignore array so it works with the case insensitive helper
+ $ignore = array_flip($ignore);
+ // Allow case-insensitive comparisons in wildcards
+ $expected = array_change_key_case($expected);
+
+ // Compare the expected and actual HTTP headers in no particular order
+ foreach ($actual as $key => $value) {
+
+ // If this is to be ignored, the skip it
+ if ($this->hasKey($key, $ignore)) {
+ continue;
+ }
+
+ // If the header was not expected
+ if (!$this->hasKey($key, $expected)) {
+ $differences["+ {$key}"] = $value;
+ continue;
+ }
+
+ // Check values and take wildcards into account
+ $lkey = strtolower($key);
+ $pos = is_string($expected[$lkey]) ? strpos($expected[$lkey], '*') : false;
+
+ foreach ((array) $actual[$key] as $v) {
+ if (($pos === false && $v != $expected[$lkey]) || $pos > 0 && substr($v, 0, $pos) != substr($expected[$lkey], 0, $pos)) {
+ $differences[$key] = "{$value} != {$expected[$lkey]}";
+ }
+ }
+ }
+
+ return empty($differences) ? false : $differences;
+ }
+
+ /**
+ * Case insensitive check if an array have a key
+ *
+ * @param string $key Key to check
+ * @param array $array Array to check
+ *
+ * @return bool
+ */
+ protected function hasKey($key, $array)
+ {
+ if ($array instanceof Collection) {
+ $keys = $array->getKeys();
+ } else {
+ $keys = array_keys($array);
+ }
+
+ foreach ($keys as $k) {
+ if (!strcasecmp($k, $key)) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparisonTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparisonTest.php
new file mode 100644
index 0000000..86c4fe8
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderComparisonTest.php
@@ -0,0 +1,115 @@
+<?php
+
+namespace Guzzle\Tests\Message;
+
+use Guzzle\Common\Collection;
+use Guzzle\Tests\Http\Message\HeaderComparison;
+
+class HeaderComparisonTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function filterProvider()
+ {
+ return array(
+
+ // Headers match
+ array(array(
+ 'Content-Length' => 'Foo'
+ ), array(
+ 'Content-Length' => 'Foo'
+ ), false),
+
+ // Missing header
+ array(array(
+ 'X-Foo' => 'Bar'
+ ), array(), array(
+ '- X-Foo' => 'Bar'
+ )),
+
+ // Extra headers is present
+ array(array(
+ 'X-Foo' => 'Bar'
+ ), array(
+ 'X-Foo' => 'Bar',
+ 'X-Baz' => 'Jar'
+ ), array(
+ '+ X-Baz' => 'Jar'
+ )),
+
+ // Header is present but must be absent
+ array(array(
+ '!X-Foo' => '*'
+ ), array(
+ 'X-Foo' => 'Bar'
+ ), array(
+ '++ X-Foo' => 'Bar'
+ )),
+
+ // Different values
+ array(array(
+ 'X-Foo' => 'Bar'
+ ), array(
+ 'X-Foo' => 'Baz'
+ ), array(
+ 'X-Foo' => 'Baz != Bar'
+ )),
+
+ // Wildcard search passes
+ array(array(
+ 'X-Foo' => '*'
+ ), array(
+ 'X-Foo' => 'Bar'
+ ), false),
+
+ // Wildcard search fails
+ array(array(
+ 'X-Foo' => '*'
+ ), array(), array(
+ '- X-Foo' => '*'
+ )),
+
+ // Ignore extra header if present
+ array(array(
+ 'X-Foo' => '*',
+ '_X-Bar' => '*',
+ ), array(
+ 'X-Foo' => 'Baz',
+ 'X-Bar' => 'Jar'
+ ), false),
+
+ // Ignore extra header if present and is not
+ array(array(
+ 'X-Foo' => '*',
+ '_X-Bar' => '*',
+ ), array(
+ 'X-Foo' => 'Baz'
+ ), false),
+
+ // Case insensitive
+ array(array(
+ 'X-Foo' => '*',
+ '_X-Bar' => '*',
+ ), array(
+ 'x-foo' => 'Baz',
+ 'x-BAR' => 'baz'
+ ), false),
+
+ // Case insensitive with collection
+ array(array(
+ 'X-Foo' => '*',
+ '_X-Bar' => '*',
+ ), new Collection(array(
+ 'x-foo' => 'Baz',
+ 'x-BAR' => 'baz'
+ )), false),
+ );
+ }
+
+ /**
+ * @dataProvider filterProvider
+ */
+ public function testComparesHeaders($filters, $headers, $result)
+ {
+ $compare = new HeaderComparison();
+ $this->assertEquals($result, $compare->compare($filters, $headers));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderTest.php
new file mode 100644
index 0000000..c750234
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/HeaderTest.php
@@ -0,0 +1,162 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message;
+
+use Guzzle\Http\Message\Header;
+use Guzzle\Http\Message\Response;
+
+/**
+ * @covers Guzzle\Http\Message\Header
+ */
+class HeaderTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $test = array(
+ 'zoo' => array('foo', 'Foo'),
+ 'Zoo' => 'bar',
+ );
+
+ public function testStoresHeaderName()
+ {
+ $i = new Header('Zoo', $this->test);
+ $this->assertEquals('Zoo', $i->getName());
+ }
+
+ public function testConvertsToString()
+ {
+ $i = new Header('Zoo', $this->test);
+ $this->assertEquals('foo, Foo, bar', (string) $i);
+ $i->setGlue(';');
+ $this->assertEquals('foo; Foo; bar', (string) $i);
+ }
+
+ public function testNormalizesGluedHeaders()
+ {
+ $h = new Header('Zoo', array('foo, Faz', 'bar'));
+ $result = $h->normalize(true)->toArray();
+ natsort($result);
+ $this->assertEquals(array('bar', 'foo', 'Faz'), $result);
+ }
+
+ public function testCanSearchForValues()
+ {
+ $h = new Header('Zoo', $this->test);
+ $this->assertTrue($h->hasValue('foo'));
+ $this->assertTrue($h->hasValue('Foo'));
+ $this->assertTrue($h->hasValue('bar'));
+ $this->assertFalse($h->hasValue('moo'));
+ $this->assertFalse($h->hasValue('FoO'));
+ }
+
+ public function testIsCountable()
+ {
+ $h = new Header('Zoo', $this->test);
+ $this->assertEquals(3, count($h));
+ }
+
+ public function testCanBeIterated()
+ {
+ $h = new Header('Zoo', $this->test);
+ $results = array();
+ foreach ($h as $key => $value) {
+ $results[$key] = $value;
+ }
+ $this->assertEquals(array(
+ 'foo', 'Foo', 'bar'
+ ), $results);
+ }
+
+ public function testAllowsFalseyValues()
+ {
+ // Allows 0
+ $h = new Header('Foo', 0, ';');
+ $this->assertEquals('0', (string) $h);
+ $this->assertEquals(1, count($h));
+ $this->assertEquals(';', $h->getGlue());
+
+ // Does not add a null header by default
+ $h = new Header('Foo');
+ $this->assertEquals('', (string) $h);
+ $this->assertEquals(0, count($h));
+
+ // Allows null array for a single null header
+ $h = new Header('Foo', array(null));
+ $this->assertEquals('', (string) $h);
+
+ // Allows empty string
+ $h = new Header('Foo', '');
+ $this->assertEquals('', (string) $h);
+ $this->assertEquals(1, count($h));
+ $this->assertEquals(1, count($h->normalize()->toArray()));
+ }
+
+ public function testCanRemoveValues()
+ {
+ $h = new Header('Foo', array('Foo', 'baz', 'bar'));
+ $h->removeValue('bar');
+ $this->assertTrue($h->hasValue('Foo'));
+ $this->assertFalse($h->hasValue('bar'));
+ $this->assertTrue($h->hasValue('baz'));
+ }
+
+ public function testAllowsArrayInConstructor()
+ {
+ $h = new Header('Foo', array('Testing', '123', 'Foo=baz'));
+ $this->assertEquals(array('Testing', '123', 'Foo=baz'), $h->toArray());
+ }
+
+ public function parseParamsProvider()
+ {
+ $res1 = array(
+ array(
+ '<http:/.../front.jpeg>' => '',
+ 'rel' => 'front',
+ 'type' => 'image/jpeg',
+ ),
+ array(
+ '<http://.../back.jpeg>' => '',
+ 'rel' => 'back',
+ 'type' => 'image/jpeg',
+ ),
+ );
+
+ return array(
+ array(
+ '<http:/.../front.jpeg>; rel="front"; type="image/jpeg", <http://.../back.jpeg>; rel=back; type="image/jpeg"',
+ $res1
+ ),
+ array(
+ '<http:/.../front.jpeg>; rel="front"; type="image/jpeg",<http://.../back.jpeg>; rel=back; type="image/jpeg"',
+ $res1
+ ),
+ array(
+ 'foo="baz"; bar=123, boo, test="123", foobar="foo;bar"',
+ array(
+ array('foo' => 'baz', 'bar' => '123'),
+ array('boo' => ''),
+ array('test' => '123'),
+ array('foobar' => 'foo;bar')
+ )
+ ),
+ array(
+ '<http://.../side.jpeg?test=1>; rel="side"; type="image/jpeg",<http://.../side.jpeg?test=2>; rel=side; type="image/jpeg"',
+ array(
+ array('<http://.../side.jpeg?test=1>' => '', 'rel' => 'side', 'type' => 'image/jpeg'),
+ array('<http://.../side.jpeg?test=2>' => '', 'rel' => 'side', 'type' => 'image/jpeg')
+ )
+ ),
+ array(
+ '',
+ array()
+ )
+ );
+ }
+
+ /**
+ * @dataProvider parseParamsProvider
+ */
+ public function testParseParams($header, $result)
+ {
+ $response = new Response(200, array('Link' => $header));
+ $this->assertEquals($result, $response->getHeader('Link')->parseParams());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/PostFileTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/PostFileTest.php
new file mode 100644
index 0000000..be048cb
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/PostFileTest.php
@@ -0,0 +1,88 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\PostFile;
+
+/**
+ * @covers Guzzle\Http\Message\PostFile
+ * @group server
+ */
+class PostFileTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testConstructorConfiguresPostFile()
+ {
+ $file = new PostFile('foo', __FILE__, 'x-foo', 'boo');
+ $this->assertEquals('foo', $file->getFieldName());
+ $this->assertEquals(__FILE__, $file->getFilename());
+ $this->assertEquals('boo', $file->getPostName());
+ $this->assertEquals('x-foo', $file->getContentType());
+ }
+
+ public function testRemovesLeadingAtSymbolFromPath()
+ {
+ $file = new PostFile('foo', '@' . __FILE__);
+ $this->assertEquals(__FILE__, $file->getFilename());
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testEnsuresFileIsReadable()
+ {
+ $file = new PostFile('foo', '/foo/baz/bar');
+ }
+
+ public function testCanChangeContentType()
+ {
+ $file = new PostFile('foo', '@' . __FILE__);
+ $file->setContentType('Boo');
+ $this->assertEquals('Boo', $file->getContentType());
+ }
+
+ public function testCanChangeFieldName()
+ {
+ $file = new PostFile('foo', '@' . __FILE__);
+ $file->setFieldName('Boo');
+ $this->assertEquals('Boo', $file->getFieldName());
+ }
+
+ public function testReturnsCurlValueString()
+ {
+ $file = new PostFile('foo', __FILE__);
+ if (version_compare(phpversion(), '5.5.0', '<')) {
+ $this->assertContains('@' . __FILE__ . ';filename=PostFileTest.php;type=text/x-', $file->getCurlValue());
+ } else {
+ $c = $file->getCurlValue();
+ $this->assertEquals(__FILE__, $c->getFilename());
+ $this->assertEquals('PostFileTest.php', $c->getPostFilename());
+ $this->assertContains('text/x-', $c->getMimeType());
+ }
+ }
+
+ public function testReturnsCurlValueStringAndPostname()
+ {
+ $file = new PostFile('foo', __FILE__, null, 'NewPostFileTest.php');
+ if (version_compare(phpversion(), '5.5.0', '<')) {
+ $this->assertContains('@' . __FILE__ . ';filename=NewPostFileTest.php;type=text/x-', $file->getCurlValue());
+ } else {
+ $c = $file->getCurlValue();
+ $this->assertEquals(__FILE__, $c->getFilename());
+ $this->assertEquals('NewPostFileTest.php', $c->getPostFilename());
+ $this->assertContains('text/x-', $c->getMimeType());
+ }
+ }
+
+ public function testContentDispositionFilePathIsStripped()
+ {
+ $this->getServer()->flush();
+ $client = new Client($this->getServer()->getUrl());
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request = $client->post()->addPostFile('file', __FILE__);
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(false);
+ $this->assertContains('POST / HTTP/1.1', $requests[0]);
+ $this->assertContains('Content-Disposition: form-data; name="file"; filename="PostFileTest.php"', $requests[0]);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestFactoryTest.php
new file mode 100644
index 0000000..80b8d54
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestFactoryTest.php
@@ -0,0 +1,616 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message;
+
+use Guzzle\Common\Collection;
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Url;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\QueryString;
+use Guzzle\Parser\Message\MessageParser;
+use Guzzle\Plugin\Log\LogPlugin;
+use Guzzle\Plugin\Mock\MockPlugin;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Message\RequestFactory
+ */
+class HttpRequestFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testCachesSingletonInstance()
+ {
+ $factory = RequestFactory::getInstance();
+ $this->assertSame($factory, RequestFactory::getInstance());
+ }
+
+ public function testCreatesNewGetRequests()
+ {
+ $request = RequestFactory::getInstance()->create('GET', 'http://www.google.com/');
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\MessageInterface', $request);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\RequestInterface', $request);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Request', $request);
+ $this->assertEquals('GET', $request->getMethod());
+ $this->assertEquals('http', $request->getScheme());
+ $this->assertEquals('http://www.google.com/', $request->getUrl());
+ $this->assertEquals('www.google.com', $request->getHost());
+ $this->assertEquals('/', $request->getPath());
+ $this->assertEquals('/', $request->getResource());
+
+ // Create a GET request with a custom receiving body
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $b = EntityBody::factory();
+ $request = RequestFactory::getInstance()->create('GET', $this->getServer()->getUrl(), null, $b);
+ $request->setClient(new Client());
+ $response = $request->send();
+ $this->assertSame($b, $response->getBody());
+ }
+
+ public function testCreatesPutRequests()
+ {
+ // Test using a string
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, 'Data');
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ $this->assertEquals('PUT', $request->getMethod());
+ $this->assertEquals('http', $request->getScheme());
+ $this->assertEquals('http://www.google.com/path?q=1&v=2', $request->getUrl());
+ $this->assertEquals('www.google.com', $request->getHost());
+ $this->assertEquals('/path', $request->getPath());
+ $this->assertEquals('/path?q=1&v=2', $request->getResource());
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $request->getBody());
+ $this->assertEquals('Data', (string) $request->getBody());
+ unset($request);
+
+ // Test using an EntityBody
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, EntityBody::factory('Data'));
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ $this->assertEquals('Data', (string) $request->getBody());
+
+ // Test using a resource
+ $resource = fopen('php://temp', 'w+');
+ fwrite($resource, 'Data');
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, $resource);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ $this->assertEquals('Data', (string) $request->getBody());
+
+ // Test using an object that can be cast as a string
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, Url::factory('http://www.example.com/'));
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ $this->assertEquals('http://www.example.com/', (string) $request->getBody());
+ }
+
+ public function testCreatesHeadAndDeleteRequests()
+ {
+ $request = RequestFactory::getInstance()->create('DELETE', 'http://www.test.com/');
+ $this->assertEquals('DELETE', $request->getMethod());
+ $request = RequestFactory::getInstance()->create('HEAD', 'http://www.test.com/');
+ $this->assertEquals('HEAD', $request->getMethod());
+ }
+
+ public function testCreatesOptionsRequests()
+ {
+ $request = RequestFactory::getInstance()->create('OPTIONS', 'http://www.example.com/');
+ $this->assertEquals('OPTIONS', $request->getMethod());
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ }
+
+ public function testCreatesNewPutRequestWithBody()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', null, 'Data');
+ $this->assertEquals('Data', (string) $request->getBody());
+ }
+
+ public function testCreatesNewPostRequestWithFields()
+ {
+ // Use an array
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.google.com/path?q=1&v=2', null, array(
+ 'a' => 'b'
+ ));
+ $this->assertEquals(array('a' => 'b'), $request->getPostFields()->getAll());
+ unset($request);
+
+ // Use a collection
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.google.com/path?q=1&v=2', null, new Collection(array(
+ 'a' => 'b'
+ )));
+ $this->assertEquals(array('a' => 'b'), $request->getPostFields()->getAll());
+
+ // Use a QueryString
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.google.com/path?q=1&v=2', null, new QueryString(array(
+ 'a' => 'b'
+ )));
+ $this->assertEquals(array('a' => 'b'), $request->getPostFields()->getAll());
+
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.test.com/', null, array(
+ 'a' => 'b',
+ 'file' => '@' . __FILE__
+ ));
+
+ $this->assertEquals(array(
+ 'a' => 'b'
+ ), $request->getPostFields()->getAll());
+
+ $files = $request->getPostFiles();
+ $this->assertInstanceOf('Guzzle\Http\Message\PostFile', $files['file'][0]);
+ }
+
+ public function testCreatesFromParts()
+ {
+ $parts = parse_url('http://michael:123@www.google.com:8080/path?q=1&v=2');
+
+ $request = RequestFactory::getInstance()->fromParts('PUT', $parts, null, 'Data');
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ $this->assertEquals('PUT', $request->getMethod());
+ $this->assertEquals('http', $request->getScheme());
+ $this->assertEquals('http://www.google.com:8080/path?q=1&v=2', $request->getUrl());
+ $this->assertEquals('www.google.com', $request->getHost());
+ $this->assertEquals('www.google.com:8080', $request->getHeader('Host'));
+ $this->assertEquals('/path', $request->getPath());
+ $this->assertEquals('/path?q=1&v=2', $request->getResource());
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $request->getBody());
+ $this->assertEquals('Data', (string) $request->getBody());
+ $this->assertEquals('michael', $request->getUsername());
+ $this->assertEquals('123', $request->getPassword());
+ $this->assertEquals('8080', $request->getPort());
+ $this->assertEquals(array(
+ 'scheme' => 'http',
+ 'host' => 'www.google.com',
+ 'port' => 8080,
+ 'path' => '/path',
+ 'query' => 'q=1&v=2',
+ ), parse_url($request->getUrl()));
+ }
+
+ public function testCreatesFromMessage()
+ {
+ $auth = base64_encode('michael:123');
+ $message = "PUT /path?q=1&v=2 HTTP/1.1\r\nHost: www.google.com:8080\r\nContent-Length: 4\r\nAuthorization: Basic {$auth}\r\n\r\nData";
+ $request = RequestFactory::getInstance()->fromMessage($message);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ $this->assertEquals('PUT', $request->getMethod());
+ $this->assertEquals('http', $request->getScheme());
+ $this->assertEquals('http://www.google.com:8080/path?q=1&v=2', $request->getUrl());
+ $this->assertEquals('www.google.com', $request->getHost());
+ $this->assertEquals('www.google.com:8080', $request->getHeader('Host'));
+ $this->assertEquals('/path', $request->getPath());
+ $this->assertEquals('/path?q=1&v=2', $request->getResource());
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $request->getBody());
+ $this->assertEquals('Data', (string) $request->getBody());
+ $this->assertEquals("Basic {$auth}", (string) $request->getHeader('Authorization'));
+ $this->assertEquals('8080', $request->getPort());
+
+ // Test passing a blank message returns false
+ $this->assertFalse($request = RequestFactory::getInstance()->fromMessage(''));
+
+ // Test passing a url with no port
+ $message = "PUT /path?q=1&v=2 HTTP/1.1\r\nHost: www.google.com\r\nContent-Length: 4\r\nAuthorization: Basic {$auth}\r\n\r\nData";
+ $request = RequestFactory::getInstance()->fromMessage($message);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\EntityEnclosingRequest', $request);
+ $this->assertEquals('PUT', $request->getMethod());
+ $this->assertEquals('http', $request->getScheme());
+ $this->assertEquals('http://www.google.com/path?q=1&v=2', $request->getUrl());
+ $this->assertEquals('www.google.com', $request->getHost());
+ $this->assertEquals('/path', $request->getPath());
+ $this->assertEquals('/path?q=1&v=2', $request->getResource());
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $request->getBody());
+ $this->assertEquals('Data', (string) $request->getBody());
+ $this->assertEquals("Basic {$auth}", (string) $request->getHeader('Authorization'));
+ $this->assertEquals(80, $request->getPort());
+ }
+
+ public function testCreatesNewTraceRequest()
+ {
+ $request = RequestFactory::getInstance()->create('TRACE', 'http://www.google.com/');
+ $this->assertFalse($request instanceof \Guzzle\Http\Message\EntityEnclosingRequest);
+ $this->assertEquals('TRACE', $request->getMethod());
+ }
+
+ public function testCreatesProperTransferEncodingRequests()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/', array(
+ 'Transfer-Encoding' => 'chunked'
+ ), 'hello');
+ $this->assertEquals('chunked', $request->getHeader('Transfer-Encoding'));
+ $this->assertFalse($request->hasHeader('Content-Length'));
+ }
+
+ public function testProperlyDealsWithDuplicateHeaders()
+ {
+ $parser = new MessageParser();
+
+ $message = "POST / http/1.1\r\n"
+ . "DATE:Mon, 09 Sep 2011 23:36:00 GMT\r\n"
+ . "host:host.foo.com\r\n"
+ . "ZOO:abc\r\n"
+ . "ZOO:123\r\n"
+ . "ZOO:HI\r\n"
+ . "zoo:456\r\n\r\n";
+
+ $parts = $parser->parseRequest($message);
+ $this->assertEquals(array (
+ 'DATE' => 'Mon, 09 Sep 2011 23:36:00 GMT',
+ 'host' => 'host.foo.com',
+ 'ZOO' => array('abc', '123', 'HI'),
+ 'zoo' => '456',
+ ), $parts['headers']);
+
+ $request = RequestFactory::getInstance()->fromMessage($message);
+
+ $this->assertEquals(array(
+ 'abc', '123', 'HI', '456'
+ ), $request->getHeader('zoo')->toArray());
+ }
+
+ public function testCreatesHttpMessagesWithBodiesAndNormalizesLineEndings()
+ {
+ $message = "POST / http/1.1\r\n"
+ . "Content-Type:application/x-www-form-urlencoded; charset=utf8\r\n"
+ . "Date:Mon, 09 Sep 2011 23:36:00 GMT\r\n"
+ . "Host:host.foo.com\r\n\r\n"
+ . "foo=bar";
+
+ $request = RequestFactory::getInstance()->fromMessage($message);
+ $this->assertEquals('application/x-www-form-urlencoded; charset=utf8', (string) $request->getHeader('Content-Type'));
+ $this->assertEquals('foo=bar', (string) $request->getBody());
+
+ $message = "POST / http/1.1\n"
+ . "Content-Type:application/x-www-form-urlencoded; charset=utf8\n"
+ . "Date:Mon, 09 Sep 2011 23:36:00 GMT\n"
+ . "Host:host.foo.com\n\n"
+ . "foo=bar";
+ $request = RequestFactory::getInstance()->fromMessage($message);
+ $this->assertEquals('foo=bar', (string) $request->getBody());
+
+ $message = "PUT / HTTP/1.1\r\nContent-Length: 0\r\n\r\n";
+ $request = RequestFactory::getInstance()->fromMessage($message);
+ $this->assertTrue($request->hasHeader('Content-Length'));
+ $this->assertEquals(0, (string) $request->getHeader('Content-Length'));
+ }
+
+ public function testBugPathIncorrectlyHandled()
+ {
+ $message = "POST /foo\r\n\r\nBODY";
+ $request = RequestFactory::getInstance()->fromMessage($message);
+ $this->assertSame('POST', $request->getMethod());
+ $this->assertSame('/foo', $request->getPath());
+ $this->assertSame('BODY', (string) $request->getBody());
+ }
+
+ public function testHandlesChunkedTransferEncoding()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.foo.com/', array(
+ 'Transfer-Encoding' => 'chunked'
+ ), 'Test');
+ $this->assertFalse($request->hasHeader('Content-Length'));
+ $this->assertEquals('chunked', $request->getHeader('Transfer-Encoding'));
+
+ $request = RequestFactory::getInstance()->create('POST', 'http://www.foo.com/', array(
+ 'transfer-encoding' => 'chunked'
+ ), array(
+ 'foo' => 'bar'
+ ));
+
+ $this->assertFalse($request->hasHeader('Content-Length'));
+ $this->assertEquals('chunked', $request->getHeader('Transfer-Encoding'));
+ }
+
+ public function testClonesRequestsWithMethodWithoutClient()
+ {
+ $f = RequestFactory::getInstance();
+ $request = $f->create('GET', 'http://www.test.com', array('X-Foo' => 'Bar'));
+ $request->getParams()->replace(array('test' => '123'));
+ $request->getCurlOptions()->set('foo', 'bar');
+ $cloned = $f->cloneRequestWithMethod($request, 'PUT');
+ $this->assertEquals('PUT', $cloned->getMethod());
+ $this->assertEquals('Bar', (string) $cloned->getHeader('X-Foo'));
+ $this->assertEquals('http://www.test.com', $cloned->getUrl());
+ // Ensure params are cloned and cleaned up
+ $this->assertEquals(1, count($cloned->getParams()->getAll()));
+ $this->assertEquals('123', $cloned->getParams()->get('test'));
+ // Ensure curl options are cloned
+ $this->assertEquals('bar', $cloned->getCurlOptions()->get('foo'));
+ // Ensure event dispatcher is cloned
+ $this->assertNotSame($request->getEventDispatcher(), $cloned->getEventDispatcher());
+ }
+
+ public function testClonesRequestsWithMethodWithClient()
+ {
+ $f = RequestFactory::getInstance();
+ $client = new Client();
+ $request = $client->put('http://www.test.com', array('Content-Length' => 4), 'test');
+ $cloned = $f->cloneRequestWithMethod($request, 'GET');
+ $this->assertEquals('GET', $cloned->getMethod());
+ $this->assertNull($cloned->getHeader('Content-Length'));
+ $this->assertEquals('http://www.test.com', $cloned->getUrl());
+ $this->assertSame($request->getClient(), $cloned->getClient());
+ }
+
+ public function testClonesRequestsWithMethodWithClientWithEntityEnclosingChange()
+ {
+ $f = RequestFactory::getInstance();
+ $client = new Client();
+ $request = $client->put('http://www.test.com', array('Content-Length' => 4), 'test');
+ $cloned = $f->cloneRequestWithMethod($request, 'POST');
+ $this->assertEquals('POST', $cloned->getMethod());
+ $this->assertEquals('test', (string) $cloned->getBody());
+ }
+
+ public function testCanDisableRedirects()
+ {
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 307\r\nLocation: " . $this->getServer()->getUrl() . "\r\nContent-Length: 0\r\n\r\n"
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $response = $client->get('/', array(), array('allow_redirects' => false))->send();
+ $this->assertEquals(307, $response->getStatusCode());
+ }
+
+ public function testCanAddCookies()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get('/', array(), array('cookies' => array('Foo' => 'Bar')));
+ $this->assertEquals('Bar', $request->getCookie('Foo'));
+ }
+
+ public function testCanAddQueryString()
+ {
+ $request = RequestFactory::getInstance()->create('GET', 'http://foo.com', array(), null, array(
+ 'query' => array('Foo' => 'Bar')
+ ));
+ $this->assertEquals('Bar', $request->getQuery()->get('Foo'));
+ }
+
+ public function testCanSetDefaultQueryString()
+ {
+ $request = new Request('GET', 'http://www.foo.com?test=abc');
+ RequestFactory::getInstance()->applyOptions($request, array(
+ 'query' => array('test' => '123', 'other' => 't123')
+ ), RequestFactory::OPTIONS_AS_DEFAULTS);
+ $this->assertEquals('abc', $request->getQuery()->get('test'));
+ $this->assertEquals('t123', $request->getQuery()->get('other'));
+ }
+
+ public function testCanAddBasicAuth()
+ {
+ $request = RequestFactory::getInstance()->create('GET', 'http://foo.com', array(), null, array(
+ 'auth' => array('michael', 'test')
+ ));
+ $this->assertEquals('michael', $request->getUsername());
+ $this->assertEquals('test', $request->getPassword());
+ }
+
+ public function testCanAddDigestAuth()
+ {
+ $request = RequestFactory::getInstance()->create('GET', 'http://foo.com', array(), null, array(
+ 'auth' => array('michael', 'test', 'digest')
+ ));
+ $this->assertEquals(CURLAUTH_DIGEST, $request->getCurlOptions()->get(CURLOPT_HTTPAUTH));
+ $this->assertEquals('michael', $request->getUsername());
+ $this->assertEquals('test', $request->getPassword());
+ }
+
+ public function testCanAddEvents()
+ {
+ $foo = null;
+ $client = new Client();
+ $client->addSubscriber(new MockPlugin(array(new Response(200))));
+ $request = $client->get($this->getServer()->getUrl(), array(), array(
+ 'events' => array(
+ 'request.before_send' => function () use (&$foo) { $foo = true; }
+ )
+ ));
+ $request->send();
+ $this->assertTrue($foo);
+ }
+
+ public function testCanAddEventsWithPriority()
+ {
+ $foo = null;
+ $client = new Client();
+ $client->addSubscriber(new MockPlugin(array(new Response(200))));
+ $request = $client->get($this->getServer()->getUrl(), array(), array(
+ 'events' => array(
+ 'request.before_send' => array(function () use (&$foo) { $foo = true; }, 100)
+ )
+ ));
+ $request->send();
+ $this->assertTrue($foo);
+ }
+
+ public function testCanAddPlugins()
+ {
+ $mock = new MockPlugin(array(
+ new Response(200),
+ new Response(200)
+ ));
+ $client = new Client();
+ $client->addSubscriber($mock);
+ $request = $client->get('/', array(), array(
+ 'plugins' => array($mock)
+ ));
+ $request->send();
+ }
+
+ public function testCanDisableExceptions()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array(
+ 'plugins' => array(new MockPlugin(array(new Response(500)))),
+ 'exceptions' => false
+ ));
+ $this->assertEquals(500, $request->send()->getStatusCode());
+ }
+
+ public function testCanDisableExceptionsWithErrorListener()
+ {
+ $client = new Client();
+ $client->getEventDispatcher()->addListener('request.error', function () {});
+ $request = $client->get('/', array(), array(
+ 'plugins' => array(new MockPlugin(array(new Response(500)))),
+ 'exceptions' => false
+ ));
+ $this->assertEquals(500, $request->send()->getStatusCode());
+ }
+
+ public function testCanChangeSaveToLocation()
+ {
+ $r = EntityBody::factory();
+ $client = new Client();
+ $request = $client->get('/', array(), array(
+ 'plugins' => array(new MockPlugin(array(new Response(200, array(), 'testing')))),
+ 'save_to' => $r
+ ));
+ $request->send();
+ $this->assertEquals('testing', (string) $r);
+ }
+
+ public function testCanSetProxy()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('proxy' => '192.168.16.121'));
+ $this->assertEquals('192.168.16.121', $request->getCurlOptions()->get(CURLOPT_PROXY));
+ }
+
+ public function testCanSetHeadersOption()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('headers' => array('Foo' => 'Bar')));
+ $this->assertEquals('Bar', (string) $request->getHeader('Foo'));
+ }
+
+ public function testCanSetDefaultHeadersOptions()
+ {
+ $request = new Request('GET', 'http://www.foo.com', array('Foo' => 'Bar'));
+ RequestFactory::getInstance()->applyOptions($request, array(
+ 'headers' => array('Foo' => 'Baz', 'Bam' => 't123')
+ ), RequestFactory::OPTIONS_AS_DEFAULTS);
+ $this->assertEquals('Bar', (string) $request->getHeader('Foo'));
+ $this->assertEquals('t123', (string) $request->getHeader('Bam'));
+ }
+
+ public function testCanSetBodyOption()
+ {
+ $client = new Client();
+ $request = $client->put('/', array(), null, array('body' => 'test'));
+ $this->assertEquals('test', (string) $request->getBody());
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testValidatesBodyOption()
+ {
+ $client = new Client();
+ $client->get('/', array(), array('body' => 'test'));
+ }
+
+ public function testCanSetTimeoutOption()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('timeout' => 1.5));
+ $this->assertEquals(1500, $request->getCurlOptions()->get(CURLOPT_TIMEOUT_MS));
+ }
+
+ public function testCanSetConnectTimeoutOption()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('connect_timeout' => 1.5));
+ $this->assertEquals(1500, $request->getCurlOptions()->get(CURLOPT_CONNECTTIMEOUT_MS));
+ }
+
+ public function testCanSetDebug()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('debug' => true));
+ $this->assertTrue($request->getCurlOptions()->get(CURLOPT_VERBOSE));
+ }
+
+ public function testCanSetVerifyToOff()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('verify' => false));
+ $this->assertNull($request->getCurlOptions()->get(CURLOPT_CAINFO));
+ $this->assertSame(0, $request->getCurlOptions()->get(CURLOPT_SSL_VERIFYHOST));
+ $this->assertFalse($request->getCurlOptions()->get(CURLOPT_SSL_VERIFYPEER));
+ }
+
+ public function testCanSetVerifyToOn()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('verify' => true));
+ $this->assertNotNull($request->getCurlOptions()->get(CURLOPT_CAINFO));
+ $this->assertSame(2, $request->getCurlOptions()->get(CURLOPT_SSL_VERIFYHOST));
+ $this->assertTrue($request->getCurlOptions()->get(CURLOPT_SSL_VERIFYPEER));
+ }
+
+ public function testCanSetVerifyToPath()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('verify' => '/foo.pem'));
+ $this->assertEquals('/foo.pem', $request->getCurlOptions()->get(CURLOPT_CAINFO));
+ $this->assertSame(2, $request->getCurlOptions()->get(CURLOPT_SSL_VERIFYHOST));
+ $this->assertTrue($request->getCurlOptions()->get(CURLOPT_SSL_VERIFYPEER));
+ }
+
+ public function inputValidation()
+ {
+ return array_map(function ($option) { return array($option); }, array(
+ 'headers', 'query', 'cookies', 'auth', 'events', 'plugins', 'params'
+ ));
+ }
+
+ /**
+ * @dataProvider inputValidation
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testValidatesInput($option)
+ {
+ $client = new Client();
+ $client->get('/', array(), array($option => 'foo'));
+ }
+
+ public function testCanAddRequestParams()
+ {
+ $client = new Client();
+ $request = $client->put('/', array(), null, array('params' => array('foo' => 'test')));
+ $this->assertEquals('test', $request->getParams()->get('foo'));
+ }
+
+ public function testCanAddSslKey()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('ssl_key' => '/foo.pem'));
+ $this->assertEquals('/foo.pem', $request->getCurlOptions()->get(CURLOPT_SSLKEY));
+ }
+
+ public function testCanAddSslKeyPassword()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('ssl_key' => array('/foo.pem', 'bar')));
+ $this->assertEquals('/foo.pem', $request->getCurlOptions()->get(CURLOPT_SSLKEY));
+ $this->assertEquals('bar', $request->getCurlOptions()->get(CURLOPT_SSLKEYPASSWD));
+ }
+
+ public function testCanAddSslCert()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('cert' => '/foo.pem'));
+ $this->assertEquals('/foo.pem', $request->getCurlOptions()->get(CURLOPT_SSLCERT));
+ }
+
+ public function testCanAddSslCertPassword()
+ {
+ $client = new Client();
+ $request = $client->get('/', array(), array('cert' => array('/foo.pem', 'bar')));
+ $this->assertEquals('/foo.pem', $request->getCurlOptions()->get(CURLOPT_SSLCERT));
+ $this->assertEquals('bar', $request->getCurlOptions()->get(CURLOPT_SSLCERTPASSWD));
+ }
+
+ public function testCreatesBodyWithoutZeroString()
+ {
+ $request = RequestFactory::getInstance()->create('PUT', 'http://test.com', array(), '0');
+ $this->assertSame('0', (string) $request->getBody());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestTest.php
new file mode 100644
index 0000000..5bf6248
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/RequestTest.php
@@ -0,0 +1,639 @@
+<?php
+
+namespace Guzzle\Tests\Http\Message;
+
+use Guzzle\Common\Collection;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Url;
+use Guzzle\Http\Client;
+use Guzzle\Plugin\Async\AsyncPlugin;
+use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\RedirectPlugin;
+use Guzzle\Http\Exception\BadResponseException;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Message\Request
+ * @covers Guzzle\Http\Message\AbstractMessage
+ */
+class RequestTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var Request */
+ protected $request;
+
+ /** @var Client */
+ protected $client;
+
+ protected function setUp()
+ {
+ $this->client = new Client($this->getServer()->getUrl());
+ $this->request = $this->client->get();
+ }
+
+ public function tearDown()
+ {
+ unset($this->request);
+ unset($this->client);
+ }
+
+ public function testConstructorBuildsRequestWithArrayHeaders()
+ {
+ // Test passing an array of headers
+ $request = new Request('GET', 'http://www.guzzle-project.com/', array(
+ 'foo' => 'bar'
+ ));
+
+ $this->assertEquals('GET', $request->getMethod());
+ $this->assertEquals('http://www.guzzle-project.com/', $request->getUrl());
+ $this->assertEquals('bar', $request->getHeader('foo'));
+ }
+
+ public function testDescribesEvents()
+ {
+ $this->assertInternalType('array', Request::getAllEvents());
+ }
+
+ public function testConstructorBuildsRequestWithCollectionHeaders()
+ {
+ $request = new Request('GET', 'http://www.guzzle-project.com/', new Collection(array(
+ 'foo' => 'bar'
+ )));
+ $this->assertEquals('bar', $request->getHeader('foo'));
+ }
+
+ public function testConstructorBuildsRequestWithNoHeaders()
+ {
+ $request = new Request('GET', 'http://www.guzzle-project.com/', null);
+ $this->assertFalse($request->hasHeader('foo'));
+ }
+
+ public function testConstructorHandlesNonBasicAuth()
+ {
+ $request = new Request('GET', 'http://www.guzzle-project.com/', array(
+ 'Authorization' => 'Foo bar'
+ ));
+ $this->assertNull($request->getUserName());
+ $this->assertNull($request->getPassword());
+ $this->assertEquals('Foo bar', (string) $request->getHeader('Authorization'));
+ }
+
+ public function testRequestsCanBeConvertedToRawMessageStrings()
+ {
+ $auth = base64_encode('michael:123');
+ $message = "PUT /path?q=1&v=2 HTTP/1.1\r\n"
+ . "Host: www.google.com\r\n"
+ . "Authorization: Basic {$auth}\r\n"
+ . "Content-Length: 4\r\n\r\nData";
+
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.google.com/path?q=1&v=2', array(
+ 'Authorization' => 'Basic ' . $auth
+ ), 'Data');
+
+ $this->assertEquals($message, $request->__toString());
+ }
+
+ /**
+ * Add authorization after the fact and see that it was put in the message
+ */
+ public function testRequestStringsIncludeAuth()
+ {
+ $auth = base64_encode('michael:123');
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request = RequestFactory::getInstance()->create('PUT', $this->getServer()->getUrl(), null, 'Data')
+ ->setClient($this->client)
+ ->setAuth('michael', '123', CURLAUTH_BASIC);
+ $request->send();
+
+ $this->assertContains('Authorization: Basic ' . $auth, (string) $request);
+ }
+
+ public function testGetEventDispatcher()
+ {
+ $d = $this->request->getEventDispatcher();
+ $this->assertInstanceOf('Symfony\\Component\\EventDispatcher\\EventDispatcherInterface', $d);
+ $this->assertEquals($d, $this->request->getEventDispatcher());
+ }
+
+ public function testRequestsManageClients()
+ {
+ $request = new Request('GET', 'http://test.com');
+ $this->assertNull($request->getClient());
+ $request->setClient($this->client);
+ $this->assertSame($this->client, $request->getClient());
+ }
+
+ /**
+ * @expectedException \RuntimeException
+ * @expectedExceptionMessage A client must be set on the request
+ */
+ public function testRequestsRequireClients()
+ {
+ $request = new Request('GET', 'http://test.com');
+ $request->send();
+ }
+
+ public function testSend()
+ {
+ $response = new Response(200, array(
+ 'Content-Length' => 3
+ ), 'abc');
+ $this->request->setResponse($response, true);
+ $r = $this->request->send();
+
+ $this->assertSame($response, $r);
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $this->request->getResponse());
+ $this->assertSame($r, $this->request->getResponse());
+ $this->assertEquals('complete', $this->request->getState());
+ }
+
+ public function testGetResponse()
+ {
+ $this->assertNull($this->request->getResponse());
+ $response = new Response(200, array('Content-Length' => 3), 'abc');
+
+ $this->request->setResponse($response);
+ $this->assertEquals($response, $this->request->getResponse());
+
+ $client = new Client('http://www.google.com');
+ $request = $client->get('http://www.google.com/');
+ $request->setResponse($response, true);
+ $request->send();
+ $requestResponse = $request->getResponse();
+ $this->assertSame($response, $requestResponse);
+
+ // Try again, making sure it's still the same response
+ $this->assertSame($requestResponse, $request->getResponse());
+
+ $response = new Response(204);
+ $request = $client->get();
+ $request->setResponse($response, true);
+ $request->send();
+ $requestResponse = $request->getResponse();
+ $this->assertSame($response, $requestResponse);
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $response->getBody());
+ }
+
+ public function testRequestThrowsExceptionOnBadResponse()
+ {
+ try {
+ $this->request->setResponse(new Response(404, array('Content-Length' => 3), 'abc'), true);
+ $this->request->send();
+ $this->fail('Expected exception not thrown');
+ } catch (BadResponseException $e) {
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\RequestInterface', $e->getRequest());
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $e->getResponse());
+ $this->assertContains('Client error response', $e->getMessage());
+ }
+ }
+
+ public function testManagesQuery()
+ {
+ $this->assertInstanceOf('Guzzle\\Http\\QueryString', $this->request->getQuery());
+ $this->request->getQuery()->set('test', '123');
+ $this->assertEquals('test=123', $this->request->getQuery(true));
+ }
+
+ public function testRequestHasMethod()
+ {
+ $this->assertEquals('GET', $this->request->getMethod());
+ }
+
+ public function testRequestHasScheme()
+ {
+ $this->assertEquals('http', $this->request->getScheme());
+ $this->assertEquals($this->request, $this->request->setScheme('https'));
+ $this->assertEquals('https', $this->request->getScheme());
+ }
+
+ public function testRequestHasHost()
+ {
+ $this->assertEquals('127.0.0.1', $this->request->getHost());
+ $this->assertEquals('127.0.0.1:8124', (string) $this->request->getHeader('Host'));
+
+ $this->assertSame($this->request, $this->request->setHost('www2.google.com'));
+ $this->assertEquals('www2.google.com', $this->request->getHost());
+ $this->assertEquals('www2.google.com:8124', (string) $this->request->getHeader('Host'));
+
+ $this->assertSame($this->request, $this->request->setHost('www.test.com:8081'));
+ $this->assertEquals('www.test.com', $this->request->getHost());
+ $this->assertEquals(8081, $this->request->getPort());
+ }
+
+ public function testRequestHasProtocol()
+ {
+ $this->assertEquals('1.1', $this->request->getProtocolVersion());
+ $this->assertEquals($this->request, $this->request->setProtocolVersion('1.1'));
+ $this->assertEquals('1.1', $this->request->getProtocolVersion());
+ $this->assertEquals($this->request, $this->request->setProtocolVersion('1.0'));
+ $this->assertEquals('1.0', $this->request->getProtocolVersion());
+ }
+
+ public function testRequestHasPath()
+ {
+ $this->assertEquals('/', $this->request->getPath());
+ $this->assertEquals($this->request, $this->request->setPath('/index.html'));
+ $this->assertEquals('/index.html', $this->request->getPath());
+ $this->assertEquals($this->request, $this->request->setPath('index.html'));
+ $this->assertEquals('/index.html', $this->request->getPath());
+ }
+
+ public function testPermitsFalsyComponents()
+ {
+ $request = new Request('GET', 'http://0/0?0');
+ $this->assertSame('0', $request->getHost());
+ $this->assertSame('/0', $request->getPath());
+ $this->assertSame('0', $request->getQuery(true));
+
+ $request = new Request('GET', '0');
+ $this->assertEquals('/0', $request->getPath());
+ }
+
+ public function testRequestHasPort()
+ {
+ $this->assertEquals(8124, $this->request->getPort());
+ $this->assertEquals('127.0.0.1:8124', $this->request->getHeader('Host'));
+
+ $this->assertEquals($this->request, $this->request->setPort('8080'));
+ $this->assertEquals('8080', $this->request->getPort());
+ $this->assertEquals('127.0.0.1:8080', $this->request->getHeader('Host'));
+
+ $this->request->setPort(80);
+ $this->assertEquals('127.0.0.1', $this->request->getHeader('Host'));
+ }
+
+ public function testRequestHandlesAuthorization()
+ {
+ // Uninitialized auth
+ $this->assertEquals(null, $this->request->getUsername());
+ $this->assertEquals(null, $this->request->getPassword());
+
+ // Set an auth
+ $this->assertSame($this->request, $this->request->setAuth('michael', '123'));
+ $this->assertEquals('michael', $this->request->getUsername());
+ $this->assertEquals('123', $this->request->getPassword());
+
+ // Set an auth with blank password
+ $this->assertSame($this->request, $this->request->setAuth('michael', ''));
+ $this->assertEquals('michael', $this->request->getUsername());
+ $this->assertEquals('', $this->request->getPassword());
+
+ // Remove the auth
+ $this->request->setAuth(false);
+ $this->assertEquals(null, $this->request->getUsername());
+ $this->assertEquals(null, $this->request->getPassword());
+
+ // Make sure that the cURL based auth works too
+ $request = new Request('GET', $this->getServer()->getUrl());
+ $request->setAuth('michael', 'password', CURLAUTH_DIGEST);
+ $this->assertEquals('michael:password', $request->getCurlOptions()->get(CURLOPT_USERPWD));
+ $this->assertEquals(CURLAUTH_DIGEST, $request->getCurlOptions()->get(CURLOPT_HTTPAUTH));
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testValidatesAuth()
+ {
+ $this->request->setAuth('foo', 'bar', 'bam');
+ }
+
+ public function testGetResourceUri()
+ {
+ $this->assertEquals('/', $this->request->getResource());
+ $this->request->setPath('/index.html');
+ $this->assertEquals('/index.html', $this->request->getResource());
+ $this->request->getQuery()->add('v', '1');
+ $this->assertEquals('/index.html?v=1', $this->request->getResource());
+ }
+
+ public function testRequestHasMutableUrl()
+ {
+ $url = 'http://www.test.com:8081/path?q=123#fragment';
+ $u = Url::factory($url);
+ $this->assertSame($this->request, $this->request->setUrl($url));
+ $this->assertEquals($url, $this->request->getUrl());
+
+ $this->assertSame($this->request, $this->request->setUrl($u));
+ $this->assertEquals($url, $this->request->getUrl());
+ }
+
+ public function testRequestHasState()
+ {
+ $this->assertEquals(RequestInterface::STATE_NEW, $this->request->getState());
+ $this->request->setState(RequestInterface::STATE_TRANSFER);
+ $this->assertEquals(RequestInterface::STATE_TRANSFER, $this->request->getState());
+ }
+
+ public function testSetManualResponse()
+ {
+ $response = new Response(200, array(
+ 'Date' => 'Sat, 16 Oct 2010 17:27:14 GMT',
+ 'Expires' => '-1',
+ 'Cache-Control' => 'private, max-age=0',
+ 'Content-Type' => 'text/html; charset=ISO-8859-1',
+ ), 'response body');
+
+ $this->assertSame($this->request, $this->request->setResponse($response), '-> setResponse() must use a fluent interface');
+ $this->assertEquals('complete', $this->request->getState(), '-> setResponse() must change the state of the request to complete');
+ $this->assertSame($response, $this->request->getResponse(), '-> setResponse() must set the exact same response that was passed in to it');
+ }
+
+ public function testRequestCanHaveManuallySetResponseBody()
+ {
+ $file = __DIR__ . '/../../TestData/temp.out';
+ if (file_exists($file)) {
+ unlink($file);
+ }
+
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata");
+ $request = RequestFactory::getInstance()->create('GET', $this->getServer()->getUrl());
+ $request->setClient($this->client);
+ $entityBody = EntityBody::factory(fopen($file, 'w+'));
+ $request->setResponseBody($entityBody);
+ $response = $request->send();
+ $this->assertSame($entityBody, $response->getBody());
+
+ $this->assertTrue(file_exists($file));
+ $this->assertEquals('data', file_get_contents($file));
+ unlink($file);
+
+ $this->assertEquals('data', $response->getBody(true));
+ }
+
+ public function testHoldsCookies()
+ {
+ $this->assertNull($this->request->getCookie('test'));
+
+ // Set a cookie
+ $this->assertSame($this->request, $this->request->addCookie('test', 'abc'));
+ $this->assertEquals('abc', $this->request->getCookie('test'));
+
+ // Multiple cookies by setting the Cookie header
+ $this->request->setHeader('Cookie', '__utma=1.638370270.1344367610.1374365610.1944450276.2; __utmz=1.1346368610.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none); hl=de; PHPSESSID=ak93pqashi5uubuoq8fjv60897');
+ $this->assertEquals('1.638370270.1344367610.1374365610.1944450276.2', $this->request->getCookie('__utma'));
+ $this->assertEquals('1.1346368610.1.1.utmcsr=(direct)|utmccn=(direct)|utmcmd=(none)', $this->request->getCookie('__utmz'));
+ $this->assertEquals('de', $this->request->getCookie('hl'));
+ $this->assertEquals('ak93pqashi5uubuoq8fjv60897', $this->request->getCookie('PHPSESSID'));
+
+ // Unset the cookies by setting the Cookie header to null
+ $this->request->setHeader('Cookie', null);
+ $this->assertNull($this->request->getCookie('test'));
+ $this->request->removeHeader('Cookie');
+
+ // Set and remove a cookie
+ $this->assertSame($this->request, $this->request->addCookie('test', 'abc'));
+ $this->assertEquals('abc', $this->request->getCookie('test'));
+ $this->assertSame($this->request, $this->request->removeCookie('test'));
+ $this->assertNull($this->request->getCookie('test'));
+
+ // Remove the cookie header
+ $this->assertSame($this->request, $this->request->addCookie('test', 'abc'));
+ $this->request->removeHeader('Cookie');
+ $this->assertEquals('', (string) $this->request->getHeader('Cookie'));
+
+ // Remove a cookie value
+ $this->request->addCookie('foo', 'bar')->addCookie('baz', 'boo');
+ $this->request->removeCookie('foo');
+ $this->assertEquals(array(
+ 'baz' => 'boo'
+ ), $this->request->getCookies());
+
+ $this->request->addCookie('foo', 'bar');
+ $this->assertEquals('baz=boo; foo=bar', (string) $this->request->getHeader('Cookie'));
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\RequestException
+ * @expectedExceptionMessage Error completing request
+ */
+ public function testRequestThrowsExceptionWhenSetToCompleteWithNoResponse()
+ {
+ $this->request->setState(RequestInterface::STATE_COMPLETE);
+ }
+
+ public function testClonedRequestsUseNewInternalState()
+ {
+ $p = new AsyncPlugin();
+ $this->request->getEventDispatcher()->addSubscriber($p);
+ $h = $this->request->getHeader('Host');
+
+ $r = clone $this->request;
+ $this->assertEquals(RequestInterface::STATE_NEW, $r->getState());
+ $this->assertNotSame($r->getQuery(), $this->request->getQuery());
+ $this->assertNotSame($r->getCurlOptions(), $this->request->getCurlOptions());
+ $this->assertNotSame($r->getEventDispatcher(), $this->request->getEventDispatcher());
+ $this->assertEquals($r->getHeaders(), $this->request->getHeaders());
+ $this->assertNotSame($h, $r->getHeader('Host'));
+ $this->assertNotSame($r->getParams(), $this->request->getParams());
+ $this->assertTrue($this->request->getEventDispatcher()->hasListeners('request.sent'));
+ }
+
+ public function testRecognizesBasicAuthCredentialsInUrls()
+ {
+ $this->request->setUrl('http://michael:test@test.com/');
+ $this->assertEquals('michael', $this->request->getUsername());
+ $this->assertEquals('test', $this->request->getPassword());
+ }
+
+ public function testRequestCanBeSentUsingCurl()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\nExpires: Thu, 01 Dec 1994 16:00:00 GMT\r\nConnection: close\r\n\r\ndata",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\nExpires: Thu, 01 Dec 1994 16:00:00 GMT\r\nConnection: close\r\n\r\ndata",
+ "HTTP/1.1 404 Not Found\r\nContent-Encoding: application/xml\r\nContent-Length: 48\r\n\r\n<error><mesage>File not found</message></error>"
+ ));
+
+ $request = RequestFactory::getInstance()->create('GET', $this->getServer()->getUrl());
+ $request->setClient($this->client);
+ $response = $request->send();
+
+ $this->assertEquals('data', $response->getBody(true));
+ $this->assertEquals(200, (int) $response->getStatusCode());
+ $this->assertEquals('OK', $response->getReasonPhrase());
+ $this->assertEquals(4, $response->getContentLength());
+ $this->assertEquals('Thu, 01 Dec 1994 16:00:00 GMT', $response->getExpires());
+
+ // Test that the same handle can be sent twice without setting state to new
+ $response2 = $request->send();
+ $this->assertNotSame($response, $response2);
+
+ try {
+ $request = RequestFactory::getInstance()->create('GET', $this->getServer()->getUrl() . 'index.html');
+ $request->setClient($this->client);
+ $response = $request->send();
+ $this->fail('Request did not receive a 404 response');
+ } catch (BadResponseException $e) {
+ }
+
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $messages = $this->getServer()->getReceivedRequests(false);
+ $port = $this->getServer()->getPort();
+
+ $userAgent = $this->client->getDefaultUserAgent();
+
+ $this->assertEquals('127.0.0.1:' . $port, $requests[0]->getHeader('Host'));
+ $this->assertEquals('127.0.0.1:' . $port, $requests[1]->getHeader('Host'));
+ $this->assertEquals('127.0.0.1:' . $port, $requests[2]->getHeader('Host'));
+
+ $this->assertEquals('/', $requests[0]->getPath());
+ $this->assertEquals('/', $requests[1]->getPath());
+ $this->assertEquals('/index.html', $requests[2]->getPath());
+
+ $parts = explode("\r\n", $messages[0]);
+ $this->assertEquals('GET / HTTP/1.1', $parts[0]);
+
+ $parts = explode("\r\n", $messages[1]);
+ $this->assertEquals('GET / HTTP/1.1', $parts[0]);
+
+ $parts = explode("\r\n", $messages[2]);
+ $this->assertEquals('GET /index.html HTTP/1.1', $parts[0]);
+ }
+
+ public function testThrowsExceptionsWhenUnsuccessfulResponseIsReceivedByDefault()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 404 Not found\r\nContent-Length: 0\r\n\r\n");
+
+ try {
+ $request = $this->client->get('/index.html');
+ $response = $request->send();
+ $this->fail('Request did not receive a 404 response');
+ } catch (BadResponseException $e) {
+ $this->assertContains('Client error response', $e->getMessage());
+ $this->assertContains('[status code] 404', $e->getMessage());
+ $this->assertContains('[reason phrase] Not found', $e->getMessage());
+ }
+ }
+
+ public function testCanShortCircuitErrorHandling()
+ {
+ $request = $this->request;
+ $response = new Response(404);
+ $request->setResponse($response, true);
+ $out = '';
+ $that = $this;
+ $request->getEventDispatcher()->addListener('request.error', function($event) use (&$out, $that) {
+ $out .= $event['request'] . "\n" . $event['response'] . "\n";
+ $event->stopPropagation();
+ });
+ $request->send();
+ $this->assertContains((string) $request, $out);
+ $this->assertContains((string) $request->getResponse(), $out);
+ $this->assertSame($response, $request->getResponse());
+ }
+
+ public function testCanOverrideUnsuccessfulResponses()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 404 NOT FOUND\r\n" .
+ "Content-Length: 0\r\n" .
+ "\r\n",
+ "HTTP/1.1 200 OK\r\n" .
+ "Content-Length: 0\r\n" .
+ "\r\n"
+ ));
+
+ $newResponse = null;
+
+ $request = $this->request;
+ $request->getEventDispatcher()->addListener('request.error', function($event) use (&$newResponse) {
+ if ($event['response']->getStatusCode() == 404) {
+ $newRequest = clone $event['request'];
+ $newResponse = $newRequest->send();
+ // Override the original response and bypass additional response processing
+ $event['response'] = $newResponse;
+ // Call $event['request']->setResponse($newResponse); to re-apply events
+ $event->stopPropagation();
+ }
+ });
+
+ $request->send();
+
+ $this->assertEquals(200, $request->getResponse()->getStatusCode());
+ $this->assertSame($newResponse, $request->getResponse());
+ $this->assertEquals(2, count($this->getServer()->getReceivedRequests()));
+ }
+
+ public function testCanRetrieveUrlObject()
+ {
+ $request = new Request('GET', 'http://www.example.com/foo?abc=d');
+ $this->assertInstanceOf('Guzzle\Http\Url', $request->getUrl(true));
+ $this->assertEquals('http://www.example.com/foo?abc=d', $request->getUrl());
+ $this->assertEquals('http://www.example.com/foo?abc=d', (string) $request->getUrl(true));
+ }
+
+ public function testUnresolvedRedirectsReturnResponse()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 303 SEE OTHER\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Foo\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n"
+ ));
+ $request = $this->request;
+ $this->assertEquals(303, $request->send()->getStatusCode());
+ $request->getParams()->set(RedirectPlugin::DISABLE, true);
+ $this->assertEquals(301, $request->send()->getStatusCode());
+ }
+
+ public function testCanSendCustomRequests()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $request = $this->client->createRequest('PROPFIND', $this->getServer()->getUrl(), array(
+ 'Content-Type' => 'text/plain'
+ ), 'foo');
+ $response = $request->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('PROPFIND', $requests[0]->getMethod());
+ $this->assertEquals(3, (string) $requests[0]->getHeader('Content-Length'));
+ $this->assertEquals('foo', (string) $requests[0]->getBody());
+ }
+
+ /**
+ * @expectedException \PHPUnit_Framework_Error_Warning
+ */
+ public function testEnsuresFileCanBeCreated()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest");
+ $this->client->get('/')->setResponseBody('/wefwefefefefwewefwe/wefwefwefefwe/wefwefewfw.txt')->send();
+ }
+
+ public function testAllowsFilenameForDownloadingContent()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest");
+ $name = sys_get_temp_dir() . '/foo.txt';
+ $this->client->get('/')->setResponseBody($name)->send();
+ $this->assertEquals('test', file_get_contents($name));
+ unlink($name);
+ }
+
+ public function testUsesCustomResponseBodyWhenItIsCustom()
+ {
+ $en = EntityBody::factory();
+ $request = $this->client->get();
+ $request->setResponseBody($en);
+ $request->setResponse(new Response(200, array(), 'foo'));
+ $this->assertEquals('foo', (string) $en);
+ }
+
+ public function testCanChangePortThroughScheme()
+ {
+ $request = new Request('GET', 'http://foo.com');
+ $request->setScheme('https');
+ $this->assertEquals('https://foo.com', (string) $request->getUrl());
+ $this->assertEquals('foo.com', $request->getHost());
+ $request->setScheme('http');
+ $this->assertEquals('http://foo.com', (string) $request->getUrl());
+ $this->assertEquals('foo.com', $request->getHost());
+ $request->setPort(null);
+ $this->assertEquals('http://foo.com', (string) $request->getUrl());
+ $this->assertEquals('foo.com', $request->getHost());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/ResponseTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/ResponseTest.php
new file mode 100644
index 0000000..08b4df8
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Message/ResponseTest.php
@@ -0,0 +1,677 @@
+<?php
+
+namespace Guzzle\Tests\Message;
+
+use Guzzle\Common\Collection;
+use Guzzle\Http\ClientInterface;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\HttpException;
+use Guzzle\Http\Exception\BadResponseException;
+use Guzzle\Http\Message\Response;
+
+/**
+ * @group server
+ * @covers Guzzle\Http\Message\Response
+ */
+class ResponseTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var Response The response object to test */
+ protected $response;
+
+ public function setup()
+ {
+ $this->response = new Response(200, new Collection(array(
+ 'Accept-Ranges' => 'bytes',
+ 'Age' => '12',
+ 'Allow' => 'GET, HEAD',
+ 'Cache-Control' => 'no-cache',
+ 'Content-Encoding' => 'gzip',
+ 'Content-Language' => 'da',
+ 'Content-Length' => '348',
+ 'Content-Location' => '/index.htm',
+ 'Content-Disposition' => 'attachment; filename=fname.ext',
+ 'Content-MD5' => 'Q2hlY2sgSW50ZWdyaXR5IQ==',
+ 'Content-Range' => 'bytes 21010-47021/47022',
+ 'Content-Type' => 'text/html; charset=utf-8',
+ 'Date' => 'Tue, 15 Nov 1994 08:12:31 GMT',
+ 'ETag' => '737060cd8c284d8af7ad3082f209582d',
+ 'Expires' => 'Thu, 01 Dec 1994 16:00:00 GMT',
+ 'Last-Modified' => 'Tue, 15 Nov 1994 12:45:26 GMT',
+ 'Location' => 'http://www.w3.org/pub/WWW/People.html',
+ 'Pragma' => 'no-cache',
+ 'Proxy-Authenticate' => 'Basic',
+ 'Retry-After' => '120',
+ 'Server' => 'Apache/1.3.27 (Unix) (Red-Hat/Linux)',
+ 'Set-Cookie' => 'UserID=JohnDoe; Max-Age=3600; Version=1',
+ 'Trailer' => 'Max-Forwards',
+ 'Transfer-Encoding' => 'chunked',
+ 'Vary' => '*',
+ 'Via' => '1.0 fred, 1.1 nowhere.com (Apache/1.1)',
+ 'Warning' => '199 Miscellaneous warning',
+ 'WWW-Authenticate' => 'Basic'
+ )), 'body');
+ }
+
+ public function tearDown()
+ {
+ unset($this->response);
+ }
+
+ public function testConstructor()
+ {
+ $params = new Collection();
+ $body = EntityBody::factory('');
+ $response = new Response(200, $params, $body);
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals($body, $response->getBody());
+ $this->assertEquals('OK', $response->getReasonPhrase());
+ $this->assertEquals("HTTP/1.1 200 OK\r\n\r\n", $response->getRawHeaders());
+
+ // Make sure Content-Length is set automatically
+ $response = new Response(200, $params);
+ $this->assertEquals("HTTP/1.1 200 OK\r\n\r\n", $response->getRawHeaders());
+
+ // Pass bodies to the response
+ $response = new Response(200, null, 'data');
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $response->getBody());
+ $response = new Response(200, null, EntityBody::factory('data'));
+ $this->assertInstanceOf('Guzzle\\Http\\EntityBody', $response->getBody());
+ $this->assertEquals('data', $response->getBody(true));
+ $response = new Response(200, null, '0');
+ $this->assertSame('0', $response->getBody(true), 'getBody(true) should return "0" if response body is "0".');
+
+ // Make sure the proper exception is thrown
+ try {
+ //$response = new Response(200, null, array('foo' => 'bar'));
+ //$this->fail('Response did not throw exception when passing invalid body');
+ } catch (HttpException $e) {
+ }
+
+ // Ensure custom codes can be set
+ $response = new Response(2);
+ $this->assertEquals(2, $response->getStatusCode());
+ $this->assertEquals('', $response->getReasonPhrase());
+
+ // Make sure the proper exception is thrown when sending invalid headers
+ try {
+ $response = new Response(200, 'adidas');
+ $this->fail('Response did not throw exception when passing invalid $headers');
+ } catch (BadResponseException $e) {
+ }
+ }
+
+ public function test__toString()
+ {
+ $response = new Response(200);
+ $this->assertEquals("HTTP/1.1 200 OK\r\n\r\n", (string) $response);
+
+ // Add another header
+ $response = new Response(200, array(
+ 'X-Test' => 'Guzzle'
+ ));
+ $this->assertEquals("HTTP/1.1 200 OK\r\nX-Test: Guzzle\r\n\r\n", (string) $response);
+
+ $response = new Response(200, array(
+ 'Content-Length' => 4
+ ), 'test');
+ $this->assertEquals("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest", (string) $response);
+ }
+
+ public function testFactory()
+ {
+ $response = Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest");
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('OK', $response->getReasonPhrase());
+ $this->assertEquals(4, (string) $response->getContentLength());
+ $this->assertEquals('test', $response->getBody(true));
+
+ // Make sure that automatic Content-Length works
+ $response = Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest");
+ $this->assertEquals(4, (string) $response->getContentLength());
+ $this->assertEquals('test', $response->getBody(true));
+ }
+
+ public function testFactoryCanCreateHeadResponses()
+ {
+ $response = Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\n");
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('OK', $response->getReasonPhrase());
+ $this->assertEquals(4, (string) $response->getContentLength());
+ $this->assertEquals('', $response->getBody(true));
+ }
+
+ public function testFactoryRequiresMessage()
+ {
+ $this->assertFalse(Response::fromMessage(''));
+ }
+
+ public function testGetBody()
+ {
+ $body = EntityBody::factory('');
+ $response = new Response(403, new Collection(), $body);
+ $this->assertEquals($body, $response->getBody());
+ $response->setBody('foo');
+ $this->assertEquals('foo', $response->getBody(true));
+ }
+
+ public function testManagesStatusCode()
+ {
+ $response = new Response(403);
+ $this->assertEquals(403, $response->getStatusCode());
+ }
+
+ public function testGetMessage()
+ {
+ $response = new Response(200, new Collection(array(
+ 'Content-Length' => 4
+ )), 'body');
+
+ $this->assertEquals("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\nbody", $response->getMessage());
+ }
+
+ public function testGetRawHeaders()
+ {
+ $response = new Response(200, new Collection(array(
+ 'Keep-Alive' => 155,
+ 'User-Agent' => 'Guzzle',
+ 'Content-Length' => 4
+ )), 'body');
+
+ $this->assertEquals("HTTP/1.1 200 OK\r\nKeep-Alive: 155\r\nUser-Agent: Guzzle\r\nContent-Length: 4\r\n\r\n", $response->getRawHeaders());
+ }
+
+ public function testHandlesStatusAndStatusCodes()
+ {
+ $response = new Response(200, new Collection(), 'body');
+ $this->assertEquals('OK', $response->getReasonPhrase());
+
+ $this->assertSame($response, $response->setStatus(204));
+ $this->assertEquals('No Content', $response->getReasonPhrase());
+ $this->assertEquals(204, $response->getStatusCode());
+
+ $this->assertSame($response, $response->setStatus(204, 'Testing!'));
+ $this->assertEquals('Testing!', $response->getReasonPhrase());
+ $this->assertEquals(204, $response->getStatusCode());
+
+ $response->setStatus(2000);
+ $this->assertEquals(2000, $response->getStatusCode());
+ $this->assertEquals('', $response->getReasonPhrase());
+
+ $response->setStatus(200, 'Foo');
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('Foo', $response->getReasonPhrase());
+ }
+
+ public function testIsClientError()
+ {
+ $response = new Response(403);
+ $this->assertTrue($response->isClientError());
+ $response = new Response(200);
+ $this->assertFalse($response->isClientError());
+ }
+
+ public function testIsError()
+ {
+ $response = new Response(403);
+ $this->assertTrue($response->isError());
+ $response = new Response(200);
+ $this->assertFalse($response->isError());
+ $response = new Response(500);
+ $this->assertTrue($response->isError());
+ }
+
+ public function testIsInformational()
+ {
+ $response = new Response(100);
+ $this->assertTrue($response->isInformational());
+ $response = new Response(200);
+ $this->assertFalse($response->isInformational());
+ }
+
+ public function testIsRedirect()
+ {
+ $response = new Response(301);
+ $this->assertTrue($response->isRedirect());
+ $response = new Response(200);
+ $this->assertFalse($response->isRedirect());
+ }
+
+ public function testIsServerError()
+ {
+ $response = new Response(500);
+ $this->assertTrue($response->isServerError());
+ $response = new Response(400);
+ $this->assertFalse($response->isServerError());
+ }
+
+ public function testIsSuccessful()
+ {
+ $response = new Response(200);
+ $this->assertTrue($response->isSuccessful());
+ $response = new Response(403);
+ $this->assertFalse($response->isSuccessful());
+ }
+
+ public function testGetAcceptRanges()
+ {
+ $this->assertEquals('bytes', $this->response->getAcceptRanges());
+ }
+
+ public function testCalculatesAge()
+ {
+ $this->assertEquals(12, $this->response->calculateAge());
+
+ $this->response->removeHeader('Age');
+ $this->response->removeHeader('Date');
+ $this->assertNull($this->response->calculateAge());
+
+ $this->response->setHeader('Date', gmdate(ClientInterface::HTTP_DATE, strtotime('-1 minute')));
+ // If the test runs slowly, still pass with a +5 second allowance
+ $this->assertTrue($this->response->getAge() - 60 <= 5);
+ }
+
+ public function testGetAllow()
+ {
+ $this->assertEquals('GET, HEAD', $this->response->getAllow());
+ }
+
+ public function testGetCacheControl()
+ {
+ $this->assertEquals('no-cache', $this->response->getCacheControl());
+ }
+
+ public function testGetContentEncoding()
+ {
+ $this->assertEquals('gzip', $this->response->getContentEncoding());
+ }
+
+ public function testGetContentLanguage()
+ {
+ $this->assertEquals('da', $this->response->getContentLanguage());
+ }
+
+ public function testGetContentLength()
+ {
+ $this->assertEquals('348', $this->response->getContentLength());
+ }
+
+ public function testGetContentLocation()
+ {
+ $this->assertEquals('/index.htm', $this->response->getContentLocation());
+ }
+
+ public function testGetContentDisposition()
+ {
+ $this->assertEquals('attachment; filename=fname.ext', $this->response->getContentDisposition());
+ }
+
+ public function testGetContentMd5()
+ {
+ $this->assertEquals('Q2hlY2sgSW50ZWdyaXR5IQ==', $this->response->getContentMd5());
+ }
+
+ public function testGetContentRange()
+ {
+ $this->assertEquals('bytes 21010-47021/47022', $this->response->getContentRange());
+ }
+
+ public function testGetContentType()
+ {
+ $this->assertEquals('text/html; charset=utf-8', $this->response->getContentType());
+ }
+
+ public function testGetDate()
+ {
+ $this->assertEquals('Tue, 15 Nov 1994 08:12:31 GMT', $this->response->getDate());
+ }
+
+ public function testGetEtag()
+ {
+ $this->assertEquals('737060cd8c284d8af7ad3082f209582d', $this->response->getEtag());
+ }
+
+ public function testGetExpires()
+ {
+ $this->assertEquals('Thu, 01 Dec 1994 16:00:00 GMT', $this->response->getExpires());
+ }
+
+ public function testGetLastModified()
+ {
+ $this->assertEquals('Tue, 15 Nov 1994 12:45:26 GMT', $this->response->getLastModified());
+ }
+
+ public function testGetLocation()
+ {
+ $this->assertEquals('http://www.w3.org/pub/WWW/People.html', $this->response->getLocation());
+ }
+
+ public function testGetPragma()
+ {
+ $this->assertEquals('no-cache', $this->response->getPragma());
+ }
+
+ public function testGetProxyAuthenticate()
+ {
+ $this->assertEquals('Basic', $this->response->getProxyAuthenticate());
+ }
+
+ public function testGetServer()
+ {
+ $this->assertEquals('Apache/1.3.27 (Unix) (Red-Hat/Linux)', $this->response->getServer());
+ }
+
+ public function testGetSetCookie()
+ {
+ $this->assertEquals('UserID=JohnDoe; Max-Age=3600; Version=1', $this->response->getSetCookie());
+ }
+
+ public function testGetMultipleSetCookie()
+ {
+ $this->response->addHeader('Set-Cookie', 'UserID=Mike; Max-Age=200');
+ $this->assertEquals(array(
+ 'UserID=JohnDoe; Max-Age=3600; Version=1',
+ 'UserID=Mike; Max-Age=200',
+ ), $this->response->getHeader('Set-Cookie')->toArray());
+ }
+
+ public function testGetSetCookieNormalizesHeaders()
+ {
+ $this->response->addHeaders(array(
+ 'Set-Cooke' => 'boo',
+ 'set-cookie' => 'foo'
+ ));
+
+ $this->assertEquals(array(
+ 'UserID=JohnDoe; Max-Age=3600; Version=1',
+ 'foo'
+ ), $this->response->getHeader('Set-Cookie')->toArray());
+
+ $this->response->addHeaders(array(
+ 'set-cookie' => 'fubu'
+ ));
+ $this->assertEquals(
+ array('UserID=JohnDoe; Max-Age=3600; Version=1', 'foo', 'fubu'),
+ $this->response->getHeader('Set-Cookie')->toArray()
+ );
+ }
+
+ public function testGetTrailer()
+ {
+ $this->assertEquals('Max-Forwards', $this->response->getTrailer());
+ }
+
+ public function testGetTransferEncoding()
+ {
+ $this->assertEquals('chunked', $this->response->getTransferEncoding());
+ }
+
+ public function testGetVary()
+ {
+ $this->assertEquals('*', $this->response->getVary());
+ }
+
+ public function testReturnsViaHeader()
+ {
+ $this->assertEquals('1.0 fred, 1.1 nowhere.com (Apache/1.1)', $this->response->getVia());
+ }
+ public function testGetWarning()
+ {
+ $this->assertEquals('199 Miscellaneous warning', $this->response->getWarning());
+ }
+
+ public function testReturnsWwwAuthenticateHeader()
+ {
+ $this->assertEquals('Basic', $this->response->getWwwAuthenticate());
+ }
+
+ public function testReturnsConnectionHeader()
+ {
+ $this->assertEquals(null, $this->response->getConnection());
+ $this->response->setHeader('Connection', 'close');
+ $this->assertEquals('close', $this->response->getConnection());
+ }
+
+ public function testReturnsHeaders()
+ {
+ $this->assertEquals('Basic', $this->response->getHeader('WWW-Authenticate', null, true));
+ $this->assertEquals('chunked', $this->response->getHeader('Transfer-Encoding', null, false));
+ }
+
+ public function testHasTransferInfo()
+ {
+ $stats = array (
+ 'url' => 'http://www.google.com/',
+ 'content_type' => 'text/html; charset=ISO-8859-1',
+ 'http_code' => 200,
+ 'header_size' => 606,
+ 'request_size' => 53,
+ 'filetime' => -1,
+ 'ssl_verify_result' => 0,
+ 'redirect_count' => 0,
+ 'total_time' => 0.093284,
+ 'namelookup_time' => 0.001349,
+ 'connect_time' => 0.01635,
+ 'pretransfer_time' => 0.016358,
+ 'size_upload' => 0,
+ 'size_download' => 10330,
+ 'speed_download' => 110737,
+ 'speed_upload' => 0,
+ 'download_content_length' => -1,
+ 'upload_content_length' => 0,
+ 'starttransfer_time' => 0.07066,
+ 'redirect_time' => 0,
+ );
+
+ // Uninitialized state
+ $this->assertNull($this->response->getInfo('url'));
+ $this->assertEquals(array(), $this->response->getInfo());
+
+ // Set the stats
+ $this->response->setInfo($stats);
+ $this->assertEquals($stats, $this->response->getInfo());
+ $this->assertEquals(606, $this->response->getInfo('header_size'));
+ $this->assertNull($this->response->getInfo('does_not_exist'));
+ }
+
+ /**
+ * @return Response
+ */
+ private function getResponse($code, array $headers = null, EntityBody $body = null)
+ {
+ return new Response($code, $headers, $body);
+ }
+
+ public function testDeterminesIfItCanBeCached()
+ {
+ $this->assertTrue($this->getResponse(200)->canCache());
+ $this->assertTrue($this->getResponse(410)->canCache());
+ $this->assertFalse($this->getResponse(404)->canCache());
+ $this->assertTrue($this->getResponse(200, array(
+ 'Cache-Control' => 'public'
+ ))->canCache());
+
+ // This has the no-store directive
+ $this->assertFalse($this->getResponse(200, array(
+ 'Cache-Control' => 'private, no-store'
+ ))->canCache());
+
+ // The body cannot be read, so it cannot be cached
+ $tmp = tempnam('/tmp', 'not-readable');
+ $resource = fopen($tmp, 'w');
+ $this->assertFalse($this->getResponse(200, array(
+ 'Transfer-Encoding' => 'chunked'
+ ), EntityBody::factory($resource, 10))->canCache());
+ unlink($tmp);
+
+ // The body is 0 length, cannot be read, so it can be cached
+ $tmp = tempnam('/tmp', 'not-readable');
+ $resource = fopen($tmp, 'w');
+ $this->assertTrue($this->getResponse(200, array(array(
+ 'Content-Length' => 0
+ )), EntityBody::factory($resource, 0))->canCache());
+ unlink($tmp);
+ }
+
+ public function testDeterminesResponseMaxAge()
+ {
+ $this->assertEquals(null, $this->getResponse(200)->getMaxAge());
+
+ // Uses the response's s-maxage
+ $this->assertEquals(140, $this->getResponse(200, array(
+ 'Cache-Control' => 's-maxage=140'
+ ))->getMaxAge());
+
+ // Uses the response's max-age
+ $this->assertEquals(120, $this->getResponse(200, array(
+ 'Cache-Control' => 'max-age=120'
+ ))->getMaxAge());
+
+ // Uses the response's max-age
+ $this->assertEquals(120, $this->getResponse(200, array(
+ 'Cache-Control' => 'max-age=120',
+ 'Expires' => gmdate(ClientInterface::HTTP_DATE, strtotime('+1 day'))
+ ))->getMaxAge());
+
+ // Uses the Expires date
+ $this->assertGreaterThanOrEqual(82400, $this->getResponse(200, array(
+ 'Expires' => gmdate(ClientInterface::HTTP_DATE, strtotime('+1 day'))
+ ))->getMaxAge());
+
+ // Uses the Expires date
+ $this->assertGreaterThanOrEqual(82400, $this->getResponse(200, array(
+ 'Expires' => gmdate(ClientInterface::HTTP_DATE, strtotime('+1 day'))
+ ))->getMaxAge());
+ }
+
+ public function testDeterminesIfItCanValidate()
+ {
+ $response = new Response(200);
+ $this->assertFalse($response->canValidate());
+ $response->setHeader('ETag', '123');
+ $this->assertTrue($response->canValidate());
+ $response->removeHeader('ETag');
+ $this->assertFalse($response->canValidate());
+ $response->setHeader('Last-Modified', '123');
+ $this->assertTrue($response->canValidate());
+ }
+
+ public function testCalculatesFreshness()
+ {
+ $response = new Response(200);
+ $this->assertNull($response->isFresh());
+ $this->assertNull($response->getFreshness());
+
+ $response->setHeader('Cache-Control', 'max-age=120');
+ $response->setHeader('Age', 100);
+ $this->assertEquals(20, $response->getFreshness());
+ $this->assertTrue($response->isFresh());
+
+ $response->setHeader('Age', 120);
+ $this->assertEquals(0, $response->getFreshness());
+ $this->assertTrue($response->isFresh());
+
+ $response->setHeader('Age', 150);
+ $this->assertEquals(-30, $response->getFreshness());
+ $this->assertFalse($response->isFresh());
+ }
+
+ public function testHandlesProtocols()
+ {
+ $this->assertSame($this->response, $this->response->setProtocol('HTTP', '1.0'));
+ $this->assertEquals('HTTP', $this->response->getProtocol());
+ $this->assertEquals('1.0', $this->response->getProtocolVersion());
+ }
+
+ public function testComparesContentType()
+ {
+ $response = new Response(200, array(
+ 'Content-Type' => 'text/html; charset=ISO-8859-4'
+ ));
+
+ $this->assertTrue($response->isContentType('text/html'));
+ $this->assertTrue($response->isContentType('TExT/html'));
+ $this->assertTrue($response->isContentType('charset=ISO-8859-4'));
+ $this->assertFalse($response->isContentType('application/xml'));
+ }
+
+ public function testResponseDeterminesIfMethodIsAllowedBaseOnAllowHeader()
+ {
+ $response = new Response(200, array(
+ 'Allow' => 'OPTIONS, POST, deletE,GET'
+ ));
+
+ $this->assertTrue($response->isMethodAllowed('get'));
+ $this->assertTrue($response->isMethodAllowed('GET'));
+ $this->assertTrue($response->isMethodAllowed('options'));
+ $this->assertTrue($response->isMethodAllowed('post'));
+ $this->assertTrue($response->isMethodAllowed('Delete'));
+ $this->assertFalse($response->isMethodAllowed('put'));
+ $this->assertFalse($response->isMethodAllowed('PUT'));
+
+ $response = new Response(200);
+ $this->assertFalse($response->isMethodAllowed('get'));
+ }
+
+ public function testParsesJsonResponses()
+ {
+ $response = new Response(200, array(), '{"foo": "bar"}');
+ $this->assertEquals(array('foo' => 'bar'), $response->json());
+ // Return array when null is a service response
+ $response = new Response(200);
+ $this->assertEquals(array(), $response->json());
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ * @expectedExceptionMessage Unable to parse response body into JSON: 4
+ */
+ public function testThrowsExceptionWhenFailsToParseJsonResponse()
+ {
+ $response = new Response(200, array(), '{"foo": "');
+ $response->json();
+ }
+
+ public function testParsesXmlResponses()
+ {
+ $response = new Response(200, array(), '<abc><foo>bar</foo></abc>');
+ $this->assertEquals('bar', (string) $response->xml()->foo);
+ // Always return a SimpleXMLElement from the xml method
+ $response = new Response(200);
+ $this->assertEmpty((string) $response->xml()->foo);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ * @expectedExceptionMessage Unable to parse response body into XML: String could not be parsed as XML
+ */
+ public function testThrowsExceptionWhenFailsToParseXmlResponse()
+ {
+ $response = new Response(200, array(), '<abc');
+ $response->xml();
+ }
+
+ public function testResponseIsSerializable()
+ {
+ $response = new Response(200, array('Foo' => 'bar'), 'test');
+ $r = unserialize(serialize($response));
+ $this->assertEquals(200, $r->getStatusCode());
+ $this->assertEquals('bar', (string) $r->getHeader('Foo'));
+ $this->assertEquals('test', (string) $r->getBody());
+ }
+
+ public function testPreventsComplexExternalEntities()
+ {
+ $xml = '<?xml version="1.0"?><!DOCTYPE scan[<!ENTITY test SYSTEM "php://filter/read=convert.base64-encode/resource=ResponseTest.php">]><scan>&test;</scan>';
+ $response = new Response(200, array(), $xml);
+
+ $oldCwd = getcwd();
+ chdir(__DIR__);
+ try {
+ $xml = $response->xml();
+ chdir($oldCwd);
+ $this->markTestIncomplete('Did not throw the expected exception! XML resolved as: ' . $xml->asXML());
+ } catch (\Exception $e) {
+ chdir($oldCwd);
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/MimetypesTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/MimetypesTest.php
new file mode 100644
index 0000000..7228453
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/MimetypesTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\Mimetypes;
+
+/**
+ * @covers Guzzle\Http\Mimetypes
+ */
+class MimetypesTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testGetsFromExtension()
+ {
+ $this->assertEquals('text/x-php', Mimetypes::getInstance()->fromExtension('php'));
+ }
+
+ public function testGetsFromFilename()
+ {
+ $this->assertEquals('text/x-php', Mimetypes::getInstance()->fromFilename(__FILE__));
+ }
+
+ public function testGetsFromCaseInsensitiveFilename()
+ {
+ $this->assertEquals('text/x-php', Mimetypes::getInstance()->fromFilename(strtoupper(__FILE__)));
+ }
+
+ public function testReturnsNullWhenNoMatchFound()
+ {
+ $this->assertNull(Mimetypes::getInstance()->fromExtension('foobar'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/CommaAggregatorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/CommaAggregatorTest.php
new file mode 100644
index 0000000..549d3ed
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/CommaAggregatorTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\QueryString;
+use Guzzle\Http\QueryAggregator\CommaAggregator as Ag;
+
+class CommaAggregatorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testAggregates()
+ {
+ $query = new QueryString();
+ $a = new Ag();
+ $key = 'test 123';
+ $value = array('foo 123', 'baz', 'bar');
+ $result = $a->aggregate($key, $value, $query);
+ $this->assertEquals(array('test%20123' => 'foo%20123,baz,bar'), $result);
+ }
+
+ public function testEncodes()
+ {
+ $query = new QueryString();
+ $query->useUrlEncoding(false);
+ $a = new Ag();
+ $key = 'test 123';
+ $value = array('foo 123', 'baz', 'bar');
+ $result = $a->aggregate($key, $value, $query);
+ $this->assertEquals(array('test 123' => 'foo 123,baz,bar'), $result);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/DuplicateAggregatorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/DuplicateAggregatorTest.php
new file mode 100644
index 0000000..6a4d9d9
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/DuplicateAggregatorTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\QueryString;
+use Guzzle\Http\QueryAggregator\DuplicateAggregator as Ag;
+
+class DuplicateAggregatorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testAggregates()
+ {
+ $query = new QueryString();
+ $a = new Ag();
+ $key = 'facet 1';
+ $value = array('size a', 'width b');
+ $result = $a->aggregate($key, $value, $query);
+ $this->assertEquals(array('facet%201' => array('size%20a', 'width%20b')), $result);
+ }
+
+ public function testEncodes()
+ {
+ $query = new QueryString();
+ $query->useUrlEncoding(false);
+ $a = new Ag();
+ $key = 'facet 1';
+ $value = array('size a', 'width b');
+ $result = $a->aggregate($key, $value, $query);
+ $this->assertEquals(array('facet 1' => array('size a', 'width b')), $result);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/PhpAggregatorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/PhpAggregatorTest.php
new file mode 100644
index 0000000..1e7f0c2
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryAggregator/PhpAggregatorTest.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\QueryString;
+use Guzzle\Http\QueryAggregator\PhpAggregator as Ag;
+
+class PhpAggregatorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testEncodes()
+ {
+ $query = new QueryString();
+ $query->useUrlEncoding(false);
+ $a = new Ag();
+ $key = 't';
+ $value = array(
+ 'v1' => 'a',
+ 'v2' => 'b',
+ 'v3' => array(
+ 'v4' => 'c',
+ 'v5' => 'd',
+ )
+ );
+ $result = $a->aggregate($key, $value, $query);
+ $this->assertEquals(array(
+ 't[v1]' => 'a',
+ 't[v2]' => 'b',
+ 't[v3][v4]' => 'c',
+ 't[v3][v5]' => 'd',
+ ), $result);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryStringTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryStringTest.php
new file mode 100644
index 0000000..948db44
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/QueryStringTest.php
@@ -0,0 +1,233 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\QueryString;
+use Guzzle\Http\QueryAggregator\DuplicateAggregator;
+use Guzzle\Http\QueryAggregator\CommaAggregator;
+
+class QueryStringTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var \Guzzle\Http\QueryString The query string object to test */
+ protected $q;
+
+ public function setup()
+ {
+ $this->q = new QueryString();
+ }
+
+ public function testGetFieldSeparator()
+ {
+ $this->assertEquals('&', $this->q->getFieldSeparator());
+ }
+
+ public function testGetValueSeparator()
+ {
+ $this->assertEquals('=', $this->q->getValueSeparator());
+ }
+
+ public function testIsUrlEncoding()
+ {
+ $this->assertEquals('RFC 3986', $this->q->getUrlEncoding());
+ $this->assertTrue($this->q->isUrlEncoding());
+ $this->assertEquals('foo%20bar', $this->q->encodeValue('foo bar'));
+
+ $this->q->useUrlEncoding(QueryString::FORM_URLENCODED);
+ $this->assertTrue($this->q->isUrlEncoding());
+ $this->assertEquals(QueryString::FORM_URLENCODED, $this->q->getUrlEncoding());
+ $this->assertEquals('foo+bar', $this->q->encodeValue('foo bar'));
+
+ $this->assertSame($this->q, $this->q->useUrlEncoding(false));
+ $this->assertFalse($this->q->isUrlEncoding());
+ $this->assertFalse($this->q->isUrlEncoding());
+ }
+
+ public function testSetFieldSeparator()
+ {
+ $this->assertEquals($this->q, $this->q->setFieldSeparator('/'));
+ $this->assertEquals('/', $this->q->getFieldSeparator());
+ }
+
+ public function testSetValueSeparator()
+ {
+ $this->assertEquals($this->q, $this->q->setValueSeparator('/'));
+ $this->assertEquals('/', $this->q->getValueSeparator());
+ }
+
+ public function testUrlEncode()
+ {
+ $params = array(
+ 'test' => 'value',
+ 'test 2' => 'this is a test?',
+ 'test3' => array('v1', 'v2', 'v3'),
+ 'ሴ' => 'bar'
+ );
+ $encoded = array(
+ 'test' => 'value',
+ 'test%202' => rawurlencode('this is a test?'),
+ 'test3%5B0%5D' => 'v1',
+ 'test3%5B1%5D' => 'v2',
+ 'test3%5B2%5D' => 'v3',
+ '%E1%88%B4' => 'bar'
+ );
+ $this->q->replace($params);
+ $this->assertEquals($encoded, $this->q->urlEncode());
+
+ // Disable encoding
+ $testData = array('test 2' => 'this is a test');
+ $this->q->replace($testData);
+ $this->q->useUrlEncoding(false);
+ $this->assertEquals($testData, $this->q->urlEncode());
+ }
+
+ public function testToString()
+ {
+ // Check with no parameters
+ $this->assertEquals('', $this->q->__toString());
+
+ $params = array(
+ 'test' => 'value',
+ 'test 2' => 'this is a test?',
+ 'test3' => array('v1', 'v2', 'v3'),
+ 'test4' => null,
+ );
+ $this->q->replace($params);
+ $this->assertEquals('test=value&test%202=this%20is%20a%20test%3F&test3%5B0%5D=v1&test3%5B1%5D=v2&test3%5B2%5D=v3&test4', $this->q->__toString());
+ $this->q->useUrlEncoding(false);
+ $this->assertEquals('test=value&test 2=this is a test?&test3[0]=v1&test3[1]=v2&test3[2]=v3&test4', $this->q->__toString());
+
+ // Use an alternative aggregator
+ $this->q->setAggregator(new CommaAggregator());
+ $this->assertEquals('test=value&test 2=this is a test?&test3=v1,v2,v3&test4', $this->q->__toString());
+ }
+
+ public function testAllowsMultipleValuesPerKey()
+ {
+ $q = new QueryString();
+ $q->add('facet', 'size');
+ $q->add('facet', 'width');
+ $q->add('facet.field', 'foo');
+ // Use the duplicate aggregator
+ $q->setAggregator(new DuplicateAggregator());
+ $this->assertEquals('facet=size&facet=width&facet.field=foo', $q->__toString());
+ }
+
+ public function testAllowsNestedQueryData()
+ {
+ $this->q->replace(array(
+ 'test' => 'value',
+ 't' => array(
+ 'v1' => 'a',
+ 'v2' => 'b',
+ 'v3' => array(
+ 'v4' => 'c',
+ 'v5' => 'd',
+ )
+ )
+ ));
+
+ $this->q->useUrlEncoding(false);
+ $this->assertEquals('test=value&t[v1]=a&t[v2]=b&t[v3][v4]=c&t[v3][v5]=d', $this->q->__toString());
+ }
+
+ public function parseQueryProvider()
+ {
+ return array(
+ // Ensure that multiple query string values are allowed per value
+ array('q=a&q=b', array('q' => array('a', 'b'))),
+ // Ensure that PHP array style query string values are parsed
+ array('q[]=a&q[]=b', array('q' => array('a', 'b'))),
+ // Ensure that a single PHP array style query string value is parsed into an array
+ array('q[]=a', array('q' => array('a'))),
+ // Ensure that decimals are allowed in query strings
+ array('q.a=a&q.b=b', array(
+ 'q.a' => 'a',
+ 'q.b' => 'b'
+ )),
+ // Ensure that query string values are percent decoded
+ array('q%20a=a%20b', array('q a' => 'a b')),
+ // Ensure null values can be added
+ array('q&a', array('q' => false, 'a' => false)),
+ );
+ }
+
+ /**
+ * @dataProvider parseQueryProvider
+ */
+ public function testParsesQueryStrings($query, $data)
+ {
+ $query = QueryString::fromString($query);
+ $this->assertEquals($data, $query->getAll());
+ }
+
+ public function testProperlyDealsWithDuplicateQueryStringValues()
+ {
+ $query = QueryString::fromString('foo=a&foo=b&?µ=c');
+ $this->assertEquals(array('a', 'b'), $query->get('foo'));
+ $this->assertEquals('c', $query->get('?µ'));
+ }
+
+ public function testAllowsBlankQueryStringValues()
+ {
+ $query = QueryString::fromString('foo');
+ $this->assertEquals('foo', (string) $query);
+ $query->set('foo', QueryString::BLANK);
+ $this->assertEquals('foo', (string) $query);
+ }
+
+ public function testAllowsFalsyQueryStringValues()
+ {
+ $query = QueryString::fromString('0');
+ $this->assertEquals('0', (string) $query);
+ $query->set('0', QueryString::BLANK);
+ $this->assertSame('0', (string) $query);
+ }
+
+ public function testFromStringIgnoresQuestionMark()
+ {
+ $query = QueryString::fromString('foo=baz&bar=boo');
+ $this->assertEquals('foo=baz&bar=boo', (string) $query);
+ }
+
+ public function testConvertsPlusSymbolsToSpaces()
+ {
+ $query = QueryString::fromString('var=foo+bar');
+ $this->assertEquals('foo bar', $query->get('var'));
+ }
+
+ public function testFromStringDoesntMangleZeroes()
+ {
+ $query = QueryString::fromString('var=0');
+ $this->assertSame('0', $query->get('var'));
+ }
+
+ public function testAllowsZeroValues()
+ {
+ $query = new QueryString(array(
+ 'foo' => 0,
+ 'baz' => '0',
+ 'bar' => null,
+ 'boo' => false,
+ 'bam' => ''
+ ));
+ $this->assertEquals('foo=0&baz=0&bar&boo&bam=', (string) $query);
+ }
+
+ public function testFromStringDoesntStripTrailingEquals()
+ {
+ $query = QueryString::fromString('data=mF0b3IiLCJUZWFtIERldiJdfX0=');
+ $this->assertEquals('mF0b3IiLCJUZWFtIERldiJdfX0=', $query->get('data'));
+ }
+
+ public function testGuessesIfDuplicateAggregatorShouldBeUsed()
+ {
+ $query = QueryString::fromString('test=a&test=b');
+ $this->assertEquals('test=a&test=b', (string) $query);
+ }
+
+ public function testGuessesIfDuplicateAggregatorShouldBeUsedAndChecksForPhpStyle()
+ {
+ $query = QueryString::fromString('test[]=a&test[]=b');
+ $this->assertEquals('test%5B0%5D=a&test%5B1%5D=b', (string) $query);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ReadLimitEntityBodyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ReadLimitEntityBodyTest.php
new file mode 100644
index 0000000..6bb3fed
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/ReadLimitEntityBodyTest.php
@@ -0,0 +1,81 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\ReadLimitEntityBody;
+
+/**
+ * @covers Guzzle\Http\ReadLimitEntityBody
+ */
+class ReadLimitEntityBodyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var ReadLimitEntityBody */
+ protected $body;
+
+ /** @var EntityBody */
+ protected $decorated;
+
+ public function setUp()
+ {
+ $this->decorated = EntityBody::factory(fopen(__FILE__, 'r'));
+ $this->body = new ReadLimitEntityBody($this->decorated, 10, 3);
+ }
+
+ public function testReturnsSubsetWhenCastToString()
+ {
+ $body = EntityBody::factory('foo_baz_bar');
+ $limited = new ReadLimitEntityBody($body, 3, 4);
+ $this->assertEquals('baz', (string) $limited);
+ }
+
+ public function testReturnsSubsetOfEmptyBodyWhenCastToString()
+ {
+ $body = EntityBody::factory('');
+ $limited = new ReadLimitEntityBody($body, 0, 10);
+ $this->assertEquals('', (string) $limited);
+ }
+
+ public function testSeeksWhenConstructed()
+ {
+ $this->assertEquals(3, $this->body->ftell());
+ }
+
+ public function testAllowsBoundedSeek()
+ {
+ $this->body->seek(100);
+ $this->assertEquals(13, $this->body->ftell());
+ $this->body->seek(0);
+ $this->assertEquals(3, $this->body->ftell());
+ $this->assertEquals(false, $this->body->seek(1000, SEEK_END));
+ }
+
+ public function testReadsOnlySubsetOfData()
+ {
+ $data = $this->body->read(100);
+ $this->assertEquals(10, strlen($data));
+ $this->assertFalse($this->body->read(1000));
+
+ $this->body->setOffset(10);
+ $newData = $this->body->read(100);
+ $this->assertEquals(10, strlen($newData));
+ $this->assertNotSame($data, $newData);
+ }
+
+ public function testClaimsConsumedWhenReadLimitIsReached()
+ {
+ $this->assertFalse($this->body->isConsumed());
+ $this->body->read(1000);
+ $this->assertTrue($this->body->isConsumed());
+ }
+
+ public function testContentLengthIsBounded()
+ {
+ $this->assertEquals(10, $this->body->getContentLength());
+ }
+
+ public function testContentMd5IsBasedOnSubsection()
+ {
+ $this->assertNotSame($this->body->getContentMd5(), $this->decorated->getContentMd5());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/RedirectPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/RedirectPluginTest.php
new file mode 100755
index 0000000..886236d
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/RedirectPluginTest.php
@@ -0,0 +1,277 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Redirect;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\RedirectPlugin;
+use Guzzle\Http\Exception\TooManyRedirectsException;
+use Guzzle\Plugin\History\HistoryPlugin;
+
+/**
+ * @covers Guzzle\Http\RedirectPlugin
+ */
+class RedirectPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRedirectsRequests()
+ {
+ // Flush the server and queue up a redirect followed by a successful response
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect1\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect2\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ ));
+
+ // Create a client that uses the default redirect behavior
+ $client = new Client($this->getServer()->getUrl());
+ $history = new HistoryPlugin();
+ $client->addSubscriber($history);
+
+ $request = $client->get('/foo');
+ $response = $request->send();
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertContains('/redirect2', $response->getEffectiveUrl());
+
+ // Ensure that two requests were sent
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('/foo', $requests[0]->getResource());
+ $this->assertEquals('GET', $requests[0]->getMethod());
+ $this->assertEquals('/redirect1', $requests[1]->getResource());
+ $this->assertEquals('GET', $requests[1]->getMethod());
+ $this->assertEquals('/redirect2', $requests[2]->getResource());
+ $this->assertEquals('GET', $requests[2]->getMethod());
+
+ // Ensure that the redirect count was incremented
+ $this->assertEquals(2, $request->getParams()->get(RedirectPlugin::REDIRECT_COUNT));
+ $this->assertCount(3, $history);
+ $requestHistory = $history->getAll();
+
+ $this->assertEquals(301, $requestHistory[0]['response']->getStatusCode());
+ $this->assertEquals('/redirect1', (string) $requestHistory[0]['response']->getHeader('Location'));
+ $this->assertEquals(301, $requestHistory[1]['response']->getStatusCode());
+ $this->assertEquals('/redirect2', (string) $requestHistory[1]['response']->getHeader('Location'));
+ $this->assertEquals(200, $requestHistory[2]['response']->getStatusCode());
+ }
+
+ public function testCanLimitNumberOfRedirects()
+ {
+ // Flush the server and queue up a redirect followed by a successful response
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect1\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect2\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect3\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect4\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect5\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect6\r\nContent-Length: 0\r\n\r\n"
+ ));
+
+ try {
+ $client = new Client($this->getServer()->getUrl());
+ $client->get('/foo')->send();
+ $this->fail('Did not throw expected exception');
+ } catch (TooManyRedirectsException $e) {
+ $this->assertContains(
+ "5 redirects were issued for this request:\nGET /foo HTTP/1.1\r\n",
+ $e->getMessage()
+ );
+ }
+ }
+
+ public function testDefaultBehaviorIsToRedirectWithGetForEntityEnclosingRequests()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $client->post('/foo', array('X-Baz' => 'bar'), 'testing')->send();
+
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('POST', $requests[0]->getMethod());
+ $this->assertEquals('GET', $requests[1]->getMethod());
+ $this->assertEquals('bar', (string) $requests[1]->getHeader('X-Baz'));
+ $this->assertEquals('GET', $requests[2]->getMethod());
+ }
+
+ public function testCanRedirectWithStrictRfcCompliance()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->post('/foo', array('X-Baz' => 'bar'), 'testing');
+ $request->getParams()->set(RedirectPlugin::STRICT_REDIRECTS, true);
+ $request->send();
+
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('POST', $requests[0]->getMethod());
+ $this->assertEquals('POST', $requests[1]->getMethod());
+ $this->assertEquals('bar', (string) $requests[1]->getHeader('X-Baz'));
+ $this->assertEquals('POST', $requests[2]->getMethod());
+ }
+
+ public function testRedirect303WithGet()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 303 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->post('/foo');
+ $request->send();
+
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('POST', $requests[0]->getMethod());
+ $this->assertEquals('GET', $requests[1]->getMethod());
+ }
+
+ public function testRedirect303WithGetWithStrictRfcCompliance()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 303 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->post('/foo');
+ $request->getParams()->set(RedirectPlugin::STRICT_REDIRECTS, true);
+ $request->send();
+
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('POST', $requests[0]->getMethod());
+ $this->assertEquals('GET', $requests[1]->getMethod());
+ }
+
+ public function testRewindsStreamWhenRedirectingIfNeeded()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put();
+ $request->configureRedirects(true);
+ $body = EntityBody::factory('foo');
+ $body->read(1);
+ $request->setBody($body);
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('foo', (string) $requests[0]->getBody());
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\CouldNotRewindStreamException
+ */
+ public function testThrowsExceptionWhenStreamCannotBeRewound()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect\r\nContent-Length: 0\r\n\r\n"
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put();
+ $request->configureRedirects(true);
+ $body = EntityBody::factory(fopen($this->getServer()->getUrl(), 'r'));
+ $body->read(1);
+ $request->setBody($body)->send();
+ }
+
+ public function testRedirectsCanBeDisabledPerRequest()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array("HTTP/1.1 301 Foo\r\nLocation: /foo\r\nContent-Length: 0\r\n\r\n"));
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->put();
+ $request->configureRedirects(false, 0);
+ $this->assertEquals(301, $request->send()->getStatusCode());
+ }
+
+ public function testCanRedirectWithNoLeadingSlashAndQuery()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: redirect?foo=bar\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get('?foo=bar');
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals($this->getServer()->getUrl() . '?foo=bar', $requests[0]->getUrl());
+ $this->assertEquals($this->getServer()->getUrl() . 'redirect?foo=bar', $requests[1]->getUrl());
+ // Ensure that the history on the actual request is correct
+ $this->assertEquals($this->getServer()->getUrl() . '?foo=bar', $request->getUrl());
+ }
+
+ public function testRedirectWithStrictRfc386Compliance()
+ {
+ // Flush the server and queue up a redirect followed by a successful response
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: redirect\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get('/foo');
+ $request->send();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('/redirect', $requests[1]->getResource());
+ }
+
+ public function testResetsHistoryEachSend()
+ {
+ // Flush the server and queue up a redirect followed by a successful response
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect1\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect2\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+
+ // Create a client that uses the default redirect behavior
+ $client = new Client($this->getServer()->getUrl());
+ $history = new HistoryPlugin();
+ $client->addSubscriber($history);
+
+ $request = $client->get('/foo');
+ $response = $request->send();
+ $this->assertEquals(3, count($history));
+ $this->assertTrue($request->getParams()->hasKey('redirect.count'));
+ $this->assertContains('/redirect2', $response->getEffectiveUrl());
+
+ $request->send();
+ $this->assertFalse($request->getParams()->hasKey('redirect.count'));
+ }
+
+ public function testHandlesRedirectsWithSpacesProperly()
+ {
+ // Flush the server and queue up a redirect followed by a successful response
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 301 Moved Permanently\r\nLocation: /redirect 1\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->get('/foo');
+ $request->send();
+ $reqs = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('/redirect%201', $reqs[1]->getResource());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Server.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Server.php
new file mode 100644
index 0000000..94eb59a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/Server.php
@@ -0,0 +1,191 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\Exception\BadResponseException;
+use Guzzle\Common\Exception\RuntimeException;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\Client;
+
+/**
+ * The Server class is used to control a scripted webserver using node.js that
+ * will respond to HTTP requests with queued responses.
+ *
+ * Queued responses will be served to requests using a FIFO order. All requests
+ * received by the server are stored on the node.js server and can be retrieved
+ * by calling {@see Server::getReceivedRequests()}.
+ *
+ * Mock responses that don't require data to be transmitted over HTTP a great
+ * for testing. Mock response, however, cannot test the actual sending of an
+ * HTTP request using cURL. This test server allows the simulation of any
+ * number of HTTP request response transactions to test the actual sending of
+ * requests over the wire without having to leave an internal network.
+ */
+class Server
+{
+ const DEFAULT_PORT = 8124;
+ const REQUEST_DELIMITER = "\n----[request]\n";
+
+ /** @var int Port that the server will listen on */
+ private $port;
+
+ /** @var bool Is the server running */
+ private $running = false;
+
+ /** @var Client */
+ private $client;
+
+ /**
+ * Create a new scripted server
+ *
+ * @param int $port Port to listen on (defaults to 8124)
+ */
+ public function __construct($port = null)
+ {
+ $this->port = $port ?: self::DEFAULT_PORT;
+ $this->client = new Client($this->getUrl());
+ register_shutdown_function(array($this, 'stop'));
+ }
+
+ /**
+ * Flush the received requests from the server
+ * @throws RuntimeException
+ */
+ public function flush()
+ {
+ $this->client->delete('guzzle-server/requests')->send();
+ }
+
+ /**
+ * Queue an array of responses or a single response on the server.
+ *
+ * Any currently queued responses will be overwritten. Subsequent requests
+ * on the server will return queued responses in FIFO order.
+ *
+ * @param array|Response $responses A single or array of Responses to queue
+ * @throws BadResponseException
+ */
+ public function enqueue($responses)
+ {
+ $data = array();
+ foreach ((array) $responses as $response) {
+
+ // Create the response object from a string
+ if (is_string($response)) {
+ $response = Response::fromMessage($response);
+ } elseif (!($response instanceof Response)) {
+ throw new BadResponseException('Responses must be strings or implement Response');
+ }
+
+ $data[] = array(
+ 'statusCode' => $response->getStatusCode(),
+ 'reasonPhrase' => $response->getReasonPhrase(),
+ 'headers' => $response->getHeaders()->toArray(),
+ 'body' => $response->getBody(true)
+ );
+ }
+
+ $request = $this->client->put('guzzle-server/responses', null, json_encode($data));
+ $request->send();
+ }
+
+ /**
+ * Check if the server is running
+ *
+ * @return bool
+ */
+ public function isRunning()
+ {
+ if ($this->running) {
+ return true;
+ }
+
+ try {
+ $this->client->get('guzzle-server/perf', array(), array('timeout' => 5))->send();
+ $this->running = true;
+ return true;
+ } catch (\Exception $e) {
+ return false;
+ }
+ }
+
+ /**
+ * Get the URL to the server
+ *
+ * @return string
+ */
+ public function getUrl()
+ {
+ return 'http://127.0.0.1:' . $this->getPort() . '/';
+ }
+
+ /**
+ * Get the port that the server is listening on
+ *
+ * @return int
+ */
+ public function getPort()
+ {
+ return $this->port;
+ }
+
+ /**
+ * Get all of the received requests
+ *
+ * @param bool $hydrate Set to TRUE to turn the messages into
+ * actual {@see RequestInterface} objects. If $hydrate is FALSE,
+ * requests will be returned as strings.
+ *
+ * @return array
+ * @throws RuntimeException
+ */
+ public function getReceivedRequests($hydrate = false)
+ {
+ $response = $this->client->get('guzzle-server/requests')->send();
+ $data = array_filter(explode(self::REQUEST_DELIMITER, $response->getBody(true)));
+ if ($hydrate) {
+ $data = array_map(function($message) {
+ return RequestFactory::getInstance()->fromMessage($message);
+ }, $data);
+ }
+
+ return $data;
+ }
+
+ /**
+ * Start running the node.js server in the background
+ */
+ public function start()
+ {
+ if (!$this->isRunning()) {
+ exec('node ' . __DIR__ . \DIRECTORY_SEPARATOR
+ . 'server.js ' . $this->port
+ . ' >> /tmp/server.log 2>&1 &');
+ // Wait at most 5 seconds for the server the setup before
+ // proceeding.
+ $start = time();
+ while (!$this->isRunning() && time() - $start < 5);
+ if (!$this->running) {
+ throw new RuntimeException(
+ 'Unable to contact server.js. Have you installed node.js v0.5.0+? node must be in your path.'
+ );
+ }
+ }
+ }
+
+ /**
+ * Stop running the node.js server
+ */
+ public function stop()
+ {
+ if (!$this->isRunning()) {
+ return false;
+ }
+
+ $this->running = false;
+ $this->client->delete('guzzle-server')->send();
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/StaticClientTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/StaticClientTest.php
new file mode 100644
index 0000000..091314b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/StaticClientTest.php
@@ -0,0 +1,67 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Redirect;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\StaticClient;
+use Guzzle\Plugin\Mock\MockPlugin;
+use Guzzle\Http\Message\Response;
+use Guzzle\Stream\Stream;
+
+/**
+ * @covers Guzzle\Http\StaticClient
+ */
+class StaticClientTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testMountsClient()
+ {
+ $client = new Client();
+ StaticClient::mount('FooBazBar', $client);
+ $this->assertTrue(class_exists('FooBazBar'));
+ $this->assertSame($client, $this->readAttribute('Guzzle\Http\StaticClient', 'client'));
+ }
+
+ public function requestProvider()
+ {
+ return array_map(
+ function ($m) { return array($m); },
+ array('GET', 'POST', 'PUT', 'DELETE', 'PATCH', 'HEAD', 'OPTIONS')
+ );
+ }
+
+ /**
+ * @dataProvider requestProvider
+ */
+ public function testSendsRequests($method)
+ {
+ $mock = new MockPlugin(array(new Response(200)));
+ call_user_func('Guzzle\Http\StaticClient::' . $method, 'http://foo.com', array(
+ 'plugins' => array($mock)
+ ));
+ $requests = $mock->getReceivedRequests();
+ $this->assertCount(1, $requests);
+ $this->assertEquals($method, $requests[0]->getMethod());
+ }
+
+ public function testCanCreateStreamsUsingDefaultFactory()
+ {
+ $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest"));
+ $stream = StaticClient::get($this->getServer()->getUrl(), array('stream' => true));
+ $this->assertInstanceOf('Guzzle\Stream\StreamInterface', $stream);
+ $this->assertEquals('test', (string) $stream);
+ }
+
+ public function testCanCreateStreamsUsingCustomFactory()
+ {
+ $stream = $this->getMockBuilder('Guzzle\Stream\StreamRequestFactoryInterface')
+ ->setMethods(array('fromRequest'))
+ ->getMockForAbstractClass();
+ $resource = new Stream(fopen('php://temp', 'r+'));
+ $stream->expects($this->once())
+ ->method('fromRequest')
+ ->will($this->returnValue($resource));
+ $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ntest"));
+ $result = StaticClient::get($this->getServer()->getUrl(), array('stream' => $stream));
+ $this->assertSame($resource, $result);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/UrlTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/UrlTest.php
new file mode 100644
index 0000000..28f2671
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/UrlTest.php
@@ -0,0 +1,303 @@
+<?php
+
+namespace Guzzle\Tests\Http;
+
+use Guzzle\Http\QueryString;
+use Guzzle\Http\Url;
+
+/**
+ * @covers Guzzle\Http\Url
+ */
+class UrlTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testEmptyUrl()
+ {
+ $url = Url::factory('');
+ $this->assertEquals('', (string) $url);
+ }
+
+ public function testPortIsDeterminedFromScheme()
+ {
+ $this->assertEquals(80, Url::factory('http://www.test.com/')->getPort());
+ $this->assertEquals(443, Url::factory('https://www.test.com/')->getPort());
+ $this->assertEquals(null, Url::factory('ftp://www.test.com/')->getPort());
+ $this->assertEquals(8192, Url::factory('http://www.test.com:8192/')->getPort());
+ }
+
+ public function testCloneCreatesNewInternalObjects()
+ {
+ $u1 = Url::factory('http://www.test.com/');
+ $u2 = clone $u1;
+ $this->assertNotSame($u1->getQuery(), $u2->getQuery());
+ }
+
+ public function testValidatesUrlPartsInFactory()
+ {
+ $url = Url::factory('/index.php');
+ $this->assertEquals('/index.php', (string) $url);
+ $this->assertFalse($url->isAbsolute());
+
+ $url = 'http://michael:test@test.com:80/path/123?q=abc#test';
+ $u = Url::factory($url);
+ $this->assertEquals('http://michael:test@test.com/path/123?q=abc#test', (string) $u);
+ $this->assertTrue($u->isAbsolute());
+ }
+
+ public function testAllowsFalsyUrlParts()
+ {
+ $url = Url::factory('http://0:50/0?0#0');
+ $this->assertSame('0', $url->getHost());
+ $this->assertEquals(50, $url->getPort());
+ $this->assertSame('/0', $url->getPath());
+ $this->assertEquals('0', (string) $url->getQuery());
+ $this->assertSame('0', $url->getFragment());
+ $this->assertEquals('http://0:50/0?0#0', (string) $url);
+
+ $url = Url::factory('');
+ $this->assertSame('', (string) $url);
+
+ $url = Url::factory('0');
+ $this->assertSame('0', (string) $url);
+ }
+
+ public function testBuildsRelativeUrlsWithFalsyParts()
+ {
+ $url = Url::buildUrl(array(
+ 'host' => '0',
+ 'path' => '0',
+ ));
+
+ $this->assertSame('//0/0', $url);
+
+ $url = Url::buildUrl(array(
+ 'path' => '0',
+ ));
+ $this->assertSame('0', $url);
+ }
+
+ public function testUrlStoresParts()
+ {
+ $url = Url::factory('http://test:pass@www.test.com:8081/path/path2/?a=1&b=2#fragment');
+ $this->assertEquals('http', $url->getScheme());
+ $this->assertEquals('test', $url->getUsername());
+ $this->assertEquals('pass', $url->getPassword());
+ $this->assertEquals('www.test.com', $url->getHost());
+ $this->assertEquals(8081, $url->getPort());
+ $this->assertEquals('/path/path2/', $url->getPath());
+ $this->assertEquals('fragment', $url->getFragment());
+ $this->assertEquals('a=1&b=2', (string) $url->getQuery());
+
+ $this->assertEquals(array(
+ 'fragment' => 'fragment',
+ 'host' => 'www.test.com',
+ 'pass' => 'pass',
+ 'path' => '/path/path2/',
+ 'port' => 8081,
+ 'query' => 'a=1&b=2',
+ 'scheme' => 'http',
+ 'user' => 'test'
+ ), $url->getParts());
+ }
+
+ public function testHandlesPathsCorrectly()
+ {
+ $url = Url::factory('http://www.test.com');
+ $this->assertEquals('', $url->getPath());
+ $url->setPath('test');
+ $this->assertEquals('test', $url->getPath());
+
+ $url->setPath('/test/123/abc');
+ $this->assertEquals(array('test', '123', 'abc'), $url->getPathSegments());
+
+ $parts = parse_url('http://www.test.com/test');
+ $parts['path'] = '';
+ $this->assertEquals('http://www.test.com', Url::buildUrl($parts));
+ $parts['path'] = 'test';
+ $this->assertEquals('http://www.test.com/test', Url::buildUrl($parts));
+ }
+
+ public function testAddsQueryStringIfPresent()
+ {
+ $this->assertEquals('?foo=bar', Url::buildUrl(array(
+ 'query' => 'foo=bar'
+ )));
+ }
+
+ public function testAddsToPath()
+ {
+ // Does nothing here
+ $this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(false));
+ $this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(null));
+ $this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(array()));
+ $this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(new \stdClass()));
+ $this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath(''));
+ $this->assertEquals('http://e.com/base?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath('/'));
+ $this->assertEquals('http://e.com/baz/foo', (string) Url::factory('http://e.com/baz/')->addPath('foo'));
+ $this->assertEquals('http://e.com/base/relative?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath('relative'));
+ $this->assertEquals('http://e.com/base/relative?a=1', (string) Url::factory('http://e.com/base?a=1')->addPath('/relative'));
+ $this->assertEquals('http://e.com/base/0', (string) Url::factory('http://e.com/base')->addPath('0'));
+ $this->assertEquals('http://e.com/base/0/1', (string) Url::factory('http://e.com/base')->addPath('0')->addPath('1'));
+ }
+
+ /**
+ * URL combination data provider
+ *
+ * @return array
+ */
+ public function urlCombineDataProvider()
+ {
+ return array(
+ array('http://www.example.com/', 'http://www.example.com/', 'http://www.example.com/'),
+ array('http://www.example.com/path', '/absolute', 'http://www.example.com/absolute'),
+ array('http://www.example.com/path', '/absolute?q=2', 'http://www.example.com/absolute?q=2'),
+ array('http://www.example.com/path', 'more', 'http://www.example.com/path/more'),
+ array('http://www.example.com/path', 'more?q=1', 'http://www.example.com/path/more?q=1'),
+ array('http://www.example.com/', '?q=1', 'http://www.example.com/?q=1'),
+ array('http://www.example.com/path', 'http://test.com', 'http://test.com'),
+ array('http://www.example.com:8080/path', 'http://test.com', 'http://test.com'),
+ array('http://www.example.com:8080/path', '?q=2#abc', 'http://www.example.com:8080/path?q=2#abc'),
+ array('http://u:a@www.example.com/path', 'test', 'http://u:a@www.example.com/path/test'),
+ array('http://www.example.com/path', 'http://u:a@www.example.com/', 'http://u:a@www.example.com/'),
+ array('/path?q=2', 'http://www.test.com/', 'http://www.test.com/path?q=2'),
+ array('http://api.flickr.com/services/', 'http://www.flickr.com/services/oauth/access_token', 'http://www.flickr.com/services/oauth/access_token'),
+ array('http://www.example.com/?foo=bar', 'some/path', 'http://www.example.com/some/path?foo=bar'),
+ array('http://www.example.com/?foo=bar', 'some/path?boo=moo', 'http://www.example.com/some/path?boo=moo&foo=bar'),
+ array('http://www.example.com/some/', 'path?foo=bar&foo=baz', 'http://www.example.com/some/path?foo=bar&foo=baz'),
+ );
+ }
+
+ /**
+ * @dataProvider urlCombineDataProvider
+ */
+ public function testCombinesUrls($a, $b, $c)
+ {
+ $this->assertEquals($c, (string) Url::factory($a)->combine($b));
+ }
+
+ public function testHasGettersAndSetters()
+ {
+ $url = Url::factory('http://www.test.com/');
+ $this->assertEquals('example.com', $url->setHost('example.com')->getHost());
+ $this->assertEquals('8080', $url->setPort(8080)->getPort());
+ $this->assertEquals('/foo/bar', $url->setPath(array('foo', 'bar'))->getPath());
+ $this->assertEquals('a', $url->setPassword('a')->getPassword());
+ $this->assertEquals('b', $url->setUsername('b')->getUsername());
+ $this->assertEquals('abc', $url->setFragment('abc')->getFragment());
+ $this->assertEquals('https', $url->setScheme('https')->getScheme());
+ $this->assertEquals('a=123', (string) $url->setQuery('a=123')->getQuery());
+ $this->assertEquals('https://b:a@example.com:8080/foo/bar?a=123#abc', (string) $url);
+ $this->assertEquals('b=boo', (string) $url->setQuery(new QueryString(array(
+ 'b' => 'boo'
+ )))->getQuery());
+ $this->assertEquals('https://b:a@example.com:8080/foo/bar?b=boo#abc', (string) $url);
+ }
+
+ public function testSetQueryAcceptsArray()
+ {
+ $url = Url::factory('http://www.test.com');
+ $url->setQuery(array('a' => 'b'));
+ $this->assertEquals('http://www.test.com?a=b', (string) $url);
+ }
+
+ public function urlProvider()
+ {
+ return array(
+ array('/foo/..', '/'),
+ array('//foo//..', '/'),
+ array('/foo/../..', '/'),
+ array('/foo/../.', '/'),
+ array('/./foo/..', '/'),
+ array('/./foo', '/foo'),
+ array('/./foo/', '/foo/'),
+ array('/./foo/bar/baz/pho/../..', '/foo/bar'),
+ array('*', '*'),
+ array('/foo', '/foo'),
+ array('/abc/123/../foo/', '/abc/foo/'),
+ array('/a/b/c/./../../g', '/a/g'),
+ array('/b/c/./../../g', '/g'),
+ array('/b/c/./../../g', '/g'),
+ array('/c/./../../g', '/g'),
+ array('/./../../g', '/g'),
+ );
+ }
+
+ /**
+ * @dataProvider urlProvider
+ */
+ public function testNormalizesPaths($path, $result)
+ {
+ $url = Url::factory('http://www.example.com/');
+ $url->setPath($path)->normalizePath();
+ $this->assertEquals($result, $url->getPath());
+ }
+
+ public function testSettingHostWithPortModifiesPort()
+ {
+ $url = Url::factory('http://www.example.com');
+ $url->setHost('foo:8983');
+ $this->assertEquals('foo', $url->getHost());
+ $this->assertEquals(8983, $url->getPort());
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testValidatesUrlCanBeParsed()
+ {
+ Url::factory('foo:////');
+ }
+
+ public function testConvertsSpecialCharsInPathWhenCastingToString()
+ {
+ $url = Url::factory('http://foo.com/baz bar?a=b');
+ $url->addPath('?');
+ $this->assertEquals('http://foo.com/baz%20bar/%3F?a=b', (string) $url);
+ }
+
+ /**
+ * @link http://tools.ietf.org/html/rfc3986#section-5.4.1
+ */
+ public function rfc3986UrlProvider()
+ {
+ $result = array(
+ array('g', 'http://a/b/c/g'),
+ array('./g', 'http://a/b/c/g'),
+ array('g/', 'http://a/b/c/g/'),
+ array('/g', 'http://a/g'),
+ array('?y', 'http://a/b/c/d;p?y'),
+ array('g?y', 'http://a/b/c/g?y'),
+ array('#s', 'http://a/b/c/d;p?q#s'),
+ array('g#s', 'http://a/b/c/g#s'),
+ array('g?y#s', 'http://a/b/c/g?y#s'),
+ array(';x', 'http://a/b/c/;x'),
+ array('g;x', 'http://a/b/c/g;x'),
+ array('g;x?y#s', 'http://a/b/c/g;x?y#s'),
+ array('', 'http://a/b/c/d;p?q'),
+ array('.', 'http://a/b/c'),
+ array('./', 'http://a/b/c/'),
+ array('..', 'http://a/b'),
+ array('../', 'http://a/b/'),
+ array('../g', 'http://a/b/g'),
+ array('../..', 'http://a/'),
+ array('../../', 'http://a/'),
+ array('../../g', 'http://a/g')
+ );
+
+ // This support was added in PHP 5.4.7: https://bugs.php.net/bug.php?id=62844
+ if (version_compare(PHP_VERSION, '5.4.7', '>=')) {
+ $result[] = array('//g', 'http://g');
+ }
+
+ return $result;
+ }
+
+ /**
+ * @dataProvider rfc3986UrlProvider
+ */
+ public function testCombinesUrlsUsingRfc3986($relative, $result)
+ {
+ $a = Url::factory('http://a/b/c/d;p?q');
+ $b = Url::factory($relative);
+ $this->assertEquals($result, trim((string) $a->combine($b, true), '='));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/server.js b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/server.js
new file mode 100644
index 0000000..4156f1a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Http/server.js
@@ -0,0 +1,146 @@
+/**
+ * Guzzle node.js test server to return queued responses to HTTP requests and
+ * expose a RESTful API for enqueueing responses and retrieving the requests
+ * that have been received.
+ *
+ * - Delete all requests that have been received:
+ * DELETE /guzzle-server/requests
+ * Host: 127.0.0.1:8124
+ *
+ * - Enqueue responses
+ * PUT /guzzle-server/responses
+ * Host: 127.0.0.1:8124
+ *
+ * [{ "statusCode": 200, "reasonPhrase": "OK", "headers": {}, "body": "" }]
+ *
+ * - Get the received requests
+ * GET /guzzle-server/requests
+ * Host: 127.0.0.1:8124
+ *
+ * - Shutdown the server
+ * DELETE /guzzle-server
+ * Host: 127.0.0.1:8124
+ *
+ * @package Guzzle PHP <http://www.guzzlephp.org>
+ * @license See the LICENSE file that was distributed with this source code.
+ */
+
+var http = require("http");
+
+/**
+ * Guzzle node.js server
+ * @class
+ */
+var GuzzleServer = function(port, log) {
+
+ this.port = port;
+ this.log = log;
+ this.responses = [];
+ this.requests = [];
+ var that = this;
+
+ var controlRequest = function(request, req, res) {
+ if (req.url == '/guzzle-server/perf') {
+ res.writeHead(200, "OK", {"Content-Length": 16});
+ res.end("Body of response");
+ } else if (req.method == "DELETE") {
+ if (req.url == "/guzzle-server/requests") {
+ // Clear the received requests
+ that.requests = [];
+ res.writeHead(200, "OK", { "Content-Length": 0 });
+ res.end();
+ if (this.log) {
+ console.log("Flushing requests");
+ }
+ } else if (req.url == "/guzzle-server") {
+ // Shutdown the server
+ res.writeHead(200, "OK", { "Content-Length": 0, "Connection": "close" });
+ res.end();
+ if (this.log) {
+ console.log("Shutting down");
+ }
+ that.server.close();
+ }
+ } else if (req.method == "GET") {
+ if (req.url === "/guzzle-server/requests") {
+ // Get received requests
+ var data = that.requests.join("\n----[request]\n");
+ res.writeHead(200, "OK", { "Content-Length": data.length });
+ res.end(data);
+ if (that.log) {
+ console.log("Sending receiving requests");
+ }
+ }
+ } else if (req.method == "PUT") {
+ if (req.url == "/guzzle-server/responses") {
+ if (that.log) {
+ console.log("Adding responses...");
+ }
+ // Received response to queue
+ var data = request.split("\r\n\r\n")[1];
+ if (!data) {
+ if (that.log) {
+ console.log("No response data was provided");
+ }
+ res.writeHead(400, "NO RESPONSES IN REQUEST", { "Content-Length": 0 });
+ } else {
+ that.responses = eval("(" + data + ")");
+ if (that.log) {
+ console.log(that.responses);
+ }
+ res.writeHead(200, "OK", { "Content-Length": 0 });
+ }
+ res.end();
+ }
+ }
+ };
+
+ var receivedRequest = function(request, req, res) {
+ if (req.url.indexOf("/guzzle-server") === 0) {
+ controlRequest(request, req, res);
+ } else if (req.url.indexOf("/guzzle-server") == -1 && !that.responses.length) {
+ res.writeHead(500);
+ res.end("No responses in queue");
+ } else {
+ var response = that.responses.shift();
+ res.writeHead(response.statusCode, response.reasonPhrase, response.headers);
+ res.end(response.body);
+ that.requests.push(request);
+ }
+ };
+
+ this.start = function() {
+
+ that.server = http.createServer(function(req, res) {
+
+ var request = req.method + " " + req.url + " HTTP/" + req.httpVersion + "\r\n";
+ for (var i in req.headers) {
+ request += i + ": " + req.headers[i] + "\r\n";
+ }
+ request += "\r\n";
+
+ // Receive each chunk of the request body
+ req.addListener("data", function(chunk) {
+ request += chunk;
+ });
+
+ // Called when the request completes
+ req.addListener("end", function() {
+ receivedRequest(request, req, res);
+ });
+ });
+ that.server.listen(port, "127.0.0.1");
+
+ if (this.log) {
+ console.log("Server running at http://127.0.0.1:8124/");
+ }
+ };
+};
+
+// Get the port from the arguments
+port = process.argv.length >= 3 ? process.argv[2] : 8124;
+log = process.argv.length >= 4 ? process.argv[3] : false;
+
+// Start the server
+server = new GuzzleServer(port, log);
+server.start();
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/InflectorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/InflectorTest.php
new file mode 100644
index 0000000..990c0af
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/InflectorTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Guzzle\Tests\Inflection;
+
+use Guzzle\Inflection\Inflector;
+
+/**
+ * @covers Guzzle\Inflection\Inflector
+ */
+class InflectorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testReturnsDefaultInstance()
+ {
+ $this->assertSame(Inflector::getDefault(), Inflector::getDefault());
+ }
+
+ public function testSnake()
+ {
+ $this->assertEquals('camel_case', Inflector::getDefault()->snake('camelCase'));
+ $this->assertEquals('camel_case', Inflector::getDefault()->snake('CamelCase'));
+ $this->assertEquals('camel_case_words', Inflector::getDefault()->snake('CamelCaseWords'));
+ $this->assertEquals('camel_case_words', Inflector::getDefault()->snake('CamelCase_words'));
+ $this->assertEquals('test', Inflector::getDefault()->snake('test'));
+ $this->assertEquals('test', Inflector::getDefault()->snake('test'));
+ $this->assertEquals('expect100_continue', Inflector::getDefault()->snake('Expect100Continue'));
+ }
+
+ public function testCamel()
+ {
+ $this->assertEquals('CamelCase', Inflector::getDefault()->camel('camel_case'));
+ $this->assertEquals('CamelCaseWords', Inflector::getDefault()->camel('camel_case_words'));
+ $this->assertEquals('Test', Inflector::getDefault()->camel('test'));
+ $this->assertEquals('Expect100Continue', ucfirst(Inflector::getDefault()->camel('expect100_continue')));
+ // Get from cache
+ $this->assertEquals('Test', Inflector::getDefault()->camel('test', false));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/MemoizingInflectorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/MemoizingInflectorTest.php
new file mode 100644
index 0000000..f00b7fa
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/MemoizingInflectorTest.php
@@ -0,0 +1,46 @@
+<?php
+
+namespace Guzzle\Tests\Inflection;
+
+use Guzzle\Inflection\MemoizingInflector;
+use Guzzle\Inflection\Inflector;
+
+/**
+ * @covers Guzzle\Inflection\MemoizingInflector
+ */
+class MemoizingInflectorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testUsesCache()
+ {
+ $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
+ $mock->expects($this->once())->method('snake')->will($this->returnValue('foo_bar'));
+ $mock->expects($this->once())->method('camel')->will($this->returnValue('FooBar'));
+
+ $inflector = new MemoizingInflector($mock);
+ $this->assertEquals('foo_bar', $inflector->snake('FooBar'));
+ $this->assertEquals('foo_bar', $inflector->snake('FooBar'));
+ $this->assertEquals('FooBar', $inflector->camel('foo_bar'));
+ $this->assertEquals('FooBar', $inflector->camel('foo_bar'));
+ }
+
+ public function testProtectsAgainstCacheOverflow()
+ {
+ $inflector = new MemoizingInflector(new Inflector(), 10);
+ for ($i = 1; $i < 11; $i++) {
+ $inflector->camel('foo_' . $i);
+ $inflector->snake('Foo' . $i);
+ }
+
+ $cache = $this->readAttribute($inflector, 'cache');
+ $this->assertEquals(10, count($cache['snake']));
+ $this->assertEquals(10, count($cache['camel']));
+
+ $inflector->camel('baz!');
+ $inflector->snake('baz!');
+
+ // Now ensure that 20% of the cache was removed (2), then the item was added
+ $cache = $this->readAttribute($inflector, 'cache');
+ $this->assertEquals(9, count($cache['snake']));
+ $this->assertEquals(9, count($cache['camel']));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php
new file mode 100644
index 0000000..ff2654c
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Inflection/PreComputedInflectorTest.php
@@ -0,0 +1,45 @@
+<?php
+
+namespace Guzzle\Tests\Inflection;
+
+use Guzzle\Inflection\PreComputedInflector;
+
+/**
+ * @covers Guzzle\Inflection\PreComputedInflector
+ */
+class PreComputedInflectorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testUsesPreComputedHash()
+ {
+ $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
+ $mock->expects($this->once())->method('snake')->with('Test')->will($this->returnValue('test'));
+ $mock->expects($this->once())->method('camel')->with('Test')->will($this->returnValue('Test'));
+ $inflector = new PreComputedInflector($mock, array('FooBar' => 'foo_bar'), array('foo_bar' => 'FooBar'));
+ $this->assertEquals('FooBar', $inflector->camel('foo_bar'));
+ $this->assertEquals('foo_bar', $inflector->snake('FooBar'));
+ $this->assertEquals('Test', $inflector->camel('Test'));
+ $this->assertEquals('test', $inflector->snake('Test'));
+ }
+
+ public function testMirrorsPrecomputedValues()
+ {
+ $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
+ $mock->expects($this->never())->method('snake');
+ $mock->expects($this->never())->method('camel');
+ $inflector = new PreComputedInflector($mock, array('Zeep' => 'zeep'), array(), true);
+ $this->assertEquals('Zeep', $inflector->camel('zeep'));
+ $this->assertEquals('zeep', $inflector->snake('Zeep'));
+ }
+
+ public function testMirrorsPrecomputedValuesByMerging()
+ {
+ $mock = $this->getMock('Guzzle\Inflection\Inflector', array('snake', 'camel'));
+ $mock->expects($this->never())->method('snake');
+ $mock->expects($this->never())->method('camel');
+ $inflector = new PreComputedInflector($mock, array('Zeep' => 'zeep'), array('foo' => 'Foo'), true);
+ $this->assertEquals('Zeep', $inflector->camel('zeep'));
+ $this->assertEquals('zeep', $inflector->snake('Zeep'));
+ $this->assertEquals('Foo', $inflector->camel('foo'));
+ $this->assertEquals('foo', $inflector->snake('Foo'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/AppendIteratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/AppendIteratorTest.php
new file mode 100644
index 0000000..8d6ae84
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/AppendIteratorTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Guzzle\Tests\Iterator;
+
+use Guzzle\Iterator\AppendIterator;
+
+/**
+ * @covers Guzzle\Iterator\AppendIterator
+ */
+class AppendIteratorTest extends \PHPUnit_Framework_TestCase
+{
+ public function testTraversesIteratorsInOrder()
+ {
+ $a = new \ArrayIterator(array(
+ 'a' => 1,
+ 'b' => 2
+ ));
+ $b = new \ArrayIterator(array());
+ $c = new \ArrayIterator(array(
+ 'c' => 3,
+ 'd' => 4
+ ));
+ $i = new AppendIterator();
+ $i->append($a);
+ $i->append($b);
+ $i->append($c);
+ $this->assertEquals(array(1, 2, 3, 4), iterator_to_array($i, false));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/ChunkedIteratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/ChunkedIteratorTest.php
new file mode 100644
index 0000000..ec4c129
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/ChunkedIteratorTest.php
@@ -0,0 +1,52 @@
+<?php
+
+namespace Guzzle\Tests\Iterator;
+
+use Guzzle\Iterator\ChunkedIterator;
+
+/**
+ * @covers Guzzle\Iterator\ChunkedIterator
+ */
+class ChunkedIteratorTest extends \PHPUnit_Framework_TestCase
+{
+ public function testChunksIterator()
+ {
+ $chunked = new ChunkedIterator(new \ArrayIterator(range(0, 100)), 10);
+ $chunks = iterator_to_array($chunked, false);
+ $this->assertEquals(11, count($chunks));
+ foreach ($chunks as $j => $chunk) {
+ $this->assertEquals(range($j * 10, min(100, $j * 10 + 9)), $chunk);
+ }
+ }
+
+ public function testChunksIteratorWithOddValues()
+ {
+ $chunked = new ChunkedIterator(new \ArrayIterator(array(1, 2, 3, 4, 5)), 2);
+ $chunks = iterator_to_array($chunked, false);
+ $this->assertEquals(3, count($chunks));
+ $this->assertEquals(array(1, 2), $chunks[0]);
+ $this->assertEquals(array(3, 4), $chunks[1]);
+ $this->assertEquals(array(5), $chunks[2]);
+ }
+
+ public function testMustNotTerminateWithTraversable()
+ {
+ $traversable = simplexml_load_string('<root><foo/><foo/><foo/></root>')->foo;
+ $chunked = new ChunkedIterator($traversable, 2);
+ $actual = iterator_to_array($chunked, false);
+ $this->assertCount(2, $actual);
+ }
+
+ public function testSizeOfZeroMakesIteratorInvalid() {
+ $chunked = new ChunkedIterator(new \ArrayIterator(range(1, 5)), 0);
+ $chunked->rewind();
+ $this->assertFalse($chunked->valid());
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testSizeLowerZeroThrowsException() {
+ new ChunkedIterator(new \ArrayIterator(range(1, 5)), -1);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/FilterIteratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/FilterIteratorTest.php
new file mode 100644
index 0000000..73b4f69
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/FilterIteratorTest.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Guzzle\Tests\Iterator;
+
+use Guzzle\Iterator\FilterIterator;
+
+/**
+ * @covers Guzzle\Iterator\FilterIterator
+ */
+class FilterIteratorTest extends \PHPUnit_Framework_TestCase
+{
+ public function testFiltersValues()
+ {
+ $i = new FilterIterator(new \ArrayIterator(range(0, 100)), function ($value) {
+ return $value % 2;
+ });
+
+ $this->assertEquals(range(1, 99, 2), iterator_to_array($i, false));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testValidatesCallable()
+ {
+ $i = new FilterIterator(new \ArrayIterator(), new \stdClass());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MapIteratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MapIteratorTest.php
new file mode 100644
index 0000000..4de4a6b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MapIteratorTest.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Guzzle\Tests\Iterator;
+
+use Guzzle\Iterator\MapIterator;
+
+/**
+ * @covers Guzzle\Iterator\MapIterator
+ */
+class MapIteratorTest extends \PHPUnit_Framework_TestCase
+{
+ public function testFiltersValues()
+ {
+ $i = new MapIterator(new \ArrayIterator(range(0, 100)), function ($value) {
+ return $value * 10;
+ });
+
+ $this->assertEquals(range(0, 1000, 10), iterator_to_array($i, false));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testValidatesCallable()
+ {
+ $i = new MapIterator(new \ArrayIterator(), new \stdClass());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MethodProxyIteratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MethodProxyIteratorTest.php
new file mode 100644
index 0000000..5bcf06f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Iterator/MethodProxyIteratorTest.php
@@ -0,0 +1,28 @@
+<?php
+
+namespace Guzzle\Tests\Iterator;
+
+use Guzzle\Iterator\MethodProxyIterator;
+use Guzzle\Iterator\ChunkedIterator;
+
+/**
+ * @covers Guzzle\Iterator\MethodProxyIterator
+ */
+class MethodProxyIteratorTest extends \PHPUnit_Framework_TestCase
+{
+ public function testProxiesMagicCallsToInnermostIterator()
+ {
+ $i = new \ArrayIterator();
+ $proxy = new MethodProxyIterator(new MethodProxyIterator(new MethodProxyIterator($i)));
+ $proxy->append('a');
+ $proxy->append('b');
+ $this->assertEquals(array('a', 'b'), $i->getArrayCopy());
+ $this->assertEquals(array('a', 'b'), $proxy->getArrayCopy());
+ }
+
+ public function testUsesInnerIterator()
+ {
+ $i = new MethodProxyIterator(new ChunkedIterator(new \ArrayIterator(array(1, 2, 3, 4, 5)), 2));
+ $this->assertEquals(3, count(iterator_to_array($i, false)));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ArrayLogAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ArrayLogAdapterTest.php
new file mode 100644
index 0000000..a66882f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ArrayLogAdapterTest.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace Guzzle\Tests\Log;
+
+use Guzzle\Log\ArrayLogAdapter;
+
+class ArrayLogAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testLog()
+ {
+ $adapter = new ArrayLogAdapter();
+ $adapter->log('test', \LOG_NOTICE, '127.0.0.1');
+ $this->assertEquals(array(array('message' => 'test', 'priority' => \LOG_NOTICE, 'extras' => '127.0.0.1')), $adapter->getLogs());
+ }
+
+ public function testClearLog()
+ {
+ $adapter = new ArrayLogAdapter();
+ $adapter->log('test', \LOG_NOTICE, '127.0.0.1');
+ $adapter->clearLogs();
+ $this->assertEquals(array(), $adapter->getLogs());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ClosureLogAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ClosureLogAdapterTest.php
new file mode 100644
index 0000000..0177dc0
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/ClosureLogAdapterTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Guzzle\Tests\Log;
+
+use Guzzle\Log\ClosureLogAdapter;
+
+/**
+ * @covers Guzzle\Log\ClosureLogAdapter
+ */
+class ClosureLogAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testClosure()
+ {
+ $that = $this;
+ $modified = null;
+ $this->adapter = new ClosureLogAdapter(function($message, $priority, $extras = null) use ($that, &$modified) {
+ $modified = array($message, $priority, $extras);
+ });
+ $this->adapter->log('test', LOG_NOTICE, '127.0.0.1');
+ $this->assertEquals(array('test', LOG_NOTICE, '127.0.0.1'), $modified);
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testThrowsExceptionWhenNotCallable()
+ {
+ $this->adapter = new ClosureLogAdapter(123);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/MessageFormatterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/MessageFormatterTest.php
new file mode 100644
index 0000000..3ff4b07
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/MessageFormatterTest.php
@@ -0,0 +1,143 @@
+<?php
+
+namespace Guzzle\Tests\Log;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\Curl\CurlHandle;
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Message\Response;
+use Guzzle\Log\MessageFormatter;
+use Guzzle\Plugin\Log\LogPlugin;
+use Guzzle\Log\ClosureLogAdapter;
+
+/**
+ * @covers Guzzle\Log\MessageFormatter
+ */
+class MessageFormatterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $request;
+ protected $response;
+ protected $handle;
+
+ public function setUp()
+ {
+ $this->request = new EntityEnclosingRequest('POST', 'http://foo.com?q=test', array(
+ 'X-Foo' => 'bar',
+ 'Authorization' => 'Baz'
+ ));
+ $this->request->setBody(EntityBody::factory('Hello'));
+
+ $this->response = new Response(200, array(
+ 'X-Test' => 'Abc'
+ ), 'Foo');
+
+ $this->handle = $this->getMockBuilder('Guzzle\Http\Curl\CurlHandle')
+ ->disableOriginalConstructor()
+ ->setMethods(array('getError', 'getErrorNo', 'getStderr', 'getInfo'))
+ ->getMock();
+
+ $this->handle->expects($this->any())
+ ->method('getError')
+ ->will($this->returnValue('e'));
+
+ $this->handle->expects($this->any())
+ ->method('getErrorNo')
+ ->will($this->returnValue('123'));
+
+ $this->handle->expects($this->any())
+ ->method('getStderr')
+ ->will($this->returnValue('testing'));
+
+ $this->handle->expects($this->any())
+ ->method('getInfo')
+ ->will($this->returnValueMap(array(
+ array(CURLINFO_CONNECT_TIME, '123'),
+ array(CURLINFO_TOTAL_TIME, '456')
+ )));
+ }
+
+ public function logProvider()
+ {
+ return array(
+ // Uses the cache for the second time
+ array('{method} - {method}', 'POST - POST'),
+ array('{url}', 'http://foo.com?q=test'),
+ array('{port}', '80'),
+ array('{resource}', '/?q=test'),
+ array('{host}', 'foo.com'),
+ array('{hostname}', gethostname()),
+ array('{protocol}/{version}', 'HTTP/1.1'),
+ array('{code} {phrase}', '200 OK'),
+ array('{req_header_Foo}', ''),
+ array('{req_header_X-Foo}', 'bar'),
+ array('{req_header_Authorization}', 'Baz'),
+ array('{res_header_foo}', ''),
+ array('{res_header_X-Test}', 'Abc'),
+ array('{req_body}', 'Hello'),
+ array('{res_body}', 'Foo'),
+ array('{curl_stderr}', 'testing'),
+ array('{curl_error}', 'e'),
+ array('{curl_code}', '123'),
+ array('{connect_time}', '123'),
+ array('{total_time}', '456')
+ );
+ }
+
+ /**
+ * @dataProvider logProvider
+ */
+ public function testFormatsMessages($template, $output)
+ {
+ $formatter = new MessageFormatter($template);
+ $this->assertEquals($output, $formatter->format($this->request, $this->response, $this->handle));
+ }
+
+ public function testFormatsRequestsAndResponses()
+ {
+ $formatter = new MessageFormatter();
+ $formatter->setTemplate('{request}{response}');
+ $this->assertEquals($this->request . $this->response, $formatter->format($this->request, $this->response));
+ }
+
+ public function testAddsTimestamp()
+ {
+ $formatter = new MessageFormatter('{ts}');
+ $this->assertNotEmpty($formatter->format($this->request, $this->response));
+ }
+
+ public function testUsesResponseWhenNoHandleAndGettingCurlInformation()
+ {
+ $formatter = new MessageFormatter('{connect_time}/{total_time}');
+ $response = $this->getMockBuilder('Guzzle\Http\Message\Response')
+ ->setConstructorArgs(array(200))
+ ->setMethods(array('getInfo'))
+ ->getMock();
+ $response->expects($this->exactly(2))
+ ->method('getInfo')
+ ->will($this->returnValueMap(array(
+ array('connect_time', '1'),
+ array('total_time', '2'),
+ )));
+ $this->assertEquals('1/2', $formatter->format($this->request, $response));
+ }
+
+ public function testUsesEmptyStringWhenNoHandleAndNoResponse()
+ {
+ $formatter = new MessageFormatter('{connect_time}/{total_time}');
+ $this->assertEquals('/', $formatter->format($this->request));
+ }
+
+ public function testInjectsTotalTime()
+ {
+ $out = '';
+ $formatter = new MessageFormatter('{connect_time}/{total_time}');
+ $adapter = new ClosureLogAdapter(function ($m) use (&$out) { $out .= $m; });
+ $log = new LogPlugin($adapter, $formatter);
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nHI");
+ $client = new Client($this->getServer()->getUrl());
+ $client->addSubscriber($log);
+ $client->get('/')->send();
+ $this->assertNotEquals('/', $out);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/PsrLogAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/PsrLogAdapterTest.php
new file mode 100644
index 0000000..7b72dd6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/PsrLogAdapterTest.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Guzzle\Tests\Log;
+
+use Guzzle\Log\PsrLogAdapter;
+use Monolog\Logger;
+use Monolog\Handler\TestHandler;
+
+/**
+ * @covers Guzzle\Log\PsrLogAdapter
+ * @covers Guzzle\Log\AbstractLogAdapter
+ */
+class PsrLogAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testLogsMessagesToAdaptedObject()
+ {
+ $log = new Logger('test');
+ $handler = new TestHandler();
+ $log->pushHandler($handler);
+ $adapter = new PsrLogAdapter($log);
+ $adapter->log('test!', LOG_INFO);
+ $this->assertTrue($handler->hasInfoRecords());
+ $this->assertSame($log, $adapter->getLogObject());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/Zf2LogAdapterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/Zf2LogAdapterTest.php
new file mode 100644
index 0000000..1b61283
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Log/Zf2LogAdapterTest.php
@@ -0,0 +1,51 @@
+<?php
+
+namespace Guzzle\Tests\Log;
+
+use Guzzle\Log\Zf2LogAdapter;
+use Zend\Log\Logger;
+use Zend\Log\Writer\Stream;
+
+/**
+ * @covers Guzzle\Log\Zf2LogAdapter
+ */
+class Zf2LogAdapterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var Zf2LogAdapter */
+ protected $adapter;
+
+ /** @var Logger */
+ protected $log;
+
+ /** @var resource */
+ protected $stream;
+
+ protected function setUp()
+ {
+ $this->stream = fopen('php://temp', 'r+');
+ $this->log = new Logger();
+ $this->log->addWriter(new Stream($this->stream));
+ $this->adapter = new Zf2LogAdapter($this->log);
+
+ }
+
+ public function testLogsMessagesToAdaptedObject()
+ {
+ // Test without a priority
+ $this->adapter->log('Zend_Test!', \LOG_NOTICE);
+ rewind($this->stream);
+ $contents = stream_get_contents($this->stream);
+ $this->assertEquals(1, substr_count($contents, 'Zend_Test!'));
+
+ // Test with a priority
+ $this->adapter->log('Zend_Test!', \LOG_ALERT);
+ rewind($this->stream);
+ $contents = stream_get_contents($this->stream);
+ $this->assertEquals(2, substr_count($contents, 'Zend_Test!'));
+ }
+
+ public function testExposesAdaptedLogObject()
+ {
+ $this->assertEquals($this->log, $this->adapter->getLogObject());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/CustomResponseModel.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/CustomResponseModel.php
new file mode 100644
index 0000000..3fb6527
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/CustomResponseModel.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Guzzle\Tests\Mock;
+
+use Guzzle\Service\Command\ResponseClassInterface;
+use Guzzle\Service\Command\OperationCommand;
+
+class CustomResponseModel implements ResponseClassInterface
+{
+ public $command;
+
+ public static function fromCommand(OperationCommand $command)
+ {
+ return new self($command);
+ }
+
+ public function __construct($command)
+ {
+ $this->command = $command;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ErrorResponseMock.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ErrorResponseMock.php
new file mode 100644
index 0000000..aabb15f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ErrorResponseMock.php
@@ -0,0 +1,25 @@
+<?php
+
+namespace Guzzle\Tests\Mock;
+
+use Guzzle\Plugin\ErrorResponse\ErrorResponseExceptionInterface;
+use Guzzle\Service\Command\CommandInterface;
+use Guzzle\Http\Message\Response;
+
+class ErrorResponseMock extends \Exception implements ErrorResponseExceptionInterface
+{
+ public $command;
+ public $response;
+
+ public static function fromCommand(CommandInterface $command, Response $response)
+ {
+ return new self($command, $response);
+ }
+
+ public function __construct($command, $response)
+ {
+ $this->command = $command;
+ $this->response = $response;
+ $this->message = 'Error from ' . $response;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ExceptionMock.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ExceptionMock.php
new file mode 100644
index 0000000..97a1974
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/ExceptionMock.php
@@ -0,0 +1,11 @@
+<?php
+
+namespace Guzzle\Tests\Mock;
+
+class ExceptionMock
+{
+ public function __construct()
+ {
+ throw new \Exception('Oh no!');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockMulti.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockMulti.php
new file mode 100644
index 0000000..b4d6b82
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockMulti.php
@@ -0,0 +1,11 @@
+<?php
+
+namespace Guzzle\Tests\Mock;
+
+class MockMulti extends \Guzzle\Http\Curl\CurlMulti
+{
+ public function getHandle()
+ {
+ return $this->multiHandle;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockObserver.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockObserver.php
new file mode 100644
index 0000000..11e22eb
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockObserver.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Guzzle\Tests\Mock;
+
+use Guzzle\Common\Event;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+class MockObserver implements \Countable, EventSubscriberInterface
+{
+ public $events = array();
+
+ public static function getSubscribedEvents()
+ {
+ return array();
+ }
+
+ public function has($eventName)
+ {
+ foreach ($this->events as $event) {
+ if ($event->getName() == $eventName) {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
+ public function getLastEvent()
+ {
+ return end($this->events);
+ }
+
+ public function count()
+ {
+ return count($this->events);
+ }
+
+ public function getGrouped()
+ {
+ $events = array();
+ foreach ($this->events as $event) {
+ if (!isset($events[$event->getName()])) {
+ $events[$event->getName()] = array();
+ }
+ $events[$event->getName()][] = $event;
+ }
+
+ return $events;
+ }
+
+ public function getData($event, $key, $occurrence = 0)
+ {
+ $grouped = $this->getGrouped();
+ if (isset($grouped[$event])) {
+ return $grouped[$event][$occurrence][$key];
+ }
+
+ return null;
+ }
+
+ public function update(Event $event)
+ {
+ $this->events[] = $event;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockSubject.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockSubject.php
new file mode 100644
index 0000000..e011959
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Mock/MockSubject.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace Guzzle\Tests\Mock;
+
+class MockSubject extends \Guzzle\Common\Event\AbstractSubject
+{
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserProvider.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserProvider.php
new file mode 100644
index 0000000..86d43c0
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserProvider.php
@@ -0,0 +1,381 @@
+<?php
+
+namespace Guzzle\Tests\Parser\Cookie;
+
+use Guzzle\Http\Url;
+
+/**
+ * @covers Guzzle\Parser\Cookie\CookieParser
+ */
+class CookieParserProvider extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * Provides the parsed information from a cookie
+ *
+ * @return array
+ */
+ public function cookieParserDataProvider()
+ {
+ return array(
+ array(
+ 'ASIHTTPRequestTestCookie=This+is+the+value; expires=Sat, 26-Jul-2008 17:00:42 GMT; path=/tests; domain=allseeing-i.com; PHPSESSID=6c951590e7a9359bcedde25cda73e43c; path=/";',
+ array(
+ 'domain' => 'allseeing-i.com',
+ 'path' => '/',
+ 'data' => array(
+ 'PHPSESSID' => '6c951590e7a9359bcedde25cda73e43c'
+ ),
+ 'max_age' => NULL,
+ 'expires' => 'Sat, 26-Jul-2008 17:00:42 GMT',
+ 'version' => NULL,
+ 'secure' => NULL,
+ 'discard' => NULL,
+ 'port' => NULL,
+ 'cookies' => array(
+ 'ASIHTTPRequestTestCookie' => 'This+is+the+value'
+ ),
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ array('', false),
+ array('foo', false),
+ // Test setting a blank value for a cookie
+ array(array(
+ 'foo=', 'foo =', 'foo =;', 'foo= ;', 'foo =', 'foo= '),
+ array(
+ 'cookies' => array(
+ 'foo' => ''
+ ),
+ 'data' => array(),
+ 'discard' => null,
+ 'domain' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ // Test setting a value and removing quotes
+ array(array(
+ 'foo=1', 'foo =1', 'foo =1;', 'foo=1 ;', 'foo =1', 'foo= 1', 'foo = 1 ;', 'foo="1"', 'foo="1";', 'foo= "1";'),
+ array(
+ 'cookies' => array(
+ 'foo' => '1'
+ ),
+ 'data' => array(),
+ 'discard' => null,
+ 'domain' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ // Test setting multiple values
+ array(array(
+ 'foo=1; bar=2;', 'foo =1; bar = "2"', 'foo=1; bar=2'),
+ array(
+ 'cookies' => array(
+ 'foo' => '1',
+ 'bar' => '2',
+ ),
+ 'data' => array(),
+ 'discard' => null,
+ 'domain' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ // Tests getting the domain and path from a reference request
+ array(array(
+ 'foo=1; port="80,8081"; httponly', 'foo=1; port="80,8081"; domain=www.test.com; HttpOnly;', 'foo=1; ; domain=www.test.com; path=/path; port="80,8081"; HttpOnly;'),
+ array(
+ 'cookies' => array(
+ 'foo' => 1
+ ),
+ 'data' => array(),
+ 'discard' => null,
+ 'domain' => 'www.test.com',
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/path',
+ 'port' => array('80', '8081'),
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => true
+ ),
+ 'http://www.test.com/path/'
+ ),
+ // Some of the following tests are based on http://framework.zend.com/svn/framework/standard/trunk/tests/Zend/Http/CookieTest.php
+ array(
+ 'justacookie=foo; domain=example.com',
+ array(
+ 'cookies' => array(
+ 'justacookie' => 'foo'
+ ),
+ 'domain' => 'example.com',
+ 'data' => array(),
+ 'discard' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ array(
+ 'expires=tomorrow; secure; path=/Space Out/; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=.example.com',
+ array(
+ 'cookies' => array(
+ 'expires' => 'tomorrow'
+ ),
+ 'domain' => '.example.com',
+ 'path' => '/Space Out/',
+ 'expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
+ 'data' => array(),
+ 'discard' => null,
+ 'port' => null,
+ 'secure' => true,
+ 'version' => null,
+ 'max_age' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ array(
+ 'domain=unittests; expires=Tue, 21-Nov-2006 08:33:44 GMT; domain=example.com; path=/some value/',
+ array(
+ 'cookies' => array(
+ 'domain' => 'unittests'
+ ),
+ 'domain' => 'example.com',
+ 'path' => '/some value/',
+ 'expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
+ 'secure' => false,
+ 'data' => array(),
+ 'discard' => null,
+ 'max_age' => null,
+ 'port' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ array(
+ 'path=indexAction; path=/; domain=.foo.com; expires=Tue, 21-Nov-2006 08:33:44 GMT',
+ array(
+ 'cookies' => array(
+ 'path' => 'indexAction'
+ ),
+ 'domain' => '.foo.com',
+ 'path' => '/',
+ 'expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
+ 'secure' => false,
+ 'data' => array(),
+ 'discard' => null,
+ 'max_age' => null,
+ 'port' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ array(
+ 'secure=sha1; secure; SECURE; domain=some.really.deep.domain.com; version=1; Max-Age=86400',
+ array(
+ 'cookies' => array(
+ 'secure' => 'sha1'
+ ),
+ 'domain' => 'some.really.deep.domain.com',
+ 'path' => '/',
+ 'secure' => true,
+ 'data' => array(),
+ 'discard' => null,
+ 'expires' => time() + 86400,
+ 'max_age' => 86400,
+ 'port' => null,
+ 'version' => 1,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ array(
+ 'PHPSESSID=123456789+abcd%2Cef; secure; discard; domain=.localdomain; path=/foo/baz; expires=Tue, 21-Nov-2006 08:33:44 GMT;',
+ array(
+ 'cookies' => array(
+ 'PHPSESSID' => '123456789+abcd%2Cef'
+ ),
+ 'domain' => '.localdomain',
+ 'path' => '/foo/baz',
+ 'expires' => 'Tue, 21-Nov-2006 08:33:44 GMT',
+ 'secure' => true,
+ 'data' => array(),
+ 'discard' => true,
+ 'max_age' => null,
+ 'port' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ )
+ ),
+ // rfc6265#section-5.1.4
+ array(
+ 'cookie=value',
+ array(
+ 'cookies' => array(
+ 'cookie' => 'value'
+ ),
+ 'domain' => 'example.com',
+ 'data' => array(),
+ 'discard' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/some/path',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ ),
+ 'http://example.com/some/path/test.html'
+ ),
+ array(
+ 'empty=path',
+ array(
+ 'cookies' => array(
+ 'empty' => 'path'
+ ),
+ 'domain' => 'example.com',
+ 'data' => array(),
+ 'discard' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ ),
+ 'http://example.com/test.html'
+ ),
+ array(
+ 'baz=qux',
+ array(
+ 'cookies' => array(
+ 'baz' => 'qux'
+ ),
+ 'domain' => 'example.com',
+ 'data' => array(),
+ 'discard' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ ),
+ 'http://example.com?query=here'
+ ),
+ array(
+ 'test=noSlashPath; path=someString',
+ array(
+ 'cookies' => array(
+ 'test' => 'noSlashPath'
+ ),
+ 'domain' => 'example.com',
+ 'data' => array(),
+ 'discard' => null,
+ 'expires' => null,
+ 'max_age' => null,
+ 'path' => '/real/path',
+ 'port' => null,
+ 'secure' => null,
+ 'version' => null,
+ 'comment' => null,
+ 'comment_url' => null,
+ 'http_only' => false
+ ),
+ 'http://example.com/real/path/'
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider cookieParserDataProvider
+ */
+ public function testParseCookie($cookie, $parsed, $url = null)
+ {
+ $c = $this->cookieParserClass;
+ $parser = new $c();
+
+ $request = null;
+ if ($url) {
+ $url = Url::factory($url);
+ $host = $url->getHost();
+ $path = $url->getPath();
+ } else {
+ $host = '';
+ $path = '';
+ }
+
+ foreach ((array) $cookie as $c) {
+ $p = $parser->parseCookie($c, $host, $path);
+
+ // Remove expires values from the assertion if they are relatively equal by allowing a 5 minute difference
+ if ($p['expires'] != $parsed['expires']) {
+ if (abs($p['expires'] - $parsed['expires']) < 300) {
+ unset($p['expires']);
+ unset($parsed['expires']);
+ }
+ }
+
+ if (is_array($parsed)) {
+ foreach ($parsed as $key => $value) {
+ $this->assertEquals($parsed[$key], $p[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
+ }
+
+ foreach ($p as $key => $value) {
+ $this->assertEquals($p[$key], $parsed[$key], 'Comparing ' . $key . ' ' . var_export($value, true) . ' : ' . var_export($parsed, true) . ' | ' . var_export($p, true));
+ }
+ } else {
+ $this->assertEquals($parsed, $p);
+ }
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserTest.php
new file mode 100644
index 0000000..75d336f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Cookie/CookieParserTest.php
@@ -0,0 +1,22 @@
+<?php
+
+namespace Guzzle\Tests\Parser\Cookie;
+
+use Guzzle\Parser\Cookie\CookieParser;
+
+/**
+ * @covers Guzzle\Parser\Cookie\CookieParser
+ */
+class CookieParserTest extends CookieParserProvider
+{
+ protected $cookieParserClass = 'Guzzle\Parser\Cookie\CookieParser';
+
+ public function testUrlDecodesCookies()
+ {
+ $parser = new CookieParser();
+ $result = $parser->parseCookie('foo=baz+bar', null, null, true);
+ $this->assertEquals(array(
+ 'foo' => 'baz bar'
+ ), $result['cookies']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserProvider.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserProvider.php
new file mode 100644
index 0000000..da58bb4
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserProvider.php
@@ -0,0 +1,225 @@
+<?php
+
+namespace Guzzle\Tests\Parser\Message;
+
+class MessageParserProvider extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function requestProvider()
+ {
+ $auth = base64_encode('michael:foo');
+
+ return array(
+
+ // Empty request
+ array('', false),
+
+ // Converts casing of request. Does not require host header.
+ array("GET / HTTP/1.1\r\n\r\n", array(
+ 'method' => 'GET',
+ 'protocol' => 'HTTP',
+ 'version' => '1.1',
+ 'request_url' => array(
+ 'scheme' => 'http',
+ 'host' => '',
+ 'port' => '',
+ 'path' => '/',
+ 'query' => ''
+ ),
+ 'headers' => array(),
+ 'body' => ''
+ )),
+ // Path and query string, multiple header values per header and case sensitive storage
+ array("HEAD /path?query=foo HTTP/1.0\r\nHost: example.com\r\nX-Foo: foo\r\nx-foo: Bar\r\nX-Foo: foo\r\nX-Foo: Baz\r\n\r\n", array(
+ 'method' => 'HEAD',
+ 'protocol' => 'HTTP',
+ 'version' => '1.0',
+ 'request_url' => array(
+ 'scheme' => 'http',
+ 'host' => 'example.com',
+ 'port' => '',
+ 'path' => '/path',
+ 'query' => 'query=foo'
+ ),
+ 'headers' => array(
+ 'Host' => 'example.com',
+ 'X-Foo' => array('foo', 'foo', 'Baz'),
+ 'x-foo' => 'Bar'
+ ),
+ 'body' => ''
+ )),
+ // Includes a body
+ array("PUT / HTTP/1.0\r\nhost: example.com:443\r\nContent-Length: 4\r\n\r\ntest", array(
+ 'method' => 'PUT',
+ 'protocol' => 'HTTP',
+ 'version' => '1.0',
+ 'request_url' => array(
+ 'scheme' => 'https',
+ 'host' => 'example.com',
+ 'port' => '443',
+ 'path' => '/',
+ 'query' => ''
+ ),
+ 'headers' => array(
+ 'host' => 'example.com:443',
+ 'Content-Length' => '4'
+ ),
+ 'body' => 'test'
+ )),
+ // Includes Authorization headers
+ array("GET / HTTP/1.1\r\nHost: example.com:8080\r\nAuthorization: Basic {$auth}\r\n\r\n", array(
+ 'method' => 'GET',
+ 'protocol' => 'HTTP',
+ 'version' => '1.1',
+ 'request_url' => array(
+ 'scheme' => 'http',
+ 'host' => 'example.com',
+ 'port' => '8080',
+ 'path' => '/',
+ 'query' => ''
+ ),
+ 'headers' => array(
+ 'Host' => 'example.com:8080',
+ 'Authorization' => "Basic {$auth}"
+ ),
+ 'body' => ''
+ )),
+ // Include authorization header
+ array("GET / HTTP/1.1\r\nHost: example.com:8080\r\nauthorization: Basic {$auth}\r\n\r\n", array(
+ 'method' => 'GET',
+ 'protocol' => 'HTTP',
+ 'version' => '1.1',
+ 'request_url' => array(
+ 'scheme' => 'http',
+ 'host' => 'example.com',
+ 'port' => '8080',
+ 'path' => '/',
+ 'query' => ''
+ ),
+ 'headers' => array(
+ 'Host' => 'example.com:8080',
+ 'authorization' => "Basic {$auth}"
+ ),
+ 'body' => ''
+ )),
+ );
+ }
+
+ public function responseProvider()
+ {
+ return array(
+ // Empty request
+ array('', false),
+
+ array("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n", array(
+ 'protocol' => 'HTTP',
+ 'version' => '1.1',
+ 'code' => '200',
+ 'reason_phrase' => 'OK',
+ 'headers' => array(
+ 'Content-Length' => 0
+ ),
+ 'body' => ''
+ )),
+ array("HTTP/1.0 400 Bad Request\r\nContent-Length: 0\r\n\r\n", array(
+ 'protocol' => 'HTTP',
+ 'version' => '1.0',
+ 'code' => '400',
+ 'reason_phrase' => 'Bad Request',
+ 'headers' => array(
+ 'Content-Length' => 0
+ ),
+ 'body' => ''
+ )),
+ array("HTTP/1.0 100 Continue\r\n\r\n", array(
+ 'protocol' => 'HTTP',
+ 'version' => '1.0',
+ 'code' => '100',
+ 'reason_phrase' => 'Continue',
+ 'headers' => array(),
+ 'body' => ''
+ )),
+ array("HTTP/1.1 204 No Content\r\nX-Foo: foo\r\nx-foo: Bar\r\nX-Foo: foo\r\n\r\n", array(
+ 'protocol' => 'HTTP',
+ 'version' => '1.1',
+ 'code' => '204',
+ 'reason_phrase' => 'No Content',
+ 'headers' => array(
+ 'X-Foo' => array('foo', 'foo'),
+ 'x-foo' => 'Bar'
+ ),
+ 'body' => ''
+ )),
+ array("HTTP/1.1 200 Ok that is great!\r\nContent-Length: 4\r\n\r\nTest", array(
+ 'protocol' => 'HTTP',
+ 'version' => '1.1',
+ 'code' => '200',
+ 'reason_phrase' => 'Ok that is great!',
+ 'headers' => array(
+ 'Content-Length' => 4
+ ),
+ 'body' => 'Test'
+ )),
+ );
+ }
+
+ public function compareRequestResults($result, $expected)
+ {
+ if (!$result) {
+ $this->assertFalse($expected);
+ return;
+ }
+
+ $this->assertEquals($result['method'], $expected['method']);
+ $this->assertEquals($result['protocol'], $expected['protocol']);
+ $this->assertEquals($result['version'], $expected['version']);
+ $this->assertEquals($result['request_url'], $expected['request_url']);
+ $this->assertEquals($result['body'], $expected['body']);
+ $this->compareHttpHeaders($result['headers'], $expected['headers']);
+ }
+
+ public function compareResponseResults($result, $expected)
+ {
+ if (!$result) {
+ $this->assertFalse($expected);
+ return;
+ }
+
+ $this->assertEquals($result['protocol'], $expected['protocol']);
+ $this->assertEquals($result['version'], $expected['version']);
+ $this->assertEquals($result['code'], $expected['code']);
+ $this->assertEquals($result['reason_phrase'], $expected['reason_phrase']);
+ $this->assertEquals($result['body'], $expected['body']);
+ $this->compareHttpHeaders($result['headers'], $expected['headers']);
+ }
+
+ protected function normalizeHeaders($headers)
+ {
+ $normalized = array();
+ foreach ($headers as $key => $value) {
+ $key = strtolower($key);
+ if (!isset($normalized[$key])) {
+ $normalized[$key] = $value;
+ } elseif (!is_array($normalized[$key])) {
+ $normalized[$key] = array($value);
+ } else {
+ $normalized[$key][] = $value;
+ }
+ }
+
+ foreach ($normalized as $key => &$value) {
+ if (is_array($value)) {
+ sort($value);
+ }
+ }
+
+ return $normalized;
+ }
+
+ public function compareHttpHeaders($result, $expected)
+ {
+ // Aggregate all headers case-insensitively
+ $result = $this->normalizeHeaders($result);
+ $expected = $this->normalizeHeaders($expected);
+ $this->assertEquals($result, $expected);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserTest.php
new file mode 100644
index 0000000..2f52228
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/MessageParserTest.php
@@ -0,0 +1,58 @@
+<?php
+
+namespace Guzzle\Tests\Parser\Message;
+
+use Guzzle\Parser\Message\MessageParser;
+
+/**
+ * @covers Guzzle\Parser\Message\AbstractMessageParser
+ * @covers Guzzle\Parser\Message\MessageParser
+ */
+class MessageParserTest extends MessageParserProvider
+{
+ /**
+ * @dataProvider requestProvider
+ */
+ public function testParsesRequests($message, $parts)
+ {
+ $parser = new MessageParser();
+ $this->compareRequestResults($parts, $parser->parseRequest($message));
+ }
+
+ /**
+ * @dataProvider responseProvider
+ */
+ public function testParsesResponses($message, $parts)
+ {
+ $parser = new MessageParser();
+ $this->compareResponseResults($parts, $parser->parseResponse($message));
+ }
+
+ public function testParsesRequestsWithMissingProtocol()
+ {
+ $parser = new MessageParser();
+ $parts = $parser->parseRequest("GET /\r\nHost: Foo.com\r\n\r\n");
+ $this->assertEquals('GET', $parts['method']);
+ $this->assertEquals('HTTP', $parts['protocol']);
+ $this->assertEquals('1.1', $parts['version']);
+ }
+
+ public function testParsesRequestsWithMissingVersion()
+ {
+ $parser = new MessageParser();
+ $parts = $parser->parseRequest("GET / HTTP\r\nHost: Foo.com\r\n\r\n");
+ $this->assertEquals('GET', $parts['method']);
+ $this->assertEquals('HTTP', $parts['protocol']);
+ $this->assertEquals('1.1', $parts['version']);
+ }
+
+ public function testParsesResponsesWithMissingReasonPhrase()
+ {
+ $parser = new MessageParser();
+ $parts = $parser->parseResponse("HTTP/1.1 200\r\n\r\n");
+ $this->assertEquals('200', $parts['code']);
+ $this->assertEquals('', $parts['reason_phrase']);
+ $this->assertEquals('HTTP', $parts['protocol']);
+ $this->assertEquals('1.1', $parts['version']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/PeclHttpMessageParserTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/PeclHttpMessageParserTest.php
new file mode 100644
index 0000000..6706e20
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/Message/PeclHttpMessageParserTest.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Guzzle\Tests\Parser\Message;
+
+use Guzzle\Parser\Message\PeclHttpMessageParser;
+
+/**
+ * @covers Guzzle\Parser\Message\PeclHttpMessageParser
+ */
+class PeclHttpMessageParserTest extends MessageParserProvider
+{
+ protected function setUp()
+ {
+ if (!function_exists('http_parse_message')) {
+ $this->markTestSkipped('pecl_http is not available.');
+ }
+ }
+
+ /**
+ * @dataProvider requestProvider
+ */
+ public function testParsesRequests($message, $parts)
+ {
+ $parser = new PeclHttpMessageParser();
+ $this->compareRequestResults($parts, $parser->parseRequest($message));
+ }
+
+ /**
+ * @dataProvider responseProvider
+ */
+ public function testParsesResponses($message, $parts)
+ {
+ $parser = new PeclHttpMessageParser();
+ $this->compareResponseResults($parts, $parser->parseResponse($message));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/ParserRegistryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/ParserRegistryTest.php
new file mode 100644
index 0000000..7675efb
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/ParserRegistryTest.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Guzzle\Tests\Parser;
+
+use Guzzle\Parser\ParserRegistry;
+
+/**
+ * @covers Guzzle\Parser\ParserRegistry
+ */
+class ParserRegistryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testStoresObjects()
+ {
+ $r = new ParserRegistry();
+ $c = new \stdClass();
+ $r->registerParser('foo', $c);
+ $this->assertSame($c, $r->getParser('foo'));
+ }
+
+ public function testReturnsNullWhenNotFound()
+ {
+ $r = new ParserRegistry();
+ $this->assertNull($r->getParser('FOO'));
+ }
+
+ public function testReturnsLazyLoadedDefault()
+ {
+ $r = new ParserRegistry();
+ $c = $r->getParser('cookie');
+ $this->assertInstanceOf('Guzzle\Parser\Cookie\CookieParser', $c);
+ $this->assertSame($c, $r->getParser('cookie'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/AbstractUriTemplateTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/AbstractUriTemplateTest.php
new file mode 100644
index 0000000..a05fc2e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/AbstractUriTemplateTest.php
@@ -0,0 +1,113 @@
+<?php
+
+namespace Guzzle\Tests\Parsers\UriTemplate;
+
+abstract class AbstractUriTemplateTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @return array
+ */
+ public function templateProvider()
+ {
+ $t = array();
+ $params = array(
+ 'var' => 'value',
+ 'hello' => 'Hello World!',
+ 'empty' => '',
+ 'path' => '/foo/bar',
+ 'x' => '1024',
+ 'y' => '768',
+ 'null' => null,
+ 'list' => array('red', 'green', 'blue'),
+ 'keys' => array(
+ "semi" => ';',
+ "dot" => '.',
+ "comma" => ','
+ ),
+ 'empty_keys' => array(),
+ );
+
+ return array_map(function($t) use ($params) {
+ $t[] = $params;
+ return $t;
+ }, array(
+ array('foo', 'foo'),
+ array('{var}', 'value'),
+ array('{hello}', 'Hello%20World%21'),
+ array('{+var}', 'value'),
+ array('{+hello}', 'Hello%20World!'),
+ array('{+path}/here', '/foo/bar/here'),
+ array('here?ref={+path}', 'here?ref=/foo/bar'),
+ array('X{#var}', 'X#value'),
+ array('X{#hello}', 'X#Hello%20World!'),
+ array('map?{x,y}', 'map?1024,768'),
+ array('{x,hello,y}', '1024,Hello%20World%21,768'),
+ array('{+x,hello,y}', '1024,Hello%20World!,768'),
+ array('{+path,x}/here', '/foo/bar,1024/here'),
+ array('{#x,hello,y}', '#1024,Hello%20World!,768'),
+ array('{#path,x}/here', '#/foo/bar,1024/here'),
+ array('X{.var}', 'X.value'),
+ array('X{.x,y}', 'X.1024.768'),
+ array('{/var}', '/value'),
+ array('{/var,x}/here', '/value/1024/here'),
+ array('{;x,y}', ';x=1024;y=768'),
+ array('{;x,y,empty}', ';x=1024;y=768;empty'),
+ array('{?x,y}', '?x=1024&y=768'),
+ array('{?x,y,empty}', '?x=1024&y=768&empty='),
+ array('?fixed=yes{&x}', '?fixed=yes&x=1024'),
+ array('{&x,y,empty}', '&x=1024&y=768&empty='),
+ array('{var:3}', 'val'),
+ array('{var:30}', 'value'),
+ array('{list}', 'red,green,blue'),
+ array('{list*}', 'red,green,blue'),
+ array('{keys}', 'semi,%3B,dot,.,comma,%2C'),
+ array('{keys*}', 'semi=%3B,dot=.,comma=%2C'),
+ array('{+path:6}/here', '/foo/b/here'),
+ array('{+list}', 'red,green,blue'),
+ array('{+list*}', 'red,green,blue'),
+ array('{+keys}', 'semi,;,dot,.,comma,,'),
+ array('{+keys*}', 'semi=;,dot=.,comma=,'),
+ array('{#path:6}/here', '#/foo/b/here'),
+ array('{#list}', '#red,green,blue'),
+ array('{#list*}', '#red,green,blue'),
+ array('{#keys}', '#semi,;,dot,.,comma,,'),
+ array('{#keys*}', '#semi=;,dot=.,comma=,'),
+ array('X{.var:3}', 'X.val'),
+ array('X{.list}', 'X.red,green,blue'),
+ array('X{.list*}', 'X.red.green.blue'),
+ array('X{.keys}', 'X.semi,%3B,dot,.,comma,%2C'),
+ array('X{.keys*}', 'X.semi=%3B.dot=..comma=%2C'),
+ array('{/var:1,var}', '/v/value'),
+ array('{/list}', '/red,green,blue'),
+ array('{/list*}', '/red/green/blue'),
+ array('{/list*,path:4}', '/red/green/blue/%2Ffoo'),
+ array('{/keys}', '/semi,%3B,dot,.,comma,%2C'),
+ array('{/keys*}', '/semi=%3B/dot=./comma=%2C'),
+ array('{;hello:5}', ';hello=Hello'),
+ array('{;list}', ';list=red,green,blue'),
+ array('{;list*}', ';list=red;list=green;list=blue'),
+ array('{;keys}', ';keys=semi,%3B,dot,.,comma,%2C'),
+ array('{;keys*}', ';semi=%3B;dot=.;comma=%2C'),
+ array('{?var:3}', '?var=val'),
+ array('{?list}', '?list=red,green,blue'),
+ array('{?list*}', '?list=red&list=green&list=blue'),
+ array('{?keys}', '?keys=semi,%3B,dot,.,comma,%2C'),
+ array('{?keys*}', '?semi=%3B&dot=.&comma=%2C'),
+ array('{&var:3}', '&var=val'),
+ array('{&list}', '&list=red,green,blue'),
+ array('{&list*}', '&list=red&list=green&list=blue'),
+ array('{&keys}', '&keys=semi,%3B,dot,.,comma,%2C'),
+ array('{&keys*}', '&semi=%3B&dot=.&comma=%2C'),
+ array('{.null}', ''),
+ array('{.null,var}', '.value'),
+ array('X{.empty_keys*}', 'X'),
+ array('X{.empty_keys}', 'X'),
+ // Test that missing expansions are skipped
+ array('test{&missing*}', 'test'),
+ // Test that multiple expansions can be set
+ array('http://{var}/{var:2}{?keys*}', 'http://value/va?semi=%3B&dot=.&comma=%2C'),
+ // Test more complex query string stuff
+ array('http://www.test.com{+path}{?var,keys*}', 'http://www.test.com/foo/bar?var=value&semi=%3B&dot=.&comma=%2C')
+ ));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/PeclUriTemplateTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/PeclUriTemplateTest.php
new file mode 100644
index 0000000..633c5d5
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/PeclUriTemplateTest.php
@@ -0,0 +1,27 @@
+<?php
+
+namespace Guzzle\Tests\Parsers\UriTemplate;
+
+use Guzzle\Parser\UriTemplate\PeclUriTemplate;
+
+/**
+ * @covers Guzzle\Parser\UriTemplate\PeclUriTemplate
+ */
+class PeclUriTemplateTest extends AbstractUriTemplateTest
+{
+ protected function setUp()
+ {
+ if (!extension_loaded('uri_template')) {
+ $this->markTestSkipped('uri_template PECL extension must be installed to test PeclUriTemplate');
+ }
+ }
+
+ /**
+ * @dataProvider templateProvider
+ */
+ public function testExpandsUriTemplates($template, $expansion, $params)
+ {
+ $uri = new PeclUriTemplate($template);
+ $this->assertEquals($expansion, $uri->expand($template, $params));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/UriTemplateTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/UriTemplateTest.php
new file mode 100644
index 0000000..5130d6f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Parser/UriTemplate/UriTemplateTest.php
@@ -0,0 +1,106 @@
+<?php
+
+namespace Guzzle\Tests\Parsers\UriTemplate;
+
+use Guzzle\Parser\UriTemplate\UriTemplate;
+
+/**
+ * @covers Guzzle\Parser\UriTemplate\UriTemplate
+ */
+class UriTemplateTest extends AbstractUriTemplateTest
+{
+ /**
+ * @dataProvider templateProvider
+ */
+ public function testExpandsUriTemplates($template, $expansion, $params)
+ {
+ $uri = new UriTemplate($template);
+ $this->assertEquals($expansion, $uri->expand($template, $params));
+ }
+
+ public function expressionProvider()
+ {
+ return array(
+ array(
+ '{+var*}', array(
+ 'operator' => '+',
+ 'values' => array(
+ array('value' => 'var', 'modifier' => '*')
+ )
+ ),
+ ),
+ array(
+ '{?keys,var,val}', array(
+ 'operator' => '?',
+ 'values' => array(
+ array('value' => 'keys', 'modifier' => ''),
+ array('value' => 'var', 'modifier' => ''),
+ array('value' => 'val', 'modifier' => '')
+ )
+ ),
+ ),
+ array(
+ '{+x,hello,y}', array(
+ 'operator' => '+',
+ 'values' => array(
+ array('value' => 'x', 'modifier' => ''),
+ array('value' => 'hello', 'modifier' => ''),
+ array('value' => 'y', 'modifier' => '')
+ )
+ )
+ )
+ );
+ }
+
+ /**
+ * @dataProvider expressionProvider
+ */
+ public function testParsesExpressions($exp, $data)
+ {
+ $template = new UriTemplate($exp);
+
+ // Access the config object
+ $class = new \ReflectionClass($template);
+ $method = $class->getMethod('parseExpression');
+ $method->setAccessible(true);
+
+ $exp = substr($exp, 1, -1);
+ $this->assertEquals($data, $method->invokeArgs($template, array($exp)));
+ }
+
+ /**
+ * @ticket https://github.com/guzzle/guzzle/issues/90
+ */
+ public function testAllowsNestedArrayExpansion()
+ {
+ $template = new UriTemplate();
+
+ $result = $template->expand('http://example.com{+path}{/segments}{?query,data*,foo*}', array(
+ 'path' => '/foo/bar',
+ 'segments' => array('one', 'two'),
+ 'query' => 'test',
+ 'data' => array(
+ 'more' => array('fun', 'ice cream')
+ ),
+ 'foo' => array(
+ 'baz' => array(
+ 'bar' => 'fizz',
+ 'test' => 'buzz'
+ ),
+ 'bam' => 'boo'
+ )
+ ));
+
+ $this->assertEquals('http://example.com/foo/bar/one,two?query=test&more%5B0%5D=fun&more%5B1%5D=ice%20cream&baz%5Bbar%5D=fizz&baz%5Btest%5D=buzz&bam=boo', $result);
+ }
+
+ /**
+ * @ticket https://github.com/guzzle/guzzle/issues/426
+ */
+ public function testSetRegex()
+ {
+ $template = new UriTemplate();
+ $template->setRegex('/\<\$(.+)\>/');
+ $this->assertSame('/foo', $template->expand('/<$a>', array('a' => 'foo')));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Async/AsyncPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Async/AsyncPluginTest.php
new file mode 100644
index 0000000..16990a5
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Async/AsyncPluginTest.php
@@ -0,0 +1,93 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Async;
+
+use Guzzle\Plugin\Async\AsyncPlugin;
+use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\Curl\CurlHandle;
+use Guzzle\Http\Exception\CurlException;
+use Guzzle\Common\Event;
+use Guzzle\Http\Client;
+
+/**
+ * @covers Guzzle\Plugin\Async\AsyncPlugin
+ */
+class AsyncPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testSubscribesToEvents()
+ {
+ $events = AsyncPlugin::getSubscribedEvents();
+ $this->assertArrayHasKey('request.before_send', $events);
+ $this->assertArrayHasKey('request.exception', $events);
+ $this->assertArrayHasKey('curl.callback.progress', $events);
+ }
+
+ public function testEnablesProgressCallbacks()
+ {
+ $p = new AsyncPlugin();
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.example.com');
+ $event = new Event(array(
+ 'request' => $request
+ ));
+ $p->onBeforeSend($event);
+ $this->assertEquals(true, $request->getCurlOptions()->get('progress'));
+ }
+
+ public function testAddsTimesOutAfterSending()
+ {
+ $p = new AsyncPlugin();
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.example.com');
+ $handle = CurlHandle::factory($request);
+ $event = new Event(array(
+ 'request' => $request,
+ 'handle' => $handle->getHandle(),
+ 'uploaded' => 10,
+ 'upload_size' => 10,
+ 'downloaded' => 0
+ ));
+ $p->onCurlProgress($event);
+ }
+
+ public function testEnsuresRequestIsSet()
+ {
+ $p = new AsyncPlugin();
+ $event = new Event(array(
+ 'uploaded' => 10,
+ 'upload_size' => 10,
+ 'downloaded' => 0
+ ));
+ $p->onCurlProgress($event);
+ }
+
+ public function testMasksCurlExceptions()
+ {
+ $p = new AsyncPlugin();
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.example.com');
+ $e = new CurlException('Error');
+ $event = new Event(array(
+ 'request' => $request,
+ 'exception' => $e
+ ));
+ $p->onRequestTimeout($event);
+ $this->assertEquals(RequestInterface::STATE_COMPLETE, $request->getState());
+ $this->assertEquals(200, $request->getResponse()->getStatusCode());
+ $this->assertTrue($request->getResponse()->hasHeader('X-Guzzle-Async'));
+ }
+
+ public function testEnsuresIntegration()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 204 FOO\r\nContent-Length: 4\r\n\r\ntest");
+ $client = new Client($this->getServer()->getUrl());
+ $request = $client->post('/', null, array(
+ 'foo' => 'bar'
+ ));
+ $request->getEventDispatcher()->addSubscriber(new AsyncPlugin());
+ $request->send();
+ $this->assertEquals('', $request->getResponse()->getBody(true));
+ $this->assertTrue($request->getResponse()->hasHeader('X-Guzzle-Async'));
+ $received = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals('POST', $received[0]->getMethod());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/AbstractBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/AbstractBackoffStrategyTest.php
new file mode 100644
index 0000000..72af263
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/AbstractBackoffStrategyTest.php
@@ -0,0 +1,86 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Http\Message\Request;
+use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy;
+use Guzzle\Plugin\Backoff\CallbackBackoffStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\AbstractBackoffStrategy
+ */
+class AbstractBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected function getMockStrategy()
+ {
+ return $this->getMockBuilder('Guzzle\Plugin\Backoff\AbstractBackoffStrategy')
+ ->setMethods(array('getDelay', 'makesDecision'))
+ ->getMockForAbstractClass();
+ }
+
+ public function testReturnsZeroWhenNoNextAndGotNull()
+ {
+ $request = new Request('GET', 'http://www.foo.com');
+ $mock = $this->getMockStrategy();
+ $mock->expects($this->atLeastOnce())->method('getDelay')->will($this->returnValue(null));
+ $this->assertEquals(0, $mock->getBackoffPeriod(0, $request));
+ }
+
+ public function testReturnsFalse()
+ {
+ $request = new Request('GET', 'http://www.foo.com');
+ $mock = $this->getMockStrategy();
+ $mock->expects($this->atLeastOnce())->method('getDelay')->will($this->returnValue(false));
+ $this->assertEquals(false, $mock->getBackoffPeriod(0, $request));
+ }
+
+ public function testReturnsNextValueWhenNullOrTrue()
+ {
+ $request = new Request('GET', 'http://www.foo.com');
+ $mock = $this->getMockStrategy();
+ $mock->expects($this->atLeastOnce())->method('getDelay')->will($this->returnValue(null));
+ $mock->expects($this->any())->method('makesDecision')->will($this->returnValue(false));
+
+ $mock2 = $this->getMockStrategy();
+ $mock2->expects($this->atLeastOnce())->method('getDelay')->will($this->returnValue(10));
+ $mock2->expects($this->atLeastOnce())->method('makesDecision')->will($this->returnValue(true));
+ $mock->setNext($mock2);
+
+ $this->assertEquals(10, $mock->getBackoffPeriod(0, $request));
+ }
+
+ public function testReturnsFalseWhenNullAndNoNext()
+ {
+ $request = new Request('GET', 'http://www.foo.com');
+ $s = new TruncatedBackoffStrategy(2);
+ $this->assertFalse($s->getBackoffPeriod(0, $request));
+ }
+
+ public function testHasNext()
+ {
+ $a = new TruncatedBackoffStrategy(2);
+ $b = new TruncatedBackoffStrategy(2);
+ $a->setNext($b);
+ $this->assertSame($b, $a->getNext());
+ }
+
+ public function testSkipsOtherDecisionsInChainWhenOneReturnsTrue()
+ {
+ $a = new CallbackBackoffStrategy(function () { return null; }, true);
+ $b = new CallbackBackoffStrategy(function () { return true; }, true);
+ $c = new CallbackBackoffStrategy(function () { return null; }, true);
+ $d = new CallbackBackoffStrategy(function () { return 10; }, false);
+ $a->setNext($b);
+ $b->setNext($c);
+ $c->setNext($d);
+ $this->assertEquals(10, $a->getBackoffPeriod(2, new Request('GET', 'http://www.foo.com')));
+ }
+
+ public function testReturnsZeroWhenDecisionMakerReturnsTrueButNoFurtherStrategiesAreInTheChain()
+ {
+ $a = new CallbackBackoffStrategy(function () { return null; }, true);
+ $b = new CallbackBackoffStrategy(function () { return true; }, true);
+ $a->setNext($b);
+ $this->assertSame(0, $a->getBackoffPeriod(2, new Request('GET', 'http://www.foo.com')));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffLoggerTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffLoggerTest.php
new file mode 100644
index 0000000..a64dd82
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffLoggerTest.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Common\Event;
+use Guzzle\Log\ClosureLogAdapter;
+use Guzzle\Http\Curl\CurlHandle;
+use Guzzle\Plugin\Backoff\BackoffLogger;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\RequestFactory;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\BackoffLogger
+ */
+class BackoffLoggerTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public $message;
+
+ public function setUp()
+ {
+ $this->message = '';
+ }
+
+ public function testHasEventList()
+ {
+ $this->assertEquals(1, count(BackoffLogger::getSubscribedEvents()));
+ }
+
+ public function testLogsEvents()
+ {
+ list($logPlugin, $request, $response) = $this->getMocks();
+
+ $response = $this->getMockBuilder('Guzzle\Http\Message\Response')
+ ->setConstructorArgs(array(503))
+ ->setMethods(array('getInfo'))
+ ->getMock();
+
+ $response->expects($this->any())
+ ->method('getInfo')
+ ->will($this->returnValue(2));
+
+ $handle = $this->getMockHandle();
+
+ $event = new Event(array(
+ 'request' => $request,
+ 'response' => $response,
+ 'retries' => 1,
+ 'delay' => 3,
+ 'handle' => $handle
+ ));
+
+ $logPlugin->onRequestRetry($event);
+ $this->assertContains(
+ '] PUT http://www.example.com - 503 Service Unavailable - Retries: 1, Delay: 3, Time: 2, 2, cURL: 30 Foo',
+ $this->message
+ );
+ }
+
+ public function testCanSetTemplate()
+ {
+ $l = new BackoffLogger(new ClosureLogAdapter(function () {}));
+ $l->setTemplate('foo');
+ $t = $this->readAttribute($l, 'formatter');
+ $this->assertEquals('foo', $this->readAttribute($t, 'template'));
+ }
+
+ /**
+ * @return array
+ */
+ protected function getMocks()
+ {
+ $that = $this;
+ $logger = new ClosureLogAdapter(function ($message) use ($that) {
+ $that->message .= $message . "\n";
+ });
+ $logPlugin = new BackoffLogger($logger);
+ $response = new Response(503);
+ $request = RequestFactory::getInstance()->create('PUT', 'http://www.example.com', array(
+ 'Content-Length' => 3,
+ 'Foo' => 'Bar'
+ ));
+
+ return array($logPlugin, $request, $response);
+ }
+
+ /**
+ * @return CurlHandle
+ */
+ protected function getMockHandle()
+ {
+ $handle = $this->getMockBuilder('Guzzle\Http\Curl\CurlHandle')
+ ->disableOriginalConstructor()
+ ->setMethods(array('getError', 'getErrorNo', 'getInfo'))
+ ->getMock();
+
+ $handle->expects($this->once())
+ ->method('getError')
+ ->will($this->returnValue('Foo'));
+
+ $handle->expects($this->once())
+ ->method('getErrorNo')
+ ->will($this->returnValue(30));
+
+ $handle->expects($this->any())
+ ->method('getInfo')
+ ->will($this->returnValue(2));
+
+ return $handle;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffPluginTest.php
new file mode 100644
index 0000000..496e49e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/BackoffPluginTest.php
@@ -0,0 +1,297 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Common\Event;
+use Guzzle\Http\Exception\CurlException;
+use Guzzle\Http\Client;
+use Guzzle\Plugin\Backoff\BackoffPlugin;
+use Guzzle\Http\Message\RequestInterface;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Curl\CurlMulti;
+use Guzzle\Http\Curl\CurlMultiInterface;
+use Guzzle\Plugin\Backoff\ConstantBackoffStrategy;
+use Guzzle\Plugin\Backoff\CurlBackoffStrategy;
+use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
+use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy;
+use Symfony\Component\EventDispatcher\EventSubscriberInterface;
+
+/**
+ * @group server
+ * @covers Guzzle\Plugin\Backoff\BackoffPlugin
+ */
+class BackoffPluginTest extends \Guzzle\Tests\GuzzleTestCase implements EventSubscriberInterface
+{
+ protected $retried;
+
+ public function setUp()
+ {
+ $this->retried = false;
+ }
+
+ public static function getSubscribedEvents()
+ {
+ return array(BackoffPlugin::RETRY_EVENT => 'onRequestRetry');
+ }
+
+ public function onRequestRetry(Event $event)
+ {
+ $this->retried = $event;
+ }
+
+ public function testHasEventList()
+ {
+ $this->assertEquals(1, count(BackoffPlugin::getAllEvents()));
+ }
+
+ public function testCreatesDefaultExponentialBackoffPlugin()
+ {
+ $plugin = BackoffPlugin::getExponentialBackoff(3, array(204), array(10));
+ $this->assertInstanceOf('Guzzle\Plugin\Backoff\BackoffPlugin', $plugin);
+ $strategy = $this->readAttribute($plugin, 'strategy');
+ $this->assertInstanceOf('Guzzle\Plugin\Backoff\TruncatedBackoffStrategy', $strategy);
+ $this->assertEquals(3, $this->readAttribute($strategy, 'max'));
+ $strategy = $this->readAttribute($strategy, 'next');
+ $this->assertInstanceOf('Guzzle\Plugin\Backoff\HttpBackoffStrategy', $strategy);
+ $this->assertEquals(array(204 => true), $this->readAttribute($strategy, 'errorCodes'));
+ $strategy = $this->readAttribute($strategy, 'next');
+ $this->assertInstanceOf('Guzzle\Plugin\Backoff\CurlBackoffStrategy', $strategy);
+ $this->assertEquals(array(10 => true), $this->readAttribute($strategy, 'errorCodes'));
+ $strategy = $this->readAttribute($strategy, 'next');
+ $this->assertInstanceOf('Guzzle\Plugin\Backoff\ExponentialBackoffStrategy', $strategy);
+ }
+
+ public function testDoesNotRetryUnlessStrategyReturnsNumber()
+ {
+ $request = new Request('GET', 'http://www.example.com');
+ $request->setState('transfer');
+
+ $mock = $this->getMockBuilder('Guzzle\Plugin\Backoff\BackoffStrategyInterface')
+ ->setMethods(array('getBackoffPeriod'))
+ ->getMockForAbstractClass();
+
+ $mock->expects($this->once())
+ ->method('getBackoffPeriod')
+ ->will($this->returnValue(false));
+
+ $plugin = new BackoffPlugin($mock);
+ $plugin->addSubscriber($this);
+ $plugin->onRequestSent(new Event(array('request' => $request)));
+ $this->assertFalse($this->retried);
+ }
+
+ public function testUpdatesRequestForRetry()
+ {
+ $request = new Request('GET', 'http://www.example.com');
+ $request->setState('transfer');
+ $response = new Response(500);
+ $handle = $this->getMockBuilder('Guzzle\Http\Curl\CurlHandle')->disableOriginalConstructor()->getMock();
+ $e = new CurlException();
+ $e->setCurlHandle($handle);
+
+ $plugin = new BackoffPlugin(new ConstantBackoffStrategy(10));
+ $plugin->addSubscriber($this);
+
+ $event = new Event(array(
+ 'request' => $request,
+ 'response' => $response,
+ 'exception' => $e
+ ));
+
+ $plugin->onRequestSent($event);
+ $this->assertEquals(array(
+ 'request' => $request,
+ 'response' => $response,
+ 'handle' => $handle,
+ 'retries' => 1,
+ 'delay' => 10
+ ), $this->readAttribute($this->retried, 'context'));
+
+ $plugin->onRequestSent($event);
+ $this->assertEquals(array(
+ 'request' => $request,
+ 'response' => $response,
+ 'handle' => $handle,
+ 'retries' => 2,
+ 'delay' => 10
+ ), $this->readAttribute($this->retried, 'context'));
+ }
+
+ public function testDoesNothingWhenNotRetryingAndPollingRequest()
+ {
+ $request = new Request('GET', 'http://www.foo.com');
+ $plugin = new BackoffPlugin(new ConstantBackoffStrategy(10));
+ $plugin->onRequestPoll(new Event(array('request' => $request)));
+ }
+
+ public function testRetriesRequests()
+ {
+ // Create a script to return several 500 and 503 response codes
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata"
+ ));
+
+ $plugin = new BackoffPlugin(
+ new TruncatedBackoffStrategy(3,
+ new HttpBackoffStrategy(null,
+ new CurlBackoffStrategy(null,
+ new ConstantBackoffStrategy(0.05)
+ )
+ )
+ )
+ );
+
+ $client = new Client($this->getServer()->getUrl());
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $request = $client->get();
+ $request->send();
+
+ // Make sure it eventually completed successfully
+ $this->assertEquals(200, $request->getResponse()->getStatusCode());
+ $this->assertEquals('data', $request->getResponse()->getBody(true));
+
+ // Check that three requests were made to retry this request
+ $this->assertEquals(3, count($this->getServer()->getReceivedRequests(false)));
+ $this->assertEquals(2, $request->getParams()->get(BackoffPlugin::RETRY_PARAM));
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\ServerErrorResponseException
+ */
+ public function testFailsOnTruncation()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n"
+ ));
+
+ $plugin = new BackoffPlugin(
+ new TruncatedBackoffStrategy(2,
+ new HttpBackoffStrategy(null,
+ new ConstantBackoffStrategy(0.05)
+ )
+ )
+ );
+
+ $client = new Client($this->getServer()->getUrl());
+ $client->addSubscriber($plugin);
+ $client->get()->send();
+ }
+
+ public function testRetriesRequestsWhenInParallel()
+ {
+ // Create a script to return several 500 and 503 response codes
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata"
+ ));
+
+ $plugin = new BackoffPlugin(
+ new HttpBackoffStrategy(null,
+ new TruncatedBackoffStrategy(3,
+ new CurlBackoffStrategy(null,
+ new ConstantBackoffStrategy(0.1)
+ )
+ )
+ )
+ );
+ $client = new Client($this->getServer()->getUrl());
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $requests = array();
+ for ($i = 0; $i < 5; $i++) {
+ $requests[] = $client->get();
+ }
+ $client->send($requests);
+
+ $this->assertEquals(15, count($this->getServer()->getReceivedRequests(false)));
+ }
+
+ /**
+ * @covers Guzzle\Plugin\Backoff\BackoffPlugin
+ * @covers Guzzle\Http\Curl\CurlMulti
+ */
+ public function testRetriesPooledRequestsUsingDelayAndPollingEvent()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 500 Internal Server Error\r\nContent-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\ndata"
+ ));
+ // Need to sleep for some time ensure that the polling works correctly in the observer
+ $plugin = new BackoffPlugin(new HttpBackoffStrategy(null,
+ new TruncatedBackoffStrategy(1,
+ new ConstantBackoffStrategy(0.5))));
+
+ $client = new Client($this->getServer()->getUrl());
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $request = $client->get();
+ $request->send();
+ // Make sure it eventually completed successfully
+ $this->assertEquals('data', $request->getResponse()->getBody(true));
+ // Check that two requests were made to retry this request
+ $this->assertEquals(2, count($this->getServer()->getReceivedRequests(false)));
+ }
+
+ public function testSeeksToBeginningOfRequestBodyWhenRetrying()
+ {
+ // Create a request with a body
+ $request = new EntityEnclosingRequest('PUT', 'http://www.example.com');
+ $request->setBody('abc');
+ // Set the retry time to be something that will be retried always
+ $request->getParams()->set(BackoffPlugin::DELAY_PARAM, 2);
+ // Seek to the end of the stream
+ $request->getBody()->seek(3);
+ $this->assertEquals('', $request->getBody()->read(1));
+ // Create a plugin that does not delay when retrying
+ $plugin = new BackoffPlugin(new ConstantBackoffStrategy(0));
+ $plugin->onRequestPoll($this->getMockEvent($request));
+ // Ensure that the stream was seeked to 0
+ $this->assertEquals('a', $request->getBody()->read(1));
+ }
+
+ public function testDoesNotSeekOnRequestsWithNoBodyWhenRetrying()
+ {
+ // Create a request with a body
+ $request = new EntityEnclosingRequest('PUT', 'http://www.example.com');
+ $request->getParams()->set(BackoffPlugin::DELAY_PARAM, 2);
+ $plugin = new BackoffPlugin(new ConstantBackoffStrategy(0));
+ $plugin->onRequestPoll($this->getMockEvent($request));
+ }
+
+ protected function getMockEvent(RequestInterface $request)
+ {
+ // Create a mock curl multi object
+ $multi = $this->getMockBuilder('Guzzle\Http\Curl\CurlMulti')
+ ->setMethods(array('remove', 'add'))
+ ->getMock();
+
+ // Create an event that is expected for the Poll event
+ $event = new Event(array(
+ 'request' => $request,
+ 'curl_multi' => $multi
+ ));
+ $event->setName(CurlMultiInterface::POLLING_REQUEST);
+
+ return $event;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CallbackBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CallbackBackoffStrategyTest.php
new file mode 100644
index 0000000..c0ce10d
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CallbackBackoffStrategyTest.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Plugin\Backoff\CallbackBackoffStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\CallbackBackoffStrategy
+ */
+class CallbackBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testEnsuresIsCallable()
+ {
+ $strategy = new CallbackBackoffStrategy(new \stdClass(), true);
+ }
+
+ public function testRetriesWithCallable()
+ {
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $strategy = new CallbackBackoffStrategy(function () { return 10; }, true);
+ $this->assertTrue($strategy->makesDecision());
+ $this->assertEquals(10, $strategy->getBackoffPeriod(0, $request));
+ // Ensure it chains correctly when null is returned
+ $strategy = new CallbackBackoffStrategy(function () { return null; }, false);
+ $this->assertFalse($strategy->makesDecision());
+ $this->assertFalse($strategy->getBackoffPeriod(0, $request));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ConstantBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ConstantBackoffStrategyTest.php
new file mode 100644
index 0000000..703eb4a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ConstantBackoffStrategyTest.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Plugin\Backoff\ConstantBackoffStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\ConstantBackoffStrategy
+ */
+class ConstantBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRetriesWithConstantDelay()
+ {
+ $strategy = new ConstantBackoffStrategy(3.5);
+ $this->assertFalse($strategy->makesDecision());
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $this->assertEquals(3.5, $strategy->getBackoffPeriod(0, $request));
+ $this->assertEquals(3.5, $strategy->getBackoffPeriod(1, $request));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CurlBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CurlBackoffStrategyTest.php
new file mode 100644
index 0000000..0a5c3e2
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/CurlBackoffStrategyTest.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Backoff\CurlBackoffStrategy;
+use Guzzle\Http\Exception\CurlException;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\CurlBackoffStrategy
+ * @covers Guzzle\Plugin\Backoff\AbstractErrorCodeBackoffStrategy
+ */
+class CurlBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRetriesWithExponentialDelay()
+ {
+ $this->assertNotEmpty(CurlBackoffStrategy::getDefaultFailureCodes());
+ $strategy = new CurlBackoffStrategy();
+ $this->assertTrue($strategy->makesDecision());
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $e = new CurlException();
+ $e->setError('foo', CURLE_BAD_CALLING_ORDER);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, null, $e));
+
+ foreach (CurlBackoffStrategy::getDefaultFailureCodes() as $code) {
+ $this->assertEquals(0, $strategy->getBackoffPeriod(0, $request, null, $e->setError('foo', $code)));
+ }
+ }
+
+ public function testIgnoresNonErrors()
+ {
+ $strategy = new CurlBackoffStrategy();
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, new Response(200)));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ExponentialBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ExponentialBackoffStrategyTest.php
new file mode 100644
index 0000000..09965bc
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ExponentialBackoffStrategyTest.php
@@ -0,0 +1,23 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Plugin\Backoff\ExponentialBackoffStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\ExponentialBackoffStrategy
+ */
+class ExponentialBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRetriesWithExponentialDelay()
+ {
+ $strategy = new ExponentialBackoffStrategy();
+ $this->assertFalse($strategy->makesDecision());
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $this->assertEquals(1, $strategy->getBackoffPeriod(0, $request));
+ $this->assertEquals(2, $strategy->getBackoffPeriod(1, $request));
+ $this->assertEquals(4, $strategy->getBackoffPeriod(2, $request));
+ $this->assertEquals(8, $strategy->getBackoffPeriod(3, $request));
+ $this->assertEquals(16, $strategy->getBackoffPeriod(4, $request));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/HttpBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/HttpBackoffStrategyTest.php
new file mode 100644
index 0000000..ae68a4e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/HttpBackoffStrategyTest.php
@@ -0,0 +1,47 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
+use Guzzle\Http\Message\Response;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\HttpBackoffStrategy
+ * @covers Guzzle\Plugin\Backoff\AbstractErrorCodeBackoffStrategy
+ */
+class HttpBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRetriesWhenCodeMatches()
+ {
+ $this->assertNotEmpty(HttpBackoffStrategy::getDefaultFailureCodes());
+ $strategy = new HttpBackoffStrategy();
+ $this->assertTrue($strategy->makesDecision());
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+
+ $response = new Response(200);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, $response));
+ $response->setStatus(400);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, $response));
+
+ foreach (HttpBackoffStrategy::getDefaultFailureCodes() as $code) {
+ $this->assertEquals(0, $strategy->getBackoffPeriod(0, $request, $response->setStatus($code)));
+ }
+ }
+
+ public function testAllowsCustomCodes()
+ {
+ $strategy = new HttpBackoffStrategy(array(204));
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $response = new Response(204);
+ $this->assertEquals(0, $strategy->getBackoffPeriod(0, $request, $response));
+ $response->setStatus(500);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, $response));
+ }
+
+ public function testIgnoresNonErrors()
+ {
+ $strategy = new HttpBackoffStrategy();
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/LinearBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/LinearBackoffStrategyTest.php
new file mode 100644
index 0000000..b4ce8e4
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/LinearBackoffStrategyTest.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Plugin\Backoff\LinearBackoffStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\LinearBackoffStrategy
+ */
+class LinearBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRetriesWithLinearDelay()
+ {
+ $strategy = new LinearBackoffStrategy(5);
+ $this->assertFalse($strategy->makesDecision());
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $this->assertEquals(0, $strategy->getBackoffPeriod(0, $request));
+ $this->assertEquals(5, $strategy->getBackoffPeriod(1, $request));
+ $this->assertEquals(10, $strategy->getBackoffPeriod(2, $request));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ReasonPhraseBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ReasonPhraseBackoffStrategyTest.php
new file mode 100644
index 0000000..dea5a68
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/ReasonPhraseBackoffStrategyTest.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Plugin\Backoff\ReasonPhraseBackoffStrategy;
+use Guzzle\Http\Message\Response;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\ReasonPhraseBackoffStrategy
+ * @covers Guzzle\Plugin\Backoff\AbstractErrorCodeBackoffStrategy
+ */
+class ReasonPhraseBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRetriesWhenCodeMatches()
+ {
+ $this->assertEmpty(ReasonPhraseBackoffStrategy::getDefaultFailureCodes());
+ $strategy = new ReasonPhraseBackoffStrategy(array('Foo', 'Internal Server Error'));
+ $this->assertTrue($strategy->makesDecision());
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $response = new Response(200);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request, $response));
+ $response->setStatus(200, 'Foo');
+ $this->assertEquals(0, $strategy->getBackoffPeriod(0, $request, $response));
+ }
+
+ public function testIgnoresNonErrors()
+ {
+ $strategy = new ReasonPhraseBackoffStrategy();
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $this->assertEquals(false, $strategy->getBackoffPeriod(0, $request));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/TruncatedBackoffStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/TruncatedBackoffStrategyTest.php
new file mode 100644
index 0000000..5590dfb
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Backoff/TruncatedBackoffStrategyTest.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Backoff;
+
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Backoff\TruncatedBackoffStrategy;
+use Guzzle\Plugin\Backoff\HttpBackoffStrategy;
+use Guzzle\Plugin\Backoff\ConstantBackoffStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Backoff\TruncatedBackoffStrategy
+ */
+class TruncatedBackoffStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testRetriesWhenLessThanMax()
+ {
+ $strategy = new TruncatedBackoffStrategy(2);
+ $this->assertTrue($strategy->makesDecision());
+ $request = $this->getMock('Guzzle\Http\Message\Request', array(), array(), '', false);
+ $this->assertFalse($strategy->getBackoffPeriod(0, $request));
+ $this->assertFalse($strategy->getBackoffPeriod(1, $request));
+ $this->assertFalse($strategy->getBackoffPeriod(2, $request));
+
+ $response = new Response(500);
+ $strategy->setNext(new HttpBackoffStrategy(null, new ConstantBackoffStrategy(10)));
+ $this->assertEquals(10, $strategy->getBackoffPeriod(0, $request, $response));
+ $this->assertEquals(10, $strategy->getBackoffPeriod(1, $request, $response));
+ $this->assertFalse($strategy->getBackoffPeriod(2, $request, $response));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CachePluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CachePluginTest.php
new file mode 100644
index 0000000..69da60a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CachePluginTest.php
@@ -0,0 +1,441 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cache;
+
+use Guzzle\Common\Event;
+use Guzzle\Common\Version;
+use Guzzle\Cache\DoctrineCacheAdapter;
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Cache\CachePlugin;
+use Guzzle\Plugin\Cache\DefaultCacheStorage;
+use Guzzle\Plugin\Cache\CallbackCanCacheStrategy;
+use Doctrine\Common\Cache\ArrayCache;
+
+/**
+ * @group server
+ * @covers Guzzle\Plugin\Cache\CachePlugin
+ * @covers Guzzle\Plugin\Cache\DefaultRevalidation
+ */
+class CachePluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testAddsDefaultStorage()
+ {
+ $plugin = new CachePlugin();
+ $this->assertInstanceOf('Guzzle\Plugin\Cache\CacheStorageInterface', $this->readAttribute($plugin, 'storage'));
+ }
+
+ public function testAddsDefaultCollaborators()
+ {
+ $this->assertNotEmpty(CachePlugin::getSubscribedEvents());
+ $plugin = new CachePlugin(array(
+ 'storage' => $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')->getMockForAbstractClass()
+ ));
+ $this->assertInstanceOf('Guzzle\Plugin\Cache\CacheStorageInterface', $this->readAttribute($plugin, 'storage'));
+ $this->assertInstanceOf(
+ 'Guzzle\Plugin\Cache\CanCacheStrategyInterface',
+ $this->readAttribute($plugin, 'canCache')
+ );
+ $this->assertInstanceOf(
+ 'Guzzle\Plugin\Cache\RevalidationInterface',
+ $this->readAttribute($plugin, 'revalidation')
+ );
+ }
+
+ public function testAddsCallbackCollaborators()
+ {
+ $this->assertNotEmpty(CachePlugin::getSubscribedEvents());
+ $plugin = new CachePlugin(array('can_cache' => function () {}));
+ $this->assertInstanceOf(
+ 'Guzzle\Plugin\Cache\CallbackCanCacheStrategy',
+ $this->readAttribute($plugin, 'canCache')
+ );
+ }
+
+ public function testCanPassCacheAsOnlyArgumentToConstructor()
+ {
+ $p = new CachePlugin(new DoctrineCacheAdapter(new ArrayCache()));
+ $p = new CachePlugin(new DefaultCacheStorage(new DoctrineCacheAdapter(new ArrayCache())));
+ }
+
+ public function testUsesCreatedCacheStorage()
+ {
+ $plugin = new CachePlugin(array(
+ 'adapter' => $this->getMockBuilder('Guzzle\Cache\CacheAdapterInterface')->getMockForAbstractClass()
+ ));
+ $this->assertInstanceOf('Guzzle\Plugin\Cache\CacheStorageInterface', $this->readAttribute($plugin, 'storage'));
+ }
+
+ public function testUsesProvidedOptions()
+ {
+ $can = $this->getMockBuilder('Guzzle\Plugin\Cache\CanCacheStrategyInterface')->getMockForAbstractClass();
+ $revalidate = $this->getMockBuilder('Guzzle\Plugin\Cache\RevalidationInterface')->getMockForAbstractClass();
+ $plugin = new CachePlugin(array(
+ 'storage' => $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')->getMockForAbstractClass(),
+ 'can_cache' => $can,
+ 'revalidation' => $revalidate
+ ));
+ $this->assertSame($can, $this->readAttribute($plugin, 'canCache'));
+ $this->assertSame($revalidate, $this->readAttribute($plugin, 'revalidation'));
+ }
+
+ public function satisfyProvider()
+ {
+ $req1 = new Request('GET', 'http://foo.com', array('Cache-Control' => 'no-cache'));
+
+ return array(
+ // The response is too old to satisfy the request
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'max-age=20')), new Response(200, array('Age' => 100)), false, false),
+ // The response cannot satisfy the request because it is stale
+ array(new Request('GET', 'http://foo.com'), new Response(200, array('Cache-Control' => 'max-age=10', 'Age' => 100)), false, false),
+ // Allows the expired response to satisfy the request because of the max-stale
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'max-stale=15')), new Response(200, array('Cache-Control' => 'max-age=90', 'Age' => 100)), true, false),
+ // Max stale is > than the allowed staleness
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'max-stale=5')), new Response(200, array('Cache-Control' => 'max-age=90', 'Age' => 100)), false, false),
+ // Performs cache revalidation
+ array($req1, new Response(200), true, true),
+ // Performs revalidation due to ETag on the response and no cache-control on the request
+ array(new Request('GET', 'http://foo.com'), new Response(200, array(
+ 'ETag' => 'ABC',
+ 'Expires' => date('c', strtotime('+1 year'))
+ )), true, true),
+ );
+ }
+
+ /**
+ * @dataProvider satisfyProvider
+ */
+ public function testChecksIfResponseCanSatisfyRequest($request, $response, $can, $revalidates)
+ {
+ $didRevalidate = false;
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')->getMockForAbstractClass();
+ $revalidate = $this->getMockBuilder('Guzzle\Plugin\Cache\DefaultRevalidation')
+ ->setMethods(array('revalidate'))
+ ->setConstructorArgs(array($storage))
+ ->getMockForAbstractClass();
+
+ $revalidate->expects($this->any())
+ ->method('revalidate')
+ ->will($this->returnCallback(function () use (&$didRevalidate) {
+ $didRevalidate = true;
+ return true;
+ }));
+
+ $plugin = new CachePlugin(array(
+ 'storage' => $storage,
+ 'revalidation' => $revalidate
+ ));
+
+ $this->assertEquals($can, $plugin->canResponseSatisfyRequest($request, $response));
+ $this->assertEquals($didRevalidate, $revalidates);
+ }
+
+ public function satisfyFailedProvider()
+ {
+ return array(
+ // Neither has stale-if-error
+ array(new Request('GET', 'http://foo.com', array()), new Response(200, array('Age' => 100)), false),
+ // Request has stale-if-error
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'stale-if-error')), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50')), true),
+ // Request has valid stale-if-error
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'stale-if-error=50')), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50')), true),
+ // Request has expired stale-if-error
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'stale-if-error=20')), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50')), false),
+ // Response has permanent stale-if-error
+ array(new Request('GET', 'http://foo.com', array()), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50, stale-if-error', )), true),
+ // Response has valid stale-if-error
+ array(new Request('GET', 'http://foo.com', array()), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50, stale-if-error=50')), true),
+ // Response has expired stale-if-error
+ array(new Request('GET', 'http://foo.com', array()), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50, stale-if-error=20')), false),
+ // Request has valid stale-if-error but response does not
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'stale-if-error=50')), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50, stale-if-error=20')), false),
+ // Response has valid stale-if-error but request does not
+ array(new Request('GET', 'http://foo.com', array('Cache-Control' => 'stale-if-error=20')), new Response(200, array('Age' => 100, 'Cache-Control' => 'max-age=50, stale-if-error=50')), false),
+ );
+ }
+
+ /**
+ * @dataProvider satisfyFailedProvider
+ */
+ public function testChecksIfResponseCanSatisfyFailedRequest($request, $response, $can)
+ {
+ $plugin = new CachePlugin();
+
+ $this->assertEquals($can, $plugin->canResponseSatisfyFailedRequest($request, $response));
+ }
+
+ public function testDoesNothingWhenRequestIsNotCacheable()
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('fetch'))
+ ->getMockForAbstractClass();
+ $storage->expects($this->never())->method('fetch');
+
+ $plugin = new CachePlugin(array(
+ 'storage' => $storage,
+ 'can_cache' => new CallbackCanCacheStrategy(function () { return false; })
+ ));
+
+ $plugin->onRequestBeforeSend(new Event(array(
+ 'request' => new Request('GET', 'http://foo.com')
+ )));
+ }
+
+ public function satisfiableProvider()
+ {
+ $date = new \DateTime('-10 seconds');
+
+ return array(
+ // Fresh response
+ array(new Response(200, array(), 'foo')),
+ // Stale response
+ array(new Response(200, array('Date' => $date->format('c'), 'Cache-Control' => 'max-age=5'), 'foo'))
+ );
+ }
+
+ /**
+ * @dataProvider satisfiableProvider
+ */
+ public function testInjectsSatisfiableResponses($response)
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('fetch'))
+ ->getMockForAbstractClass();
+
+ $storage->expects($this->once())->method('fetch')->will($this->returnValue($response));
+ $plugin = new CachePlugin(array('storage' => $storage));
+ $request = new Request('GET', 'http://foo.com', array('Cache-Control' => 'max-stale'));
+ $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
+ $plugin->onRequestSent(new Event(array('request' => $request, 'response' => $request->getResponse())));
+ $this->assertEquals($response->getStatusCode(), $request->getResponse()->getStatusCode());
+ $this->assertEquals((string) $response->getBody(), (string) $request->getResponse()->getBody());
+ $this->assertTrue($request->getResponse()->hasHeader('Age'));
+ if ($request->getResponse()->isFresh() === false) {
+ $this->assertContains('110', (string) $request->getResponse()->getHeader('Warning'));
+ }
+ $this->assertSame(
+ sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION),
+ (string) $request->getHeader('Via')
+ );
+ $this->assertSame(
+ sprintf('%s GuzzleCache/%s',$request->getProtocolVersion(), Version::VERSION),
+ (string) $request->getResponse()->getHeader('Via')
+ );
+ $this->assertTrue($request->getParams()->get('cache.lookup'));
+ $this->assertTrue($request->getParams()->get('cache.hit'));
+ $this->assertTrue($request->getResponse()->hasHeader('X-Cache-Lookup'));
+ $this->assertTrue($request->getResponse()->hasHeader('X-Cache'));
+ $this->assertEquals('HIT from GuzzleCache', (string) $request->getResponse()->getHeader('X-Cache'));
+ $this->assertEquals('HIT from GuzzleCache', (string) $request->getResponse()->getHeader('X-Cache-Lookup'));
+ }
+
+ public function satisfiableOnErrorProvider()
+ {
+ $date = new \DateTime('-10 seconds');
+ return array(
+ array(
+ new Response(200, array(
+ 'Date' => $date->format('c'),
+ 'Cache-Control' => 'max-age=5, stale-if-error'
+ ), 'foo'),
+ )
+ );
+ }
+
+ /**
+ * @dataProvider satisfiableOnErrorProvider
+ */
+ public function testInjectsSatisfiableResponsesOnError($cacheResponse)
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('fetch'))
+ ->getMockForAbstractClass();
+ $storage->expects($this->exactly(2))->method('fetch')->will($this->returnValue($cacheResponse));
+ $plugin = new CachePlugin(array('storage' => $storage));
+ $request = new Request('GET', 'http://foo.com', array('Cache-Control' => 'max-stale'));
+ $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
+ $plugin->onRequestError(
+ $event = new Event(array(
+ 'request' => $request,
+ 'response' => $request->getResponse(),
+ ))
+ );
+ $response = $event['response'];
+ $this->assertEquals($cacheResponse->getStatusCode(), $response->getStatusCode());
+ $this->assertEquals((string) $cacheResponse->getBody(), (string) $response->getBody());
+ $this->assertTrue($response->hasHeader('Age'));
+ if ($response->isFresh() === false) {
+ $this->assertContains('110', (string) $response->getHeader('Warning'));
+ }
+ $this->assertSame(sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION), (string) $request->getHeader('Via'));
+ $this->assertSame(sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION), (string) $response->getHeader('Via'));
+ $this->assertTrue($request->getParams()->get('cache.lookup'));
+ $this->assertSame('error', $request->getParams()->get('cache.hit'));
+ $this->assertTrue($response->hasHeader('X-Cache-Lookup'));
+ $this->assertTrue($response->hasHeader('X-Cache'));
+ $this->assertEquals('HIT from GuzzleCache', (string) $response->getHeader('X-Cache-Lookup'));
+ $this->assertEquals('HIT_ERROR from GuzzleCache', (string) $response->getHeader('X-Cache'));
+ }
+
+ /**
+ * @dataProvider satisfiableOnErrorProvider
+ */
+ public function testInjectsSatisfiableResponsesOnException($cacheResponse)
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('fetch'))
+ ->getMockForAbstractClass();
+ $storage->expects($this->exactly(2))->method('fetch')->will($this->returnValue($cacheResponse));
+ $plugin = new CachePlugin(array('storage' => $storage));
+ $request = new Request('GET', 'http://foo.com', array('Cache-Control' => 'max-stale'));
+ $plugin->onRequestBeforeSend(new Event(array(
+ 'request' => $request
+ )));
+ $plugin->onRequestException(
+ new Event(array(
+ 'request' => $request,
+ 'response' => $request->getResponse(),
+ 'exception' => $this->getMock('Guzzle\Http\Exception\CurlException'),
+ ))
+ );
+ $plugin->onRequestSent(
+ new Event(array(
+ 'request' => $request,
+ 'response' => $response = $request->getResponse(),
+ ))
+ );
+ $this->assertEquals($cacheResponse->getStatusCode(), $response->getStatusCode());
+ $this->assertEquals((string) $cacheResponse->getBody(), (string) $response->getBody());
+ $this->assertTrue($response->hasHeader('Age'));
+ if ($response->isFresh() === false) {
+ $this->assertContains('110', (string) $response->getHeader('Warning'));
+ }
+ $this->assertSame(sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION), (string) $request->getHeader('Via'));
+ $this->assertSame(sprintf('%s GuzzleCache/%s', $request->getProtocolVersion(), Version::VERSION), (string) $response->getHeader('Via'));
+ $this->assertTrue($request->getParams()->get('cache.lookup'));
+ $this->assertSame('error', $request->getParams()->get('cache.hit'));
+ $this->assertTrue($response->hasHeader('X-Cache-Lookup'));
+ $this->assertTrue($response->hasHeader('X-Cache'));
+ $this->assertEquals('HIT from GuzzleCache', (string) $response->getHeader('X-Cache-Lookup'));
+ $this->assertEquals('HIT_ERROR from GuzzleCache', (string) $response->getHeader('X-Cache'));
+ }
+
+ public function unsatisfiableOnErrorProvider()
+ {
+ $date = new \DateTime('-10 seconds');
+
+ return array(
+ // no-store on request
+ array(
+ false,
+ array('Cache-Control' => 'no-store'),
+ new Response(200, array('Date' => $date->format('D, d M Y H:i:s T'), 'Cache-Control' => 'max-age=5, stale-if-error'), 'foo'),
+ ),
+ // request expired
+ array(
+ true,
+ array('Cache-Control' => 'stale-if-error=4'),
+ new Response(200, array('Date' => $date->format('D, d M Y H:i:s T'), 'Cache-Control' => 'max-age=5, stale-if-error'), 'foo'),
+ ),
+ // response expired
+ array(
+ true,
+ array('Cache-Control' => 'stale-if-error'),
+ new Response(200, array('Date' => $date->format('D, d M Y H:i:s T'), 'Cache-Control' => 'max-age=5, stale-if-error=4'), 'foo'),
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider unsatisfiableOnErrorProvider
+ */
+ public function testDoesNotInjectUnsatisfiableResponsesOnError($requestCanCache, $requestHeaders, $cacheResponse)
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('fetch'))
+ ->getMockForAbstractClass();
+ $storage->expects($this->exactly($requestCanCache ? 2 : 0))->method('fetch')->will($this->returnValue($cacheResponse));
+ $plugin = new CachePlugin(array('storage' => $storage));
+ $request = new Request('GET', 'http://foo.com', $requestHeaders);
+ $plugin->onRequestBeforeSend(new Event(array(
+ 'request' => $request
+ )));
+ $plugin->onRequestError(
+ $event = new Event(array(
+ 'request' => $request,
+ 'response' => $response = $request->getResponse(),
+ ))
+ );
+
+ $this->assertSame($response, $event['response']);
+ }
+
+ /**
+ * @dataProvider unsatisfiableOnErrorProvider
+ */
+ public function testDoesNotInjectUnsatisfiableResponsesOnException($requestCanCache, $requestHeaders, $responseParts)
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('fetch'))
+ ->getMockForAbstractClass();
+ $storage->expects($this->exactly($requestCanCache ? 2 : 0))->method('fetch')->will($this->returnValue($responseParts));
+ $plugin = new CachePlugin(array('storage' => $storage));
+ $request = new Request('GET', 'http://foo.com', $requestHeaders);
+ $plugin->onRequestBeforeSend(new Event(array(
+ 'request' => $request
+ )));
+ $plugin->onRequestException(
+ $event = new Event(array(
+ 'request' => $request,
+ 'response' => $response = $request->getResponse(),
+ 'exception' => $this->getMock('Guzzle\Http\Exception\CurlException'),
+ ))
+ );
+
+ $this->assertSame($response, $request->getResponse());
+ }
+
+ public function testCachesResponsesWhenCacheable()
+ {
+ $cache = new ArrayCache();
+ $plugin = new CachePlugin($cache);
+
+ $request = new Request('GET', 'http://foo.com');
+ $response = new Response(200, array(), 'Foo');
+ $plugin->onRequestBeforeSend(new Event(array(
+ 'request' => $request
+ )));
+ $plugin->onRequestSent(new Event(array(
+ 'request' => $request,
+ 'response' => $response
+ )));
+ $data = $this->readAttribute($cache, 'data');
+ $this->assertNotEmpty($data);
+ }
+
+ public function testPurgesRequests()
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('purge'))
+ ->getMockForAbstractClass();
+ $storage->expects($this->atLeastOnce())->method('purge');
+ $plugin = new CachePlugin(array('storage' => $storage));
+ $request = new Request('GET', 'http://foo.com', array('X-Foo' => 'Bar'));
+ $plugin->purge($request);
+ }
+
+ public function testAutoPurgesRequests()
+ {
+ $storage = $this->getMockBuilder('Guzzle\Plugin\Cache\CacheStorageInterface')
+ ->setMethods(array('purge'))
+ ->getMockForAbstractClass();
+ $storage->expects($this->atLeastOnce())->method('purge');
+ $plugin = new CachePlugin(array('storage' => $storage, 'auto_purge' => true));
+ $client = new Client();
+ $request = $client->put('http://foo.com', array('X-Foo' => 'Bar'));
+ $request->addSubscriber($plugin);
+ $request->setResponse(new Response(200), true);
+ $request->send();
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CallbackCanCacheStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CallbackCanCacheStrategyTest.php
new file mode 100644
index 0000000..f3d9baf
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/CallbackCanCacheStrategyTest.php
@@ -0,0 +1,72 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cache;
+
+use Doctrine\Common\Cache\ArrayCache;
+use Guzzle\Cache\DoctrineCacheAdapter;
+use Guzzle\Common\Event;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Cache\CachePlugin;
+use Guzzle\Plugin\Cache\CallbackCanCacheStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Cache\CallbackCanCacheStrategy
+ */
+class CallbackCanCacheStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testConstructorEnsuresCallbackIsCallable()
+ {
+ $p = new CallbackCanCacheStrategy(new \stdClass());
+ }
+
+ public function testUsesCallback()
+ {
+ $c = new CallbackCanCacheStrategy(function ($request) { return true; });
+ $this->assertTrue($c->canCacheRequest(new Request('DELETE', 'http://www.foo.com')));
+ }
+
+ /**
+ * The following is a bit of an integration test to ensure that the CachePlugin honors a
+ * custom can cache strategy.
+ */
+ public function testIntegrationWithCachePlugin()
+ {
+ $c = new CallbackCanCacheStrategy(
+ function ($request) { return true; },
+ function ($response) { return true; }
+ );
+
+ // Make a request and response that have no business being cached
+ $request = new Request('DELETE', 'http://www.foo.com');
+ $response = Response::fromMessage(
+ "HTTP/1.1 200 OK\r\n"
+ . "Expires: Mon, 26 Jul 1997 05:00:00 GMT\r\n"
+ . "Last-Modified: Wed, 09 Jan 2013 08:48:53 GMT\r\n"
+ . "Content-Length: 2\r\n"
+ . "Cache-Control: no-store, no-cache, must-revalidate, post-check=0, pre-check=0\r\n\r\n"
+ . "hi"
+ );
+
+ $this->assertTrue($c->canCacheRequest($request));
+ $this->assertTrue($c->canCacheResponse($response));
+
+ $s = $this->getMockBuilder('Guzzle\Plugin\Cache\DefaultCacheStorage')
+ ->setConstructorArgs(array(new DoctrineCacheAdapter(new ArrayCache())))
+ ->setMethods(array('fetch'))
+ ->getMockForAbstractClass();
+
+ $s->expects($this->once())
+ ->method('fetch')
+ ->will($this->returnValue($response));
+
+ $plugin = new CachePlugin(array('can_cache' => $c, 'storage' => $s));
+ $plugin->onRequestBeforeSend(new Event(array('request' => $request)));
+
+ $this->assertEquals(200, $request->getResponse()->getStatusCode());
+ $this->assertEquals('hi', $request->getResponse()->getBody(true));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php
new file mode 100644
index 0000000..701a015
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCacheStorageTest.php
@@ -0,0 +1,193 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cache;
+
+use Guzzle\Cache\DoctrineCacheAdapter;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Cache\DefaultCacheStorage;
+use Doctrine\Common\Cache\ArrayCache;
+
+/**
+ * @covers Guzzle\Plugin\Cache\DefaultCacheStorage
+ */
+class DefaultCacheStorageTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected function getCache()
+ {
+ $a = new ArrayCache();
+ $c = new DoctrineCacheAdapter($a);
+ $s = new DefaultCacheStorage($c);
+ $request = new Request('GET', 'http://foo.com', array('Accept' => 'application/json'));
+ $response = new Response(200, array(
+ 'Content-Type' => 'application/json',
+ 'Connection' => 'close',
+ 'X-Foo' => 'Bar',
+ 'Vary' => 'Accept'
+ ), 'test');
+ $s->cache($request, $response);
+ $data = $this->readAttribute($a, 'data');
+
+ return array(
+ 'cache' => $a,
+ 'adapter' => $c,
+ 'storage' => $s,
+ 'request' => $request,
+ 'response' => $response,
+ 'serialized' => end($data)
+ );
+ }
+
+ public function testReturnsNullForCacheMiss()
+ {
+ $cache = $this->getCache();
+ $this->assertNull($cache['storage']->fetch(new Request('GET', 'http://test.com')));
+ }
+
+ public function testCachesRequests()
+ {
+ $cache = $this->getCache();
+ $foundRequest = $foundBody = $bodyKey = false;
+ foreach ($this->readAttribute($cache['cache'], 'data') as $key => $v) {
+ if (strpos($v, 'foo.com')) {
+ $foundRequest = true;
+ $data = unserialize($v);
+ $bodyKey = $data[0][3];
+ $this->assertInternalType('integer', $data[0][4]);
+ $this->assertFalse(isset($data[0][0]['connection']));
+ $this->assertEquals('foo.com', $data[0][0]['host']);
+ } elseif ($v == 'test') {
+ $foundBody = $key;
+ }
+ }
+ $this->assertContains($bodyKey, $foundBody);
+ $this->assertTrue($foundRequest);
+ }
+
+ public function testFetchesResponse()
+ {
+ $cache = $this->getCache();
+ $response = $cache['storage']->fetch($cache['request']);
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertFalse($response->hasHeader('Connection'));
+ $this->assertEquals('Bar', (string) $response->getHeader('X-Foo'));
+ $this->assertEquals('test', (string) $response->getBody());
+ $this->assertTrue(in_array($cache['serialized'], $this->readAttribute($cache['cache'], 'data')));
+ }
+
+ public function testDeletesRequestItemsAndBody()
+ {
+ $cache = $this->getCache();
+ $cache['storage']->delete($cache['request']);
+ $this->assertFalse(in_array('test', $this->readAttribute($cache['cache'], 'data')));
+ $this->assertFalse(in_array($cache['serialized'], $this->readAttribute($cache['cache'], 'data')));
+ }
+
+ public function testCachesMultipleRequestsWithVary()
+ {
+ $cache = $this->getCache();
+ $cache['request']->setHeader('Accept', 'application/xml');
+ $response = $cache['response']->setHeader('Content-Type', 'application/xml');
+ $response->setBody('123');
+ $cache['storage']->cache($cache['request'], $response);
+ $data = $this->readAttribute($cache['cache'], 'data');
+ foreach ($data as $v) {
+ if (strpos($v, 'foo.com')) {
+ $u = unserialize($v);
+ $this->assertEquals(2, count($u));
+ $this->assertEquals($u[0][0]['accept'], 'application/xml');
+ $this->assertEquals($u[0][1]['content-type'], 'application/xml');
+ $this->assertEquals($u[1][0]['accept'], 'application/json');
+ $this->assertEquals($u[1][1]['content-type'], 'application/json');
+ $this->assertNotSame($u[0][3], $u[1][3]);
+ break;
+ }
+ }
+ }
+
+ public function testPurgeRemovesAllMethodCaches()
+ {
+ $cache = $this->getCache();
+ foreach (array('HEAD', 'POST', 'PUT', 'DELETE') as $method) {
+ $request = RequestFactory::getInstance()->cloneRequestWithMethod($cache['request'], $method);
+ $cache['storage']->cache($request, $cache['response']);
+ }
+ $cache['storage']->purge('http://foo.com');
+ $this->assertFalse(in_array('test', $this->readAttribute($cache['cache'], 'data')));
+ $this->assertFalse(in_array($cache['serialized'], $this->readAttribute($cache['cache'], 'data')));
+ $this->assertEquals(
+ array('DoctrineNamespaceCacheKey[]'),
+ array_keys($this->readAttribute($cache['cache'], 'data'))
+ );
+ }
+
+ public function testRemovesExpiredResponses()
+ {
+ $cache = $this->getCache();
+ $request = new Request('GET', 'http://xyz.com');
+ $response = new Response(200, array('Age' => 1000, 'Cache-Control' => 'max-age=-10000'));
+ $cache['storage']->cache($request, $response);
+ $this->assertNull($cache['storage']->fetch($request));
+ $data = $this->readAttribute($cache['cache'], 'data');
+ $this->assertFalse(in_array('xyz.com', $data));
+ $this->assertTrue(in_array($cache['serialized'], $data));
+ }
+
+ public function testUsesVaryToDetermineResult()
+ {
+ $cache = $this->getCache();
+ $this->assertInstanceOf('Guzzle\Http\Message\Response', $cache['storage']->fetch($cache['request']));
+ $request = new Request('GET', 'http://foo.com', array('Accept' => 'application/xml'));
+ $this->assertNull($cache['storage']->fetch($request));
+ }
+
+ public function testEnsuresResponseIsStillPresent()
+ {
+ $cache = $this->getCache();
+ $data = $this->readAttribute($cache['cache'], 'data');
+ $key = array_search('test', $data);
+ $cache['cache']->delete(substr($key, 1, -4));
+ $this->assertNull($cache['storage']->fetch($cache['request']));
+ }
+
+ public function staleProvider()
+ {
+ return array(
+ array(
+ new Request('GET', 'http://foo.com', array('Accept' => 'foo')),
+ new Response(200, array('Cache-Control' => 'stale-if-error=100', 'Vary' => 'Accept'))
+ ),
+ array(
+ new Request('GET', 'http://foo.com', array('Accept' => 'foo')),
+ new Response(200, array('Cache-Control' => 'stale-if-error', 'Vary' => 'Accept'))
+ )
+ );
+ }
+
+ /**
+ * @dataProvider staleProvider
+ */
+ public function testUsesStaleTimeDirectiveForTtd($request, $response)
+ {
+ $cache = $this->getCache();
+ $cache['storage']->cache($request, $response);
+ $data = $this->readAttribute($cache['cache'], 'data');
+ foreach ($data as $v) {
+ if (strpos($v, 'foo.com')) {
+ $u = unserialize($v);
+ $this->assertGreaterThan($u[1][4], $u[0][4]);
+ break;
+ }
+ }
+ }
+
+ public function testCanFilterCacheKeys()
+ {
+ $cache = $this->getCache();
+ $cache['request']->getQuery()->set('auth', 'foo');
+ $this->assertNull($cache['storage']->fetch($cache['request']));
+ $cache['request']->getParams()->set('cache.key_filter', 'auth');
+ $this->assertNotNull($cache['storage']->fetch($cache['request']));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCanCacheStrategyTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCanCacheStrategyTest.php
new file mode 100644
index 0000000..de4d182
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultCanCacheStrategyTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cache;
+
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Cache\DefaultCanCacheStrategy;
+
+/**
+ * @covers Guzzle\Plugin\Cache\DefaultCanCacheStrategy
+ */
+class DefaultCanCacheStrategyTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testReturnsRequestcanCacheRequest()
+ {
+ $strategy = new DefaultCanCacheStrategy();
+ $request = new Request('GET', 'http://foo.com');
+ $this->assertTrue($strategy->canCacheRequest($request));
+ }
+
+ public function testDoesNotCacheNoStore()
+ {
+ $strategy = new DefaultCanCacheStrategy();
+ $request = new Request('GET', 'http://foo.com', array('cache-control' => 'no-store'));
+ $this->assertFalse($strategy->canCacheRequest($request));
+ }
+
+ public function testCanCacheResponse()
+ {
+ $response = $this->getMockBuilder('Guzzle\Http\Message\Response')
+ ->setMethods(array('canCache'))
+ ->setConstructorArgs(array(200))
+ ->getMock();
+ $response->expects($this->once())
+ ->method('canCache')
+ ->will($this->returnValue(true));
+ $strategy = new DefaultCanCacheStrategy();
+ $this->assertTrue($strategy->canCacheResponse($response));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultRevalidationTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultRevalidationTest.php
new file mode 100644
index 0000000..0699cb2
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DefaultRevalidationTest.php
@@ -0,0 +1,248 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cache;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\ClientInterface;
+use Guzzle\Http\Exception\BadResponseException;
+use Guzzle\Http\Exception\CurlException;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Plugin\Cache\CachePlugin;
+use Guzzle\Cache\DoctrineCacheAdapter;
+use Doctrine\Common\Cache\ArrayCache;
+use Guzzle\Plugin\Cache\DefaultCacheStorage;
+use Guzzle\Plugin\Mock\MockPlugin;
+use Guzzle\Tests\Http\Server;
+
+/**
+ * @covers Guzzle\Plugin\Cache\DefaultRevalidation
+ * @group server
+ */
+class DefaultRevalidationTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected function getHttpDate($time)
+ {
+ return gmdate(ClientInterface::HTTP_DATE, strtotime($time));
+ }
+
+ /**
+ * Data provider to test cache revalidation
+ *
+ * @return array
+ */
+ public function cacheRevalidationDataProvider()
+ {
+ return array(
+ // Forces revalidation that passes
+ array(
+ true,
+ "Pragma: no-cache\r\n\r\n",
+ "HTTP/1.1 200 OK\r\nDate: " . $this->getHttpDate('-100 hours') . "\r\nContent-Length: 4\r\n\r\nData",
+ "HTTP/1.1 304 NOT MODIFIED\r\nCache-Control: max-age=2000000\r\nContent-Length: 0\r\n\r\n",
+ ),
+ // Forces revalidation that overwrites what is in cache
+ array(
+ false,
+ "\r\n",
+ "HTTP/1.1 200 OK\r\nCache-Control: must-revalidate, no-cache\r\nDate: " . $this->getHttpDate('-10 hours') . "\r\nContent-Length: 4\r\n\r\nData",
+ "HTTP/1.1 200 OK\r\nContent-Length: 5\r\n\r\nDatas",
+ "HTTP/1.1 200 OK\r\nContent-Length: 5\r\nDate: " . $this->getHttpDate('now') . "\r\n\r\nDatas"
+ ),
+ // Throws an exception during revalidation
+ array(
+ false,
+ "\r\n",
+ "HTTP/1.1 200 OK\r\nCache-Control: no-cache\r\nDate: " . $this->getHttpDate('-3 hours') . "\r\n\r\nData",
+ "HTTP/1.1 500 INTERNAL SERVER ERROR\r\nContent-Length: 0\r\n\r\n"
+ ),
+ // ETag mismatch
+ array(
+ false,
+ "\r\n",
+ "HTTP/1.1 200 OK\r\nCache-Control: no-cache\r\nETag: \"123\"\r\nDate: " . $this->getHttpDate('-10 hours') . "\r\n\r\nData",
+ "HTTP/1.1 304 NOT MODIFIED\r\nETag: \"123456\"\r\n\r\n",
+ ),
+ );
+ }
+
+ /**
+ * @dataProvider cacheRevalidationDataProvider
+ */
+ public function testRevalidatesResponsesAgainstOriginServer($can, $request, $response, $validate = null, $result = null)
+ {
+ // Send some responses to the test server for cache validation
+ $server = $this->getServer();
+ $server->flush();
+
+ if ($validate) {
+ $server->enqueue($validate);
+ }
+
+ $request = RequestFactory::getInstance()->fromMessage("GET / HTTP/1.1\r\nHost: 127.0.0.1:" . $server->getPort() . "\r\n" . $request);
+ $response = Response::fromMessage($response);
+ $request->setClient(new Client());
+
+ $plugin = new CachePlugin(new DoctrineCacheAdapter(new ArrayCache()));
+ $this->assertEquals(
+ $can,
+ $plugin->canResponseSatisfyRequest($request, $response),
+ '-> ' . $request . "\n" . $response
+ );
+
+ if ($result) {
+ $result = Response::fromMessage($result);
+ $result->removeHeader('Date');
+ $request->getResponse()->removeHeader('Date');
+ $request->getResponse()->removeHeader('Connection');
+ // Get rid of dates
+ $this->assertEquals((string) $result, (string) $request->getResponse());
+ }
+
+ if ($validate) {
+ $this->assertEquals(1, count($server->getReceivedRequests()));
+ }
+ }
+
+ public function testHandles404RevalidationResponses()
+ {
+ $request = new Request('GET', 'http://foo.com');
+ $request->setClient(new Client());
+ $badResponse = new Response(404, array(), 'Oh no!');
+ $badRequest = clone $request;
+ $badRequest->setResponse($badResponse, true);
+ $response = new Response(200, array(), 'foo');
+
+ // Seed the cache
+ $s = new DefaultCacheStorage(new DoctrineCacheAdapter(new ArrayCache()));
+ $s->cache($request, $response);
+ $this->assertNotNull($s->fetch($request));
+
+ $rev = $this->getMockBuilder('Guzzle\Plugin\Cache\DefaultRevalidation')
+ ->setConstructorArgs(array($s))
+ ->setMethods(array('createRevalidationRequest'))
+ ->getMock();
+
+ $rev->expects($this->once())
+ ->method('createRevalidationRequest')
+ ->will($this->returnValue($badRequest));
+
+ try {
+ $rev->revalidate($request, $response);
+ $this->fail('Should have thrown an exception');
+ } catch (BadResponseException $e) {
+ $this->assertSame($badResponse, $e->getResponse());
+ $this->assertNull($s->fetch($request));
+ }
+ }
+
+ public function testCanRevalidateWithPlugin()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\n" .
+ "Date: Mon, 12 Nov 2012 03:06:37 GMT\r\n" .
+ "Cache-Control: private, s-maxage=0, max-age=0, must-revalidate\r\n" .
+ "Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
+ "Content-Length: 2\r\n\r\nhi",
+ "HTTP/1.0 304 Not Modified\r\n" .
+ "Date: Mon, 12 Nov 2012 03:06:38 GMT\r\n" .
+ "Content-Type: text/html; charset=UTF-8\r\n" .
+ "Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
+ "Age: 6302\r\n\r\n",
+ "HTTP/1.0 304 Not Modified\r\n" .
+ "Date: Mon, 12 Nov 2012 03:06:38 GMT\r\n" .
+ "Content-Type: text/html; charset=UTF-8\r\n" .
+ "Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
+ "Age: 6302\r\n\r\n",
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $client->addSubscriber(new CachePlugin());
+ $this->assertEquals(200, $client->get()->send()->getStatusCode());
+ $this->assertEquals(200, $client->get()->send()->getStatusCode());
+ $this->assertEquals(200, $client->get()->send()->getStatusCode());
+ $this->assertEquals(3, count($this->getServer()->getReceivedRequests()));
+ }
+
+ public function testCanHandleRevalidationFailures()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $lm = gmdate('c', time() - 60);
+ $mock = new MockPlugin(array(
+ new Response(200, array(
+ 'Date' => $lm,
+ 'Cache-Control' => 'max-age=100, must-revalidate, stale-if-error=9999',
+ 'Last-Modified' => $lm,
+ 'Content-Length' => 2
+ ), 'hi'),
+ new CurlException('Bleh'),
+ new CurlException('Bleh')
+ ));
+ $client->addSubscriber(new CachePlugin());
+ $client->addSubscriber($mock);
+ $client->get()->send();
+ $response = $client->get()->send();
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertEquals('hi', $response->getBody(true));
+ $this->assertEquals(3, count($mock->getReceivedRequests()));
+ $this->assertEquals(0, count($mock->getQueue()));
+ }
+
+ public function testCanHandleStaleIfErrorWhenRevalidating()
+ {
+ $lm = gmdate('c', time() - 60);
+ $mock = new MockPlugin(array(
+ new Response(200, array(
+ 'Date' => $lm,
+ 'Cache-Control' => 'must-revalidate, max-age=0, stale-if-error=1200',
+ 'Last-Modified' => $lm,
+ 'Content-Length' => 2
+ ), 'hi'),
+ new CurlException('Oh no!'),
+ new CurlException('Oh no!')
+ ));
+ $cache = new CachePlugin();
+ $client = new Client('http://www.example.com');
+ $client->addSubscriber($cache);
+ $client->addSubscriber($mock);
+ $this->assertEquals(200, $client->get()->send()->getStatusCode());
+ $response = $client->get()->send();
+ $this->assertEquals(200, $response->getStatusCode());
+ $this->assertCount(0, $mock);
+ $this->assertEquals('HIT from GuzzleCache', (string) $response->getHeader('X-Cache-Lookup'));
+ $this->assertEquals('HIT_ERROR from GuzzleCache', (string) $response->getHeader('X-Cache'));
+ }
+
+ /**
+ * @group issue-437
+ */
+ public function testDoesNotTouchClosureListeners()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\n" .
+ "Date: Mon, 12 Nov 2012 03:06:37 GMT\r\n" .
+ "Cache-Control: private, s-maxage=0, max-age=0, must-revalidate\r\n" .
+ "Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
+ "Content-Length: 2\r\n\r\nhi",
+ "HTTP/1.0 304 Not Modified\r\n" .
+ "Date: Mon, 12 Nov 2012 03:06:38 GMT\r\n" .
+ "Content-Type: text/html; charset=UTF-8\r\n" .
+ "Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
+ "Age: 6302\r\n\r\n",
+ "HTTP/1.0 304 Not Modified\r\n" .
+ "Date: Mon, 12 Nov 2012 03:06:38 GMT\r\n" .
+ "Content-Type: text/html; charset=UTF-8\r\n" .
+ "Last-Modified: Mon, 12 Nov 2012 02:53:38 GMT\r\n" .
+ "Age: 6302\r\n\r\n",
+ ));
+ $client = new Client($this->getServer()->getUrl());
+ $client->addSubscriber(new CachePlugin());
+ $client->getEventDispatcher()->addListener('command.after_send', function(){});
+ $this->assertEquals(200, $client->get()->send()->getStatusCode());
+ $this->assertEquals(200, $client->get()->send()->getStatusCode());
+ $this->assertEquals(200, $client->get()->send()->getStatusCode());
+ }
+
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DenyRevalidationTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DenyRevalidationTest.php
new file mode 100644
index 0000000..9af80f2
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/DenyRevalidationTest.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cache;
+
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Cache\DenyRevalidation;
+
+/**
+ * @covers Guzzle\Plugin\Cache\DenyRevalidation
+ */
+class DenyRevalidationTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testDeniesRequestRevalidation()
+ {
+ $deny = new DenyRevalidation();
+ $this->assertFalse($deny->revalidate(new Request('GET', 'http://foo.com'), new Response(200)));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/SkipRevalidationTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/SkipRevalidationTest.php
new file mode 100644
index 0000000..4bcc04b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cache/SkipRevalidationTest.php
@@ -0,0 +1,19 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cache;
+
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Cache\SkipRevalidation;
+
+/**
+ * @covers Guzzle\Plugin\Cache\SkipRevalidation
+ */
+class SkipRevalidationTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testSkipsRequestRevalidation()
+ {
+ $skip = new SkipRevalidation();
+ $this->assertTrue($skip->revalidate(new Request('GET', 'http://foo.com'), new Response(200)));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/ArrayCookieJarTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/ArrayCookieJarTest.php
new file mode 100644
index 0000000..5d0f668
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/ArrayCookieJarTest.php
@@ -0,0 +1,385 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cookie\CookieJar;
+
+use Guzzle\Plugin\Cookie\Cookie;
+use Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar;
+use Guzzle\Http\Message\Response;
+use Guzzle\Http\Message\Request;
+
+/**
+ * @covers Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar
+ */
+class ArrayCookieJarTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @var ArrayCookieJar
+ */
+ private $jar;
+
+ public function setUp()
+ {
+ $this->jar = new ArrayCookieJar();
+ }
+
+ protected function getTestCookies()
+ {
+ return array(
+ new Cookie(array('name' => 'foo', 'value' => 'bar', 'domain' => 'foo.com', 'path' => '/', 'discard' => true)),
+ new Cookie(array('name' => 'test', 'value' => '123', 'domain' => 'baz.com', 'path' => '/foo', 'expires' => 2)),
+ new Cookie(array('name' => 'you', 'value' => '123', 'domain' => 'bar.com', 'path' => '/boo', 'expires' => time() + 1000))
+ );
+ }
+
+ /**
+ * Provides test data for cookie cookieJar retrieval
+ */
+ public function getCookiesDataProvider()
+ {
+ return array(
+ array(array('foo', 'baz', 'test', 'muppet', 'googoo'), '', '', '', false),
+ array(array('foo', 'baz', 'muppet', 'googoo'), '', '', '', true),
+ array(array('googoo'), 'www.example.com', '', '', false),
+ array(array('muppet', 'googoo'), 'test.y.example.com', '', '', false),
+ array(array('foo', 'baz'), 'example.com', '', '', false),
+ array(array('muppet'), 'x.y.example.com', '/acme/', '', false),
+ array(array('muppet'), 'x.y.example.com', '/acme/test/', '', false),
+ array(array('googoo'), 'x.y.example.com', '/test/acme/test/', '', false),
+ array(array('foo', 'baz'), 'example.com', '', '', false),
+ array(array('baz'), 'example.com', '', 'baz', false),
+ );
+ }
+
+ public function testStoresAndRetrievesCookies()
+ {
+ $cookies = $this->getTestCookies();
+ foreach ($cookies as $cookie) {
+ $this->assertTrue($this->jar->add($cookie));
+ }
+
+ $this->assertEquals(3, count($this->jar));
+ $this->assertEquals(3, count($this->jar->getIterator()));
+ $this->assertEquals($cookies, $this->jar->all(null, null, null, false, false));
+ }
+
+ public function testRemovesExpiredCookies()
+ {
+ $cookies = $this->getTestCookies();
+ foreach ($this->getTestCookies() as $cookie) {
+ $this->jar->add($cookie);
+ }
+ $this->jar->removeExpired();
+ $this->assertEquals(array($cookies[0], $cookies[2]), $this->jar->all());
+ }
+
+ public function testRemovesTemporaryCookies()
+ {
+ $cookies = $this->getTestCookies();
+ foreach ($this->getTestCookies() as $cookie) {
+ $this->jar->add($cookie);
+ }
+ $this->jar->removeTemporary();
+ $this->assertEquals(array($cookies[2]), $this->jar->all());
+ }
+
+ public function testIsSerializable()
+ {
+ $this->assertEquals('[]', $this->jar->serialize());
+ $this->jar->unserialize('[]');
+ $this->assertEquals(array(), $this->jar->all());
+
+ $cookies = $this->getTestCookies();
+ foreach ($this->getTestCookies() as $cookie) {
+ $this->jar->add($cookie);
+ }
+
+ // Remove discard and expired cookies
+ $serialized = $this->jar->serialize();
+ $data = json_decode($serialized, true);
+ $this->assertEquals(1, count($data));
+
+ $a = new ArrayCookieJar();
+ $a->unserialize($serialized);
+ $this->assertEquals(1, count($a));
+ }
+
+ public function testRemovesSelectively()
+ {
+ $cookies = $this->getTestCookies();
+ foreach ($this->getTestCookies() as $cookie) {
+ $this->jar->add($cookie);
+ }
+
+ // Remove foo.com cookies
+ $this->jar->remove('foo.com');
+ $this->assertEquals(2, count($this->jar));
+ // Try again, removing no further cookies
+ $this->jar->remove('foo.com');
+ $this->assertEquals(2, count($this->jar));
+
+ // Remove bar.com cookies with path of /boo
+ $this->jar->remove('bar.com', '/boo');
+ $this->assertEquals(1, count($this->jar));
+
+ // Remove cookie by name
+ $this->jar->remove(null, null, 'test');
+ $this->assertEquals(0, count($this->jar));
+ }
+
+ public function testDoesNotAddIncompleteCookies()
+ {
+ $this->assertEquals(false, $this->jar->add(new Cookie()));
+ $this->assertFalse($this->jar->add(new Cookie(array(
+ 'name' => 'foo'
+ ))));
+ $this->assertFalse($this->jar->add(new Cookie(array(
+ 'name' => false
+ ))));
+ $this->assertFalse($this->jar->add(new Cookie(array(
+ 'name' => true
+ ))));
+ $this->assertFalse($this->jar->add(new Cookie(array(
+ 'name' => 'foo',
+ 'domain' => 'foo.com'
+ ))));
+ }
+
+ public function testDoesAddValidCookies()
+ {
+ $this->assertTrue($this->jar->add(new Cookie(array(
+ 'name' => 'foo',
+ 'domain' => 'foo.com',
+ 'value' => 0
+ ))));
+ $this->assertTrue($this->jar->add(new Cookie(array(
+ 'name' => 'foo',
+ 'domain' => 'foo.com',
+ 'value' => 0.0
+ ))));
+ $this->assertTrue($this->jar->add(new Cookie(array(
+ 'name' => 'foo',
+ 'domain' => 'foo.com',
+ 'value' => '0'
+ ))));
+ }
+
+ public function testOverwritesCookiesThatAreOlderOrDiscardable()
+ {
+ $t = time() + 1000;
+ $data = array(
+ 'name' => 'foo',
+ 'value' => 'bar',
+ 'domain' => '.example.com',
+ 'path' => '/',
+ 'max_age' => '86400',
+ 'port' => array(80, 8080),
+ 'version' => '1',
+ 'secure' => true,
+ 'discard' => true,
+ 'expires' => $t
+ );
+
+ // Make sure that the discard cookie is overridden with the non-discard
+ $this->assertTrue($this->jar->add(new Cookie($data)));
+
+ unset($data['discard']);
+ $this->assertTrue($this->jar->add(new Cookie($data)));
+ $this->assertEquals(1, count($this->jar));
+
+ $c = $this->jar->all();
+ $this->assertEquals(false, $c[0]->getDiscard());
+
+ // Make sure it doesn't duplicate the cookie
+ $this->jar->add(new Cookie($data));
+ $this->assertEquals(1, count($this->jar));
+
+ // Make sure the more future-ful expiration date supersede the other
+ $data['expires'] = time() + 2000;
+ $this->assertTrue($this->jar->add(new Cookie($data)));
+ $this->assertEquals(1, count($this->jar));
+ $c = $this->jar->all();
+ $this->assertNotEquals($t, $c[0]->getExpires());
+ }
+
+ public function testOverwritesCookiesThatHaveChanged()
+ {
+ $t = time() + 1000;
+ $data = array(
+ 'name' => 'foo',
+ 'value' => 'bar',
+ 'domain' => '.example.com',
+ 'path' => '/',
+ 'max_age' => '86400',
+ 'port' => array(80, 8080),
+ 'version' => '1',
+ 'secure' => true,
+ 'discard' => true,
+ 'expires' => $t
+ );
+
+ // Make sure that the discard cookie is overridden with the non-discard
+ $this->assertTrue($this->jar->add(new Cookie($data)));
+
+ $data['value'] = 'boo';
+ $this->assertTrue($this->jar->add(new Cookie($data)));
+ $this->assertEquals(1, count($this->jar));
+
+ // Changing the value plus a parameter also must overwrite the existing one
+ $data['value'] = 'zoo';
+ $data['secure'] = false;
+ $this->assertTrue($this->jar->add(new Cookie($data)));
+ $this->assertEquals(1, count($this->jar));
+
+ $c = $this->jar->all();
+ $this->assertEquals('zoo', $c[0]->getValue());
+ }
+
+ public function testAddsCookiesFromResponseWithNoRequest()
+ {
+ $response = new Response(200, array(
+ 'Set-Cookie' => array(
+ "fpc=d=.Hm.yh4.1XmJWjJfs4orLQzKzPImxklQoxXSHOZATHUSEFciRueW_7704iYUtsXNEXq0M92Px2glMdWypmJ7HIQl6XIUvrZimWjQ3vIdeuRbI.FNQMAfcxu_XN1zSx7l.AcPdKL6guHc2V7hIQFhnjRW0rxm2oHY1P4bGQxFNz7f.tHm12ZD3DbdMDiDy7TBXsuP4DM-&v=2; expires=Fri, 02-Mar-2019 02:17:40 GMT; path=/; domain=127.0.0.1",
+ "FPCK3=AgBNbvoQAGpGEABZLRAAbFsQAF1tEABkDhAAeO0=; expires=Sat, 02-Apr-2019 02:17:40 GMT; path=/; domain=127.0.0.1",
+ "CH=deleted; expires=Wed, 03-Mar-2010 02:17:39 GMT; path=/; domain=127.0.0.1",
+ "CH=AgBNbvoQAAEcEAApuhAAMJcQADQvEAAvGxAALe0QAD6uEAATwhAAC1AQAC8t; expires=Sat, 02-Apr-2019 02:17:40 GMT; path=/; domain=127.0.0.1"
+ )
+ ));
+
+ $this->jar->addCookiesFromResponse($response);
+ $this->assertEquals(3, count($this->jar));
+ $this->assertEquals(1, count($this->jar->all(null, null, 'fpc')));
+ $this->assertEquals(1, count($this->jar->all(null, null, 'FPCK3')));
+ $this->assertEquals(1, count($this->jar->all(null, null, 'CH')));
+ }
+
+ public function testAddsCookiesFromResponseWithRequest()
+ {
+ $response = new Response(200, array(
+ 'Set-Cookie' => "fpc=d=.Hm.yh4.1XmJWjJfs4orLQzKzPImxklQoxXSHOZATHUSEFciRueW_7704iYUtsXNEXq0M92Px2glMdWypmJ7HIQl6XIUvrZimWjQ3vIdeuRbI.FNQMAfcxu_XN1zSx7l.AcPdKL6guHc2V7hIQFhnjRW0rxm2oHY1P4bGQxFNz7f.tHm12ZD3DbdMDiDy7TBXsuP4DM-&v=2; expires=Fri, 02-Mar-2019 02:17:40 GMT;"
+ ));
+ $request = new Request('GET', 'http://www.example.com');
+ $this->jar->addCookiesFromResponse($response, $request);
+ $this->assertEquals(1, count($this->jar));
+ }
+
+ public function getMatchingCookiesDataProvider()
+ {
+ return array(
+ array('https://example.com', array(0)),
+ array('http://example.com', array()),
+ array('https://example.com:8912', array()),
+ array('https://foo.example.com', array(0)),
+ array('http://foo.example.com/test/acme/', array(4))
+ );
+ }
+
+ /**
+ * @dataProvider getMatchingCookiesDataProvider
+ */
+ public function testReturnsCookiesMatchingRequests($url, $cookies)
+ {
+ $bag = array(
+ new Cookie(array(
+ 'name' => 'foo',
+ 'value' => 'bar',
+ 'domain' => 'example.com',
+ 'path' => '/',
+ 'max_age' => '86400',
+ 'port' => array(443, 8080),
+ 'version' => '1',
+ 'secure' => true
+ )),
+ new Cookie(array(
+ 'name' => 'baz',
+ 'value' => 'foobar',
+ 'domain' => 'example.com',
+ 'path' => '/',
+ 'max_age' => '86400',
+ 'port' => array(80, 8080),
+ 'version' => '1',
+ 'secure' => true
+ )),
+ new Cookie(array(
+ 'name' => 'test',
+ 'value' => '123',
+ 'domain' => 'www.foobar.com',
+ 'path' => '/path/',
+ 'discard' => true
+ )),
+ new Cookie(array(
+ 'name' => 'muppet',
+ 'value' => 'cookie_monster',
+ 'domain' => '.y.example.com',
+ 'path' => '/acme/',
+ 'comment' => 'Comment goes here...',
+ 'expires' => time() + 86400
+ )),
+ new Cookie(array(
+ 'name' => 'googoo',
+ 'value' => 'gaga',
+ 'domain' => '.example.com',
+ 'path' => '/test/acme/',
+ 'max_age' => 1500,
+ 'version' => 2
+ ))
+ );
+
+ foreach ($bag as $cookie) {
+ $this->jar->add($cookie);
+ }
+
+ $request = new Request('GET', $url);
+ $results = $this->jar->getMatchingCookies($request);
+ $this->assertEquals(count($cookies), count($results));
+ foreach ($cookies as $i) {
+ $this->assertContains($bag[$i], $results);
+ }
+ }
+
+ /**
+ * @expectedException \Guzzle\Plugin\Cookie\Exception\InvalidCookieException
+ * @expectedExceptionMessage The cookie name must not contain invalid characters: abc:@123
+ */
+ public function testThrowsExceptionWithStrictMode()
+ {
+ $a = new ArrayCookieJar();
+ $a->setStrictMode(true);
+ $a->add(new Cookie(array(
+ 'name' => 'abc:@123',
+ 'value' => 'foo',
+ 'domain' => 'bar'
+ )));
+ }
+
+ public function testRemoveExistingCookieIfEmpty()
+ {
+ // Add a cookie that should not be affected
+ $a = new Cookie(array(
+ 'name' => 'foo',
+ 'value' => 'nope',
+ 'domain' => 'foo.com',
+ 'path' => '/abc'
+ ));
+ $this->jar->add($a);
+
+ $data = array(
+ 'name' => 'foo',
+ 'value' => 'bar',
+ 'domain' => 'foo.com',
+ 'path' => '/'
+ );
+
+ $b = new Cookie($data);
+ $this->assertTrue($this->jar->add($b));
+ $this->assertEquals(2, count($this->jar));
+
+ // Try to re-set the same cookie with no value: assert that cookie is not added
+ $data['value'] = null;
+ $this->assertFalse($this->jar->add(new Cookie($data)));
+ // assert that original cookie has been deleted
+ $cookies = $this->jar->all('foo.com');
+ $this->assertTrue(in_array($a, $cookies, true));
+ $this->assertFalse(in_array($b, $cookies, true));
+ $this->assertEquals(1, count($this->jar));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/FileCookieJarTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/FileCookieJarTest.php
new file mode 100644
index 0000000..ac9471f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieJar/FileCookieJarTest.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cookie\CookieJar;
+
+use Guzzle\Plugin\Cookie\Cookie;
+use Guzzle\Plugin\Cookie\CookieJar\FileCookieJar;
+
+/**
+ * @covers Guzzle\Plugin\Cookie\CookieJar\FileCookieJar
+ */
+class FileCookieJarTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private $file;
+
+ public function setUp()
+ {
+ $this->file = tempnam('/tmp', 'file-cookies');
+ }
+
+ public function testLoadsFromFileFile()
+ {
+ $jar = new FileCookieJar($this->file);
+ $this->assertEquals(array(), $jar->all());
+ unlink($this->file);
+ }
+
+ public function testPersistsToFileFile()
+ {
+ $jar = new FileCookieJar($this->file);
+ $jar->add(new Cookie(array(
+ 'name' => 'foo',
+ 'value' => 'bar',
+ 'domain' => 'foo.com',
+ 'expires' => time() + 1000
+ )));
+ $jar->add(new Cookie(array(
+ 'name' => 'baz',
+ 'value' => 'bar',
+ 'domain' => 'foo.com',
+ 'expires' => time() + 1000
+ )));
+ $jar->add(new Cookie(array(
+ 'name' => 'boo',
+ 'value' => 'bar',
+ 'domain' => 'foo.com',
+ )));
+
+ $this->assertEquals(3, count($jar));
+ unset($jar);
+
+ // Make sure it wrote to the file
+ $contents = file_get_contents($this->file);
+ $this->assertNotEmpty($contents);
+
+ // Load the cookieJar from the file
+ $jar = new FileCookieJar($this->file);
+
+ // Weeds out temporary and session cookies
+ $this->assertEquals(2, count($jar));
+ unset($jar);
+ unlink($this->file);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php
new file mode 100644
index 0000000..f8c175c
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookiePluginTest.php
@@ -0,0 +1,134 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cookie;
+
+use Guzzle\Common\Event;
+use Guzzle\Plugin\Cookie\Cookie;
+use Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar;
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Cookie\CookiePlugin;
+
+/**
+ * @group server
+ * @covers Guzzle\Plugin\Cookie\CookiePlugin
+ */
+class CookiePluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testExtractsAndStoresCookies()
+ {
+ $response = new Response(200);
+ $mock = $this->getMockBuilder('Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar')
+ ->setMethods(array('addCookiesFromResponse'))
+ ->getMock();
+
+ $mock->expects($this->exactly(1))
+ ->method('addCookiesFromResponse')
+ ->with($response);
+
+ $plugin = new CookiePlugin($mock);
+ $plugin->onRequestSent(new Event(array(
+ 'response' => $response
+ )));
+ }
+
+ public function testAddsCookiesToRequests()
+ {
+ $cookie = new Cookie(array(
+ 'name' => 'foo',
+ 'value' => 'bar'
+ ));
+
+ $mock = $this->getMockBuilder('Guzzle\Plugin\Cookie\CookieJar\ArrayCookieJar')
+ ->setMethods(array('getMatchingCookies'))
+ ->getMock();
+
+ $mock->expects($this->once())
+ ->method('getMatchingCookies')
+ ->will($this->returnValue(array($cookie)));
+
+ $plugin = new CookiePlugin($mock);
+
+ $client = new Client();
+ $client->getEventDispatcher()->addSubscriber($plugin);
+
+ $request = $client->get('http://www.example.com');
+ $plugin->onRequestBeforeSend(new Event(array(
+ 'request' => $request
+ )));
+
+ $this->assertEquals('bar', $request->getCookie('foo'));
+ }
+
+ public function testCookiesAreExtractedFromRedirectResponses()
+ {
+ $plugin = new CookiePlugin(new ArrayCookieJar());
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 302 Moved Temporarily\r\n" .
+ "Set-Cookie: test=583551; expires=Wednesday, 23-Mar-2050 19:49:45 GMT; path=/\r\n" .
+ "Location: /redirect\r\n\r\n",
+ "HTTP/1.1 200 OK\r\n" .
+ "Content-Length: 0\r\n\r\n",
+ "HTTP/1.1 200 OK\r\n" .
+ "Content-Length: 0\r\n\r\n"
+ ));
+
+ $client = new Client($this->getServer()->getUrl());
+ $client->getEventDispatcher()->addSubscriber($plugin);
+
+ $client->get()->send();
+ $request = $client->get();
+ $request->send();
+ $this->assertEquals('test=583551', $request->getHeader('Cookie'));
+
+ $requests = $this->getServer()->getReceivedRequests(true);
+ // Confirm subsequent requests have the cookie.
+ $this->assertEquals('test=583551', $requests[2]->getHeader('Cookie'));
+ // Confirm the redirected request has the cookie.
+ $this->assertEquals('test=583551', $requests[1]->getHeader('Cookie'));
+ }
+
+ public function testCookiesAreNotAddedWhenParamIsSet()
+ {
+ $jar = new ArrayCookieJar();
+ $plugin = new CookiePlugin($jar);
+
+ $jar->add(new Cookie(array(
+ 'domain' => 'example.com',
+ 'path' => '/',
+ 'name' => 'test',
+ 'value' => 'hi',
+ 'expires' => time() + 3600
+ )));
+
+ $client = new Client('http://example.com');
+ $client->getEventDispatcher()->addSubscriber($plugin);
+
+ // Ensure that it is normally added
+ $request = $client->get();
+ $request->setResponse(new Response(200), true);
+ $request->send();
+ $this->assertEquals('hi', $request->getCookie('test'));
+
+ // Now ensure that it is not added
+ $request = $client->get();
+ $request->getParams()->set('cookies.disable', true);
+ $request->setResponse(new Response(200), true);
+ $request->send();
+ $this->assertNull($request->getCookie('test'));
+ }
+
+ public function testProvidesCookieJar()
+ {
+ $jar = new ArrayCookieJar();
+ $plugin = new CookiePlugin($jar);
+ $this->assertSame($jar, $plugin->getCookieJar());
+ }
+
+ public function testEscapesCookieDomains()
+ {
+ $cookie = new Cookie(array('domain' => '/foo/^$[A-Z]+/'));
+ $this->assertFalse($cookie->matchesDomain('foo'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieTest.php
new file mode 100644
index 0000000..9fb0b43
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Cookie/CookieTest.php
@@ -0,0 +1,223 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Cookie;
+
+use Guzzle\Plugin\Cookie\Cookie;
+
+/**
+ * @covers Guzzle\Plugin\Cookie\Cookie
+ */
+class CookieTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testInitializesDefaultValues()
+ {
+ $cookie = new Cookie();
+ $this->assertEquals('/', $cookie->getPath());
+ $this->assertEquals(array(), $cookie->getPorts());
+ }
+
+ public function testConvertsDateTimeMaxAgeToUnixTimestamp()
+ {
+ $cookie = new Cookie(array(
+ 'expires' => 'November 20, 1984'
+ ));
+ $this->assertTrue(is_numeric($cookie->getExpires()));
+ }
+
+ public function testAddsExpiresBasedOnMaxAge()
+ {
+ $t = time();
+ $cookie = new Cookie(array(
+ 'max_age' => 100
+ ));
+ $this->assertEquals($t + 100, $cookie->getExpires());
+ }
+
+ public function testHoldsValues()
+ {
+ $t = time();
+ $data = array(
+ 'name' => 'foo',
+ 'value' => 'baz',
+ 'path' => '/bar',
+ 'domain' => 'baz.com',
+ 'expires' => $t,
+ 'max_age' => 100,
+ 'comment' => 'Hi',
+ 'comment_url' => 'foo.com',
+ 'port' => array(1, 2),
+ 'version' => 2,
+ 'secure' => true,
+ 'discard' => true,
+ 'http_only' => true,
+ 'data' => array(
+ 'foo' => 'baz',
+ 'bar' => 'bam'
+ )
+ );
+
+ $cookie = new Cookie($data);
+ $this->assertEquals($data, $cookie->toArray());
+
+ $this->assertEquals('foo', $cookie->getName());
+ $this->assertEquals('baz', $cookie->getValue());
+ $this->assertEquals('baz.com', $cookie->getDomain());
+ $this->assertEquals('/bar', $cookie->getPath());
+ $this->assertEquals($t, $cookie->getExpires());
+ $this->assertEquals(100, $cookie->getMaxAge());
+ $this->assertEquals('Hi', $cookie->getComment());
+ $this->assertEquals('foo.com', $cookie->getCommentUrl());
+ $this->assertEquals(array(1, 2), $cookie->getPorts());
+ $this->assertEquals(2, $cookie->getVersion());
+ $this->assertTrue($cookie->getSecure());
+ $this->assertTrue($cookie->getDiscard());
+ $this->assertTrue($cookie->getHttpOnly());
+ $this->assertEquals('baz', $cookie->getAttribute('foo'));
+ $this->assertEquals('bam', $cookie->getAttribute('bar'));
+ $this->assertEquals(array(
+ 'foo' => 'baz',
+ 'bar' => 'bam'
+ ), $cookie->getAttributes());
+
+ $cookie->setName('a')
+ ->setValue('b')
+ ->setPath('c')
+ ->setDomain('bar.com')
+ ->setExpires(10)
+ ->setMaxAge(200)
+ ->setComment('e')
+ ->setCommentUrl('f')
+ ->setPorts(array(80))
+ ->setVersion(3)
+ ->setSecure(false)
+ ->setHttpOnly(false)
+ ->setDiscard(false)
+ ->setAttribute('snoop', 'dog');
+
+ $this->assertEquals('a', $cookie->getName());
+ $this->assertEquals('b', $cookie->getValue());
+ $this->assertEquals('c', $cookie->getPath());
+ $this->assertEquals('bar.com', $cookie->getDomain());
+ $this->assertEquals(10, $cookie->getExpires());
+ $this->assertEquals(200, $cookie->getMaxAge());
+ $this->assertEquals('e', $cookie->getComment());
+ $this->assertEquals('f', $cookie->getCommentUrl());
+ $this->assertEquals(array(80), $cookie->getPorts());
+ $this->assertEquals(3, $cookie->getVersion());
+ $this->assertFalse($cookie->getSecure());
+ $this->assertFalse($cookie->getDiscard());
+ $this->assertFalse($cookie->getHttpOnly());
+ $this->assertEquals('dog', $cookie->getAttribute('snoop'));
+ }
+
+ public function testDeterminesIfExpired()
+ {
+ $c = new Cookie();
+ $c->setExpires(10);
+ $this->assertTrue($c->isExpired());
+ $c->setExpires(time() + 10000);
+ $this->assertFalse($c->isExpired());
+ }
+
+ public function testMatchesPorts()
+ {
+ $cookie = new Cookie();
+ // Always matches when nothing is set
+ $this->assertTrue($cookie->matchesPort(2));
+
+ $cookie->setPorts(array(1, 2));
+ $this->assertTrue($cookie->matchesPort(2));
+ $this->assertFalse($cookie->matchesPort(100));
+ }
+
+ public function testMatchesDomain()
+ {
+ $cookie = new Cookie();
+ $this->assertTrue($cookie->matchesDomain('baz.com'));
+
+ $cookie->setDomain('baz.com');
+ $this->assertTrue($cookie->matchesDomain('baz.com'));
+ $this->assertFalse($cookie->matchesDomain('bar.com'));
+
+ $cookie->setDomain('.baz.com');
+ $this->assertTrue($cookie->matchesDomain('.baz.com'));
+ $this->assertTrue($cookie->matchesDomain('foo.baz.com'));
+ $this->assertFalse($cookie->matchesDomain('baz.bar.com'));
+ $this->assertTrue($cookie->matchesDomain('baz.com'));
+
+ $cookie->setDomain('.127.0.0.1');
+ $this->assertTrue($cookie->matchesDomain('127.0.0.1'));
+
+ $cookie->setDomain('127.0.0.1');
+ $this->assertTrue($cookie->matchesDomain('127.0.0.1'));
+
+ $cookie->setDomain('.com.');
+ $this->assertFalse($cookie->matchesDomain('baz.com'));
+
+ $cookie->setDomain('.local');
+ $this->assertTrue($cookie->matchesDomain('example.local'));
+ }
+
+ public function testMatchesPath()
+ {
+ $cookie = new Cookie();
+ $this->assertTrue($cookie->matchesPath('/foo'));
+
+ $cookie->setPath('/foo');
+
+ // o The cookie-path and the request-path are identical.
+ $this->assertTrue($cookie->matchesPath('/foo'));
+ $this->assertFalse($cookie->matchesPath('/bar'));
+
+ // o The cookie-path is a prefix of the request-path, and the first
+ // character of the request-path that is not included in the cookie-
+ // path is a %x2F ("/") character.
+ $this->assertTrue($cookie->matchesPath('/foo/bar'));
+ $this->assertFalse($cookie->matchesPath('/fooBar'));
+
+ // o The cookie-path is a prefix of the request-path, and the last
+ // character of the cookie-path is %x2F ("/").
+ $cookie->setPath('/foo/');
+ $this->assertTrue($cookie->matchesPath('/foo/bar'));
+ $this->assertFalse($cookie->matchesPath('/fooBaz'));
+ $this->assertFalse($cookie->matchesPath('/foo'));
+
+ }
+
+ public function cookieValidateProvider()
+ {
+ return array(
+ array('foo', 'baz', 'bar', true),
+ array('0', '0', '0', true),
+ array('', 'baz', 'bar', 'The cookie name must not be empty'),
+ array('foo', '', 'bar', 'The cookie value must not be empty'),
+ array('foo', 'baz', '', 'The cookie domain must not be empty'),
+ array('foo\\', 'baz', '0', 'The cookie name must not contain invalid characters: foo\\'),
+ );
+ }
+
+ /**
+ * @dataProvider cookieValidateProvider
+ */
+ public function testValidatesCookies($name, $value, $domain, $result)
+ {
+ $cookie = new Cookie(array(
+ 'name' => $name,
+ 'value' => $value,
+ 'domain' => $domain
+ ));
+ $this->assertSame($result, $cookie->validate());
+ }
+
+ public function testCreatesInvalidCharacterString()
+ {
+ $m = new \ReflectionMethod('Guzzle\Plugin\Cookie\Cookie', 'getInvalidCharacters');
+ $m->setAccessible(true);
+ $p = new \ReflectionProperty('Guzzle\Plugin\Cookie\Cookie', 'invalidCharString');
+ $p->setAccessible(true);
+ $p->setValue('');
+ // Expects a string containing 51 invalid characters
+ $this->assertEquals(51, strlen($m->invoke($m)));
+ $this->assertContains('@', $m->invoke($m));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php
new file mode 100644
index 0000000..2a4b49e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/CurlAuth/CurlAuthPluginTest.php
@@ -0,0 +1,39 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\CurlAuth;
+
+use Guzzle\Common\Version;
+use Guzzle\Plugin\CurlAuth\CurlAuthPlugin;
+use Guzzle\Http\Client;
+
+/**
+ * @covers Guzzle\Plugin\CurlAuth\CurlAuthPlugin
+ */
+class CurlAuthPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testAddsBasicAuthentication()
+ {
+ Version::$emitWarnings = false;
+ $plugin = new CurlAuthPlugin('michael', 'test');
+ $client = new Client('http://www.test.com/');
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $request = $client->get('/');
+ $this->assertEquals('michael', $request->getUsername());
+ $this->assertEquals('test', $request->getPassword());
+ Version::$emitWarnings = true;
+ }
+
+ public function testAddsDigestAuthentication()
+ {
+ Version::$emitWarnings = false;
+ $plugin = new CurlAuthPlugin('julian', 'test', CURLAUTH_DIGEST);
+ $client = new Client('http://www.test.com/');
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $request = $client->get('/');
+ $this->assertEquals('julian', $request->getUsername());
+ $this->assertEquals('test', $request->getPassword());
+ $this->assertEquals('julian:test', $request->getCurlOptions()->get(CURLOPT_USERPWD));
+ $this->assertEquals(CURLAUTH_DIGEST, $request->getCurlOptions()->get(CURLOPT_HTTPAUTH));
+ Version::$emitWarnings = true;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/ErrorResponse/ErrorResponsePluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/ErrorResponse/ErrorResponsePluginTest.php
new file mode 100644
index 0000000..6f94186
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/ErrorResponse/ErrorResponsePluginTest.php
@@ -0,0 +1,137 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\ErrorResponse;
+
+use Guzzle\Service\Client;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\ErrorResponse\ErrorResponsePlugin;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Tests\Mock\ErrorResponseMock;
+
+/**
+ * @covers \Guzzle\Plugin\ErrorResponse\ErrorResponsePlugin
+ */
+class ErrorResponsePluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $client;
+
+ public static function tearDownAfterClass()
+ {
+ self::getServer()->flush();
+ }
+
+ public function setUp()
+ {
+ $mockError = 'Guzzle\Tests\Mock\ErrorResponseMock';
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'works' => array(
+ 'httpMethod' => 'GET',
+ 'errorResponses' => array(
+ array('code' => 500, 'class' => $mockError),
+ array('code' => 503, 'reason' => 'foo', 'class' => $mockError),
+ array('code' => 200, 'reason' => 'Error!', 'class' => $mockError)
+ )
+ ),
+ 'bad_class' => array(
+ 'httpMethod' => 'GET',
+ 'errorResponses' => array(
+ array('code' => 500, 'class' => 'Does\\Not\\Exist')
+ )
+ ),
+ 'does_not_implement' => array(
+ 'httpMethod' => 'GET',
+ 'errorResponses' => array(
+ array('code' => 500, 'class' => __CLASS__)
+ )
+ ),
+ 'no_errors' => array('httpMethod' => 'GET'),
+ 'no_class' => array(
+ 'httpMethod' => 'GET',
+ 'errorResponses' => array(
+ array('code' => 500)
+ )
+ ),
+ )
+ ));
+ $this->client = new Client($this->getServer()->getUrl());
+ $this->client->setDescription($description);
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\ServerErrorResponseException
+ */
+ public function testSkipsWhenErrorResponsesIsNotSet()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $this->client->getCommand('no_errors')->execute();
+ }
+
+ public function testSkipsWhenErrorResponsesIsNotSetAndAllowsSuccess()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $this->client->getCommand('no_errors')->execute();
+ }
+
+ /**
+ * @expectedException \Guzzle\Plugin\ErrorResponse\Exception\ErrorResponseException
+ * @expectedExceptionMessage Does\Not\Exist does not exist
+ */
+ public function testEnsuresErrorResponseExists()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $this->client->getCommand('bad_class')->execute();
+ }
+
+ /**
+ * @expectedException \Guzzle\Plugin\ErrorResponse\Exception\ErrorResponseException
+ * @expectedExceptionMessage must implement Guzzle\Plugin\ErrorResponse\ErrorResponseExceptionInterface
+ */
+ public function testEnsuresErrorResponseImplementsInterface()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $this->client->getCommand('does_not_implement')->execute();
+ }
+
+ public function testThrowsSpecificErrorResponseOnMatch()
+ {
+ try {
+ $this->getServer()->enqueue("HTTP/1.1 500 Foo\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $command = $this->client->getCommand('works');
+ $command->execute();
+ $this->fail('Exception not thrown');
+ } catch (ErrorResponseMock $e) {
+ $this->assertSame($command, $e->command);
+ $this->assertEquals(500, $e->response->getStatusCode());
+ }
+ }
+
+ /**
+ * @expectedException \Guzzle\Tests\Mock\ErrorResponseMock
+ */
+ public function testThrowsWhenCodeAndPhraseMatch()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 Error!\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $this->client->getCommand('works')->execute();
+ }
+
+ public function testSkipsWhenReasonDoesNotMatch()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $this->client->getCommand('works')->execute();
+ }
+
+ public function testSkipsWhenNoClassIsSet()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $this->client->addSubscriber(new ErrorResponsePlugin());
+ $this->client->getCommand('no_class')->execute();
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/History/HistoryPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/History/HistoryPluginTest.php
new file mode 100644
index 0000000..41aa673
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/History/HistoryPluginTest.php
@@ -0,0 +1,140 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\History;
+
+use Guzzle\Http\Client;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\History\HistoryPlugin;
+use Guzzle\Plugin\Mock\MockPlugin;
+
+/**
+ * @covers Guzzle\Plugin\History\HistoryPlugin
+ */
+class HistoryPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * Adds multiple requests to a plugin
+ *
+ * @param HistoryPlugin $h Plugin
+ * @param int $num Number of requests to add
+ *
+ * @return array
+ */
+ protected function addRequests(HistoryPlugin $h, $num)
+ {
+ $requests = array();
+ $client = new Client('http://127.0.0.1/');
+ for ($i = 0; $i < $num; $i++) {
+ $requests[$i] = $client->get();
+ $requests[$i]->setResponse(new Response(200), true);
+ $requests[$i]->send();
+ $h->add($requests[$i]);
+ }
+
+ return $requests;
+ }
+
+ public function testDescribesSubscribedEvents()
+ {
+ $this->assertInternalType('array', HistoryPlugin::getSubscribedEvents());
+ }
+
+ public function testMaintainsLimitValue()
+ {
+ $h = new HistoryPlugin();
+ $this->assertSame($h, $h->setLimit(10));
+ $this->assertEquals(10, $h->getLimit());
+ }
+
+ public function testAddsRequests()
+ {
+ $h = new HistoryPlugin();
+ $requests = $this->addRequests($h, 1);
+ $this->assertEquals(1, count($h));
+ $i = $h->getIterator();
+ $this->assertEquals(1, count($i));
+ $this->assertEquals($requests[0], $i[0]);
+ }
+
+ /**
+ * @depends testAddsRequests
+ */
+ public function testMaintainsLimit()
+ {
+ $h = new HistoryPlugin();
+ $h->setLimit(2);
+ $requests = $this->addRequests($h, 3);
+ $this->assertEquals(2, count($h));
+ $i = 0;
+ foreach ($h as $request) {
+ if ($i > 0) {
+ $this->assertSame($requests[$i], $request);
+ }
+ }
+ }
+
+ public function testReturnsLastRequest()
+ {
+ $h = new HistoryPlugin();
+ $requests = $this->addRequests($h, 5);
+ $this->assertSame(end($requests), $h->getLastRequest());
+ }
+
+ public function testReturnsLastResponse()
+ {
+ $h = new HistoryPlugin();
+ $requests = $this->addRequests($h, 5);
+ $this->assertSame(end($requests)->getResponse(), $h->getLastResponse());
+ }
+
+ public function testClearsHistory()
+ {
+ $h = new HistoryPlugin();
+ $requests = $this->addRequests($h, 5);
+ $this->assertEquals(5, count($h));
+ $h->clear();
+ $this->assertEquals(0, count($h));
+ }
+
+ /**
+ * @depends testAddsRequests
+ */
+ public function testUpdatesAddRequests()
+ {
+ $h = new HistoryPlugin();
+ $client = new Client('http://127.0.0.1/');
+ $client->getEventDispatcher()->addSubscriber($h);
+
+ $request = $client->get();
+ $request->setResponse(new Response(200), true);
+ $request->send();
+
+ $this->assertSame($request, $h->getLastRequest());
+ }
+
+ public function testCanCastToString()
+ {
+ $client = new Client('http://127.0.0.1/');
+ $h = new HistoryPlugin();
+ $client->getEventDispatcher()->addSubscriber($h);
+
+ $mock = new MockPlugin(array(
+ new Response(301, array('Location' => '/redirect1', 'Content-Length' => 0)),
+ new Response(307, array('Location' => '/redirect2', 'Content-Length' => 0)),
+ new Response(200, array('Content-Length' => '2'), 'HI')
+ ));
+
+ $client->getEventDispatcher()->addSubscriber($mock);
+ $request = $client->get();
+ $request->send();
+ $this->assertEquals(3, count($h));
+ $this->assertEquals(3, count($mock->getReceivedRequests()));
+
+ $h = str_replace("\r", '', $h);
+ $this->assertContains("> GET / HTTP/1.1\nHost: 127.0.0.1\nUser-Agent:", $h);
+ $this->assertContains("< HTTP/1.1 301 Moved Permanently\nLocation: /redirect1", $h);
+ $this->assertContains("< HTTP/1.1 307 Temporary Redirect\nLocation: /redirect2", $h);
+ $this->assertContains("< HTTP/1.1 200 OK\nContent-Length: 2\n\nHI", $h);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Log/LogPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Log/LogPluginTest.php
new file mode 100644
index 0000000..ad663a5
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Log/LogPluginTest.php
@@ -0,0 +1,95 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Log;
+
+use Guzzle\Log\ClosureLogAdapter;
+use Guzzle\Http\Client;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Message\Request;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Log\LogPlugin;
+use Guzzle\Common\Event;
+
+/**
+ * @group server
+ * @covers Guzzle\Plugin\Log\LogPlugin
+ */
+class LogPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $adapter;
+
+ public function setUp()
+ {
+ $this->adapter = new ClosureLogAdapter(function ($message) {
+ echo $message;
+ });
+ }
+
+ public function testIgnoresCurlEventsWhenNotWiringBodies()
+ {
+ $p = new LogPlugin($this->adapter);
+ $this->assertNotEmpty($p->getSubscribedEvents());
+ $event = new Event(array('request' => new Request('GET', 'http://foo.com')));
+ $p->onCurlRead($event);
+ $p->onCurlWrite($event);
+ $p->onRequestBeforeSend($event);
+ }
+
+ public function testLogsWhenComplete()
+ {
+ $output = '';
+ $p = new LogPlugin(new ClosureLogAdapter(function ($message) use (&$output) {
+ $output = $message;
+ }), '{method} {resource} | {code} {res_body}');
+
+ $p->onRequestSent(new Event(array(
+ 'request' => new Request('GET', 'http://foo.com'),
+ 'response' => new Response(200, array(), 'Foo')
+ )));
+
+ $this->assertEquals('GET / | 200 Foo', $output);
+ }
+
+ public function testWiresBodiesWhenNeeded()
+ {
+ $client = new Client($this->getServer()->getUrl());
+ $plugin = new LogPlugin($this->adapter, '{req_body} | {res_body}', true);
+ $client->getEventDispatcher()->addSubscriber($plugin);
+ $request = $client->put();
+
+ // Send the response from the dummy server as the request body
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 4\r\n\r\nsend");
+ $stream = fopen($this->getServer()->getUrl(), 'r');
+ $request->setBody(EntityBody::factory($stream, 4));
+
+ $tmpFile = tempnam(sys_get_temp_dir(), 'non_repeatable');
+ $request->setResponseBody(EntityBody::factory(fopen($tmpFile, 'w')));
+
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 8\r\n\r\nresponse");
+
+ ob_start();
+ $request->send();
+ $message = ob_get_clean();
+
+ unlink($tmpFile);
+ $this->assertContains("send", $message);
+ $this->assertContains("response", $message);
+ }
+
+ public function testHasHelpfulStaticFactoryMethod()
+ {
+ $s = fopen('php://temp', 'r+');
+ $client = new Client();
+ $client->addSubscriber(LogPlugin::getDebugPlugin(true, $s));
+ $request = $client->put('http://foo.com', array('Content-Type' => 'Foo'), 'Bar');
+ $request->setresponse(new Response(200), true);
+ $request->send();
+ rewind($s);
+ $contents = stream_get_contents($s);
+ $this->assertContains('# Request:', $contents);
+ $this->assertContainsIns('PUT / HTTP/1.1', $contents);
+ $this->assertContains('# Response:', $contents);
+ $this->assertContainsIns('HTTP/1.1 200 OK', $contents);
+ $this->assertContains('# Errors:', $contents);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/CommandContentMd5PluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/CommandContentMd5PluginTest.php
new file mode 100644
index 0000000..4bd4111
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/CommandContentMd5PluginTest.php
@@ -0,0 +1,97 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Md5;
+
+use Guzzle\Common\Event;
+use Guzzle\Plugin\Md5\CommandContentMd5Plugin;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Service\Client;
+
+/**
+ * @covers Guzzle\Plugin\Md5\CommandContentMd5Plugin
+ */
+class CommandContentMd5PluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected function getClient()
+ {
+ $description = new ServiceDescription(array(
+ 'operations' => array(
+ 'test' => array(
+ 'httpMethod' => 'PUT',
+ 'parameters' => array(
+ 'ContentMD5' => array(),
+ 'Body' => array(
+ 'location' => 'body'
+ )
+ )
+ )
+ )
+ ));
+
+ $client = new Client();
+ $client->setDescription($description);
+
+ return $client;
+ }
+
+ public function testHasEvents()
+ {
+ $this->assertNotEmpty(CommandContentMd5Plugin::getSubscribedEvents());
+ }
+
+ public function testValidatesMd5WhenParamExists()
+ {
+ $client = $this->getClient();
+ $command = $client->getCommand('test', array(
+ 'Body' => 'Foo',
+ 'ContentMD5' => true
+ ));
+ $event = new Event(array('command' => $command));
+ $request = $command->prepare();
+ $plugin = new CommandContentMd5Plugin();
+ $plugin->onCommandBeforeSend($event);
+ $this->assertEquals('E1bGfXrRY42Ba/uCLdLCXQ==', (string) $request->getHeader('Content-MD5'));
+ }
+
+ public function testDoesNothingWhenNoPayloadExists()
+ {
+ $client = $this->getClient();
+ $client->getDescription()->getOperation('test')->setHttpMethod('GET');
+ $command = $client->getCommand('test');
+ $event = new Event(array('command' => $command));
+ $request = $command->prepare();
+ $plugin = new CommandContentMd5Plugin();
+ $plugin->onCommandBeforeSend($event);
+ $this->assertNull($request->getHeader('Content-MD5'));
+ }
+
+ public function testAddsValidationToResponsesOfContentMd5()
+ {
+ $client = $this->getClient();
+ $client->getDescription()->getOperation('test')->setHttpMethod('GET');
+ $command = $client->getCommand('test', array(
+ 'ValidateMD5' => true
+ ));
+ $event = new Event(array('command' => $command));
+ $request = $command->prepare();
+ $plugin = new CommandContentMd5Plugin();
+ $plugin->onCommandBeforeSend($event);
+ $listeners = $request->getEventDispatcher()->getListeners('request.complete');
+ $this->assertNotEmpty($listeners);
+ }
+
+ public function testIgnoresValidationWhenDisabled()
+ {
+ $client = $this->getClient();
+ $client->getDescription()->getOperation('test')->setHttpMethod('GET');
+ $command = $client->getCommand('test', array(
+ 'ValidateMD5' => false
+ ));
+ $event = new Event(array('command' => $command));
+ $request = $command->prepare();
+ $plugin = new CommandContentMd5Plugin();
+ $plugin->onCommandBeforeSend($event);
+ $listeners = $request->getEventDispatcher()->getListeners('request.complete');
+ $this->assertEmpty($listeners);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/Md5ValidatorPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/Md5ValidatorPluginTest.php
new file mode 100644
index 0000000..482e92b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Md5/Md5ValidatorPluginTest.php
@@ -0,0 +1,120 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Md5;
+
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Md5\Md5ValidatorPlugin;
+
+/**
+ * @covers Guzzle\Plugin\Md5\Md5ValidatorPlugin
+ */
+class Md5ValidatorPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testValidatesMd5()
+ {
+ $plugin = new Md5ValidatorPlugin();
+ $request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
+ $request->getEventDispatcher()->addSubscriber($plugin);
+
+ $body = 'abc';
+ $hash = md5($body);
+ $response = new Response(200, array(
+ 'Content-MD5' => $hash,
+ 'Content-Length' => 3
+ ), 'abc');
+
+ $request->dispatch('request.complete', array(
+ 'response' => $response
+ ));
+
+ // Try again with no Content-MD5
+ $response->removeHeader('Content-MD5');
+ $request->dispatch('request.complete', array(
+ 'response' => $response
+ ));
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ */
+ public function testThrowsExceptionOnInvalidMd5()
+ {
+ $plugin = new Md5ValidatorPlugin();
+ $request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
+ $request->getEventDispatcher()->addSubscriber($plugin);
+
+ $request->dispatch('request.complete', array(
+ 'response' => new Response(200, array(
+ 'Content-MD5' => 'foobar',
+ 'Content-Length' => 3
+ ), 'abc')
+ ));
+ }
+
+ public function testSkipsWhenContentLengthIsTooLarge()
+ {
+ $plugin = new Md5ValidatorPlugin(false, 1);
+ $request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
+ $request->getEventDispatcher()->addSubscriber($plugin);
+
+ $request->dispatch('request.complete', array(
+ 'response' => new Response(200, array(
+ 'Content-MD5' => 'foobar',
+ 'Content-Length' => 3
+ ), 'abc')
+ ));
+ }
+
+ public function testProperlyValidatesWhenUsingContentEncoding()
+ {
+ $plugin = new Md5ValidatorPlugin(true);
+ $request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
+ $request->getEventDispatcher()->addSubscriber($plugin);
+
+ // Content-MD5 is the MD5 hash of the canonical content after all
+ // content-encoding has been applied. Because cURL will automatically
+ // decompress entity bodies, we need to re-compress it to calculate.
+ $body = EntityBody::factory('abc');
+ $body->compress();
+ $hash = $body->getContentMd5();
+ $body->uncompress();
+
+ $response = new Response(200, array(
+ 'Content-MD5' => $hash,
+ 'Content-Encoding' => 'gzip'
+ ), 'abc');
+ $request->dispatch('request.complete', array(
+ 'response' => $response
+ ));
+ $this->assertEquals('abc', $response->getBody(true));
+
+ // Try again with an unknown encoding
+ $response = new Response(200, array(
+ 'Content-MD5' => $hash,
+ 'Content-Encoding' => 'foobar'
+ ), 'abc');
+ $request->dispatch('request.complete', array(
+ 'response' => $response
+ ));
+
+ // Try again with compress
+ $body->compress('bzip2.compress');
+ $response = new Response(200, array(
+ 'Content-MD5' => $body->getContentMd5(),
+ 'Content-Encoding' => 'compress'
+ ), 'abc');
+ $request->dispatch('request.complete', array(
+ 'response' => $response
+ ));
+
+ // Try again with encoding and disabled content-encoding checks
+ $request->getEventDispatcher()->removeSubscriber($plugin);
+ $plugin = new Md5ValidatorPlugin(false);
+ $request->getEventDispatcher()->addSubscriber($plugin);
+ $request->dispatch('request.complete', array(
+ 'response' => $response
+ ));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Mock/MockPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Mock/MockPluginTest.php
new file mode 100644
index 0000000..3af8fef
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Mock/MockPluginTest.php
@@ -0,0 +1,199 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Mock;
+
+use Guzzle\Common\Event;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Mock\MockPlugin;
+use Guzzle\Http\Client;
+use Guzzle\Http\Exception\CurlException;
+
+/**
+ * @covers Guzzle\Plugin\Mock\MockPlugin
+ */
+class MockPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testDescribesSubscribedEvents()
+ {
+ $this->assertInternalType('array', MockPlugin::getSubscribedEvents());
+ }
+
+ public function testDescribesEvents()
+ {
+ $this->assertInternalType('array', MockPlugin::getAllEvents());
+ }
+
+ public function testCanBeTemporary()
+ {
+ $plugin = new MockPlugin();
+ $this->assertFalse($plugin->isTemporary());
+ $plugin = new MockPlugin(null, true);
+ $this->assertTrue($plugin->isTemporary());
+ }
+
+ public function testIsCountable()
+ {
+ $plugin = new MockPlugin();
+ $plugin->addResponse(Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
+ $this->assertEquals(1, count($plugin));
+ }
+
+ /**
+ * @depends testIsCountable
+ */
+ public function testCanClearQueue()
+ {
+ $plugin = new MockPlugin();
+ $plugin->addResponse(Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
+ $plugin->clearQueue();
+ $this->assertEquals(0, count($plugin));
+ }
+
+ public function testCanInspectQueue()
+ {
+ $plugin = new MockPlugin();
+ $this->assertInternalType('array', $plugin->getQueue());
+ $plugin->addResponse(Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n"));
+ $queue = $plugin->getQueue();
+ $this->assertInternalType('array', $queue);
+ $this->assertEquals(1, count($queue));
+ }
+
+ public function testRetrievesResponsesFromFiles()
+ {
+ $response = MockPlugin::getMockFile(__DIR__ . '/../../TestData/mock_response');
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $response);
+ $this->assertEquals(200, $response->getStatusCode());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testThrowsExceptionWhenResponseFileIsNotFound()
+ {
+ MockPlugin::getMockFile('missing/filename');
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testInvalidResponsesThrowAnException()
+ {
+ $p = new MockPlugin();
+ $p->addResponse($this);
+ }
+
+ public function testAddsResponseObjectsToQueue()
+ {
+ $p = new MockPlugin();
+ $response = Response::fromMessage("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $p->addResponse($response);
+ $this->assertEquals(array($response), $p->getQueue());
+ }
+
+ public function testAddsResponseFilesToQueue()
+ {
+ $p = new MockPlugin();
+ $p->addResponse(__DIR__ . '/../../TestData/mock_response');
+ $this->assertEquals(1, count($p));
+ }
+
+ /**
+ * @depends testAddsResponseFilesToQueue
+ */
+ public function testAddsMockResponseToRequestFromClient()
+ {
+ $p = new MockPlugin();
+ $response = MockPlugin::getMockFile(__DIR__ . '/../../TestData/mock_response');
+ $p->addResponse($response);
+
+ $client = new Client('http://127.0.0.1:123/');
+ $client->getEventDispatcher()->addSubscriber($p, 9999);
+ $request = $client->get();
+ $request->send();
+
+ $this->assertSame($response, $request->getResponse());
+ $this->assertEquals(0, count($p));
+ }
+
+ /**
+ * @depends testAddsResponseFilesToQueue
+ * @expectedException \OutOfBoundsException
+ */
+ public function testUpdateThrowsExceptionWhenEmpty()
+ {
+ $p = new MockPlugin();
+ $p->onRequestBeforeSend(new Event());
+ }
+
+ /**
+ * @depends testAddsMockResponseToRequestFromClient
+ */
+ public function testDetachesTemporaryWhenEmpty()
+ {
+ $p = new MockPlugin(null, true);
+ $p->addResponse(MockPlugin::getMockFile(__DIR__ . '/../../TestData/mock_response'));
+ $client = new Client('http://127.0.0.1:123/');
+ $client->getEventDispatcher()->addSubscriber($p, 9999);
+ $request = $client->get();
+ $request->send();
+
+ $this->assertFalse($this->hasSubscriber($client, $p));
+ }
+
+ public function testLoadsResponsesFromConstructor()
+ {
+ $p = new MockPlugin(array(new Response(200)));
+ $this->assertEquals(1, $p->count());
+ }
+
+ public function testStoresMockedRequests()
+ {
+ $p = new MockPlugin(array(new Response(200), new Response(200)));
+ $client = new Client('http://127.0.0.1:123/');
+ $client->getEventDispatcher()->addSubscriber($p, 9999);
+
+ $request1 = $client->get();
+ $request1->send();
+ $this->assertEquals(array($request1), $p->getReceivedRequests());
+
+ $request2 = $client->get();
+ $request2->send();
+ $this->assertEquals(array($request1, $request2), $p->getReceivedRequests());
+
+ $p->flush();
+ $this->assertEquals(array(), $p->getReceivedRequests());
+ }
+
+ public function testReadsBodiesFromMockedRequests()
+ {
+ $p = new MockPlugin(array(new Response(200)));
+ $p->readBodies(true);
+ $client = new Client('http://127.0.0.1:123/');
+ $client->getEventDispatcher()->addSubscriber($p, 9999);
+
+ $body = EntityBody::factory('foo');
+ $request = $client->put();
+ $request->setBody($body);
+ $request->send();
+ $this->assertEquals(3, $body->ftell());
+ }
+
+ public function testCanMockBadRequestExceptions()
+ {
+ $client = new Client('http://127.0.0.1:123/');
+ $ex = new CurlException('Foo');
+ $mock = new MockPlugin(array($ex));
+ $client->addSubscriber($mock);
+ $request = $client->get('foo');
+
+ try {
+ $request->send();
+ $this->fail('Did not dequeue an exception');
+ } catch (CurlException $e) {
+ $this->assertSame($e, $ex);
+ $this->assertSame($request, $ex->getRequest());
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Oauth/OauthPluginTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Oauth/OauthPluginTest.php
new file mode 100644
index 0000000..3892fb6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Plugin/Oauth/OauthPluginTest.php
@@ -0,0 +1,345 @@
+<?php
+
+namespace Guzzle\Tests\Plugin\Oauth;
+
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Http\QueryAggregator\CommaAggregator;
+use Guzzle\Plugin\Oauth\OauthPlugin;
+use Guzzle\Common\Event;
+
+/**
+ * @covers Guzzle\Plugin\Oauth\OauthPlugin
+ */
+class OauthPluginTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ const TIMESTAMP = '1327274290';
+ const NONCE = 'e7aa11195ca58349bec8b5ebe351d3497eb9e603';
+
+ protected $config = array(
+ 'consumer_key' => 'foo',
+ 'consumer_secret' => 'bar',
+ 'token' => 'count',
+ 'token_secret' => 'dracula'
+ );
+
+ protected function getRequest()
+ {
+ return RequestFactory::getInstance()->create('POST', 'http://www.test.com/path?a=b&c=d', null, array(
+ 'e' => 'f'
+ ));
+ }
+
+ public function testSubscribesToEvents()
+ {
+ $events = OauthPlugin::getSubscribedEvents();
+ $this->assertArrayHasKey('request.before_send', $events);
+ }
+
+ public function testAcceptsConfigurationData()
+ {
+ $p = new OauthPlugin($this->config);
+
+ // Access the config object
+ $class = new \ReflectionClass($p);
+ $property = $class->getProperty('config');
+ $property->setAccessible(true);
+ $config = $property->getValue($p);
+
+ $this->assertEquals('foo', $config['consumer_key']);
+ $this->assertEquals('bar', $config['consumer_secret']);
+ $this->assertEquals('count', $config['token']);
+ $this->assertEquals('dracula', $config['token_secret']);
+ $this->assertEquals('1.0', $config['version']);
+ $this->assertEquals('HMAC-SHA1', $config['signature_method']);
+ $this->assertEquals('header', $config['request_method']);
+ }
+
+ public function testCreatesStringToSignFromPostRequest()
+ {
+ $p = new OauthPlugin($this->config);
+ $request = $this->getRequest();
+ $signString = $p->getStringToSign($request, self::TIMESTAMP, self::NONCE);
+
+ $this->assertContains('&e=f', rawurldecode($signString));
+
+ $expectedSignString =
+ // Method and URL
+ 'POST&http%3A%2F%2Fwww.test.com%2Fpath' .
+ // Sorted parameters from query string and body
+ '&a%3Db%26c%3Dd%26e%3Df%26oauth_consumer_key%3Dfoo' .
+ '%26oauth_nonce%3De7aa11195ca58349bec8b5ebe351d3497eb9e603%26' .
+ 'oauth_signature_method%3DHMAC-SHA1' .
+ '%26oauth_timestamp%3D' . self::TIMESTAMP . '%26oauth_token%3Dcount%26oauth_version%3D1.0';
+
+ $this->assertEquals($expectedSignString, $signString);
+ }
+
+ public function testCreatesStringToSignIgnoringPostFields()
+ {
+ $config = $this->config;
+ $config['disable_post_params'] = true;
+ $p = new OauthPlugin($config);
+ $request = $this->getRequest();
+ $sts = rawurldecode($p->getStringToSign($request, self::TIMESTAMP, self::NONCE));
+ $this->assertNotContains('&e=f', $sts);
+ }
+
+ public function testCreatesStringToSignFromPostRequestWithCustomContentType()
+ {
+ $p = new OauthPlugin($this->config);
+ $request = $this->getRequest();
+ $request->setHeader('Content-Type', 'Foo');
+ $this->assertEquals(
+ // Method and URL
+ 'POST&http%3A%2F%2Fwww.test.com%2Fpath' .
+ // Sorted parameters from query string and body
+ '&a%3Db%26c%3Dd%26oauth_consumer_key%3Dfoo' .
+ '%26oauth_nonce%3D'. self::NONCE .'%26' .
+ 'oauth_signature_method%3DHMAC-SHA1' .
+ '%26oauth_timestamp%3D' . self::TIMESTAMP . '%26oauth_token%3Dcount%26oauth_version%3D1.0',
+ $p->getStringToSign($request, self::TIMESTAMP, self::NONCE)
+ );
+ }
+
+ /**
+ * @depends testCreatesStringToSignFromPostRequest
+ */
+ public function testConvertsBooleansToStrings()
+ {
+ $p = new OauthPlugin($this->config);
+ $request = $this->getRequest();
+ $request->getQuery()->set('a', true);
+ $request->getQuery()->set('c', false);
+ $this->assertContains('&a%3Dtrue%26c%3Dfalse', $p->getStringToSign($request, self::TIMESTAMP, self::NONCE));
+ }
+
+ public function testCreatesStringToSignFromPostRequestWithNullValues()
+ {
+ $config = array(
+ 'consumer_key' => 'foo',
+ 'consumer_secret' => 'bar',
+ 'token' => null,
+ 'token_secret' => 'dracula'
+ );
+
+ $p = new OauthPlugin($config);
+ $request = $this->getRequest();
+ $signString = $p->getStringToSign($request, self::TIMESTAMP, self::NONCE);
+
+ $this->assertContains('&e=f', rawurldecode($signString));
+
+ $expectedSignString = // Method and URL
+ 'POST&http%3A%2F%2Fwww.test.com%2Fpath' .
+ // Sorted parameters from query string and body
+ '&a%3Db%26c%3Dd%26e%3Df%26oauth_consumer_key%3Dfoo' .
+ '%26oauth_nonce%3De7aa11195ca58349bec8b5ebe351d3497eb9e603%26' .
+ 'oauth_signature_method%3DHMAC-SHA1' .
+ '%26oauth_timestamp%3D' . self::TIMESTAMP . '%26oauth_version%3D1.0';
+
+ $this->assertEquals($expectedSignString, $signString);
+ }
+
+ /**
+ * @depends testCreatesStringToSignFromPostRequest
+ */
+ public function testMultiDimensionalArray()
+ {
+ $p = new OauthPlugin($this->config);
+ $request = $this->getRequest();
+ $request->getQuery()->set('a', array('b' => array('e' => 'f', 'c' => 'd')));
+ $this->assertContains('a%255Bb%255D%255Bc%255D%3Dd%26a%255Bb%255D%255Be%255D%3Df%26c%3Dd%26e%3Df%26', $p->getStringToSign($request, self::TIMESTAMP, self::NONCE));
+ }
+
+ /**
+ * @depends testMultiDimensionalArray
+ */
+ public function testMultiDimensionalArrayWithNonDefaultQueryAggregator()
+ {
+ $p = new OauthPlugin($this->config);
+ $request = $this->getRequest();
+ $aggregator = new CommaAggregator();
+ $query = $request->getQuery()->setAggregator($aggregator)
+ ->set('g', array('h', 'i', 'j'))
+ ->set('k', array('l'))
+ ->set('m', array('n', 'o'));
+ $this->assertContains('a%3Db%26c%3Dd%26e%3Df%26g%3Dh%2Ci%2Cj%26k%3Dl%26m%3Dn%2Co', $p->getStringToSign($request, self::TIMESTAMP, self::NONCE));
+ }
+
+ /**
+ * @depends testCreatesStringToSignFromPostRequest
+ */
+ public function testSignsStrings()
+ {
+ $p = new OauthPlugin(array_merge($this->config, array(
+ 'signature_callback' => function($string, $key) {
+ return "_{$string}|{$key}_";
+ }
+ )));
+ $request = $this->getRequest();
+ $sig = $p->getSignature($request, self::TIMESTAMP, self::NONCE);
+ $this->assertEquals(
+ '_POST&http%3A%2F%2Fwww.test.com%2Fpath&a%3Db%26c%3Dd%26e%3Df%26oauth_consumer_key%3Dfoo' .
+ '%26oauth_nonce%3D'. self::NONCE .'%26oauth_signature_method%3DHMAC-SHA1' .
+ '%26oauth_timestamp%3D' . self::TIMESTAMP . '%26oauth_token%3Dcount%26oauth_version%3D1.0|' .
+ 'bar&dracula_',
+ base64_decode($sig)
+ );
+ }
+
+ /**
+ * Test that the Oauth is signed correctly and that extra strings haven't been added
+ * to the authorization header.
+ */
+ public function testSignsOauthRequests()
+ {
+ $p = new OauthPlugin($this->config);
+ $event = new Event(array(
+ 'request' => $this->getRequest(),
+ 'timestamp' => self::TIMESTAMP
+ ));
+ $params = $p->onRequestBeforeSend($event);
+
+ $this->assertTrue($event['request']->hasHeader('Authorization'));
+
+ $authorizationHeader = (string)$event['request']->getHeader('Authorization');
+
+ $this->assertStringStartsWith('OAuth ', $authorizationHeader);
+
+ $stringsToCheck = array(
+ 'oauth_consumer_key="foo"',
+ 'oauth_nonce="'.urlencode($params['oauth_nonce']).'"',
+ 'oauth_signature="'.urlencode($params['oauth_signature']).'"',
+ 'oauth_signature_method="HMAC-SHA1"',
+ 'oauth_timestamp="' . self::TIMESTAMP . '"',
+ 'oauth_token="count"',
+ 'oauth_version="1.0"',
+ );
+
+ $totalLength = strlen('OAuth ');
+
+ //Separator is not used before first parameter.
+ $separator = '';
+
+ foreach ($stringsToCheck as $stringToCheck) {
+ $this->assertContains($stringToCheck, $authorizationHeader);
+ $totalLength += strlen($separator);
+ $totalLength += strlen($stringToCheck);
+ $separator = ', ';
+ }
+
+ // Technically this test is not universally valid. It would be allowable to have extra \n characters
+ // in the Authorization header. However Guzzle does not do this, so we just perform a simple check
+ // on length to validate the Authorization header is composed of only the strings above.
+ $this->assertEquals($totalLength, strlen($authorizationHeader), 'Authorization has extra characters i.e. contains extra elements compared to stringsToCheck.');
+ }
+
+ public function testSignsOauthQueryStringRequest()
+ {
+ $config = array_merge(
+ $this->config,
+ array('request_method' => OauthPlugin::REQUEST_METHOD_QUERY)
+ );
+
+ $p = new OauthPlugin($config);
+ $event = new Event(array(
+ 'request' => $this->getRequest(),
+ 'timestamp' => self::TIMESTAMP
+ ));
+ $params = $p->onRequestBeforeSend($event);
+
+ $this->assertFalse($event['request']->hasHeader('Authorization'));
+
+ $stringsToCheck = array(
+ 'a=b',
+ 'c=d',
+ 'oauth_consumer_key=foo',
+ 'oauth_nonce='.urlencode($params['oauth_nonce']),
+ 'oauth_signature='.urlencode($params['oauth_signature']),
+ 'oauth_signature_method=HMAC-SHA1',
+ 'oauth_timestamp='.self::TIMESTAMP,
+ 'oauth_token=count',
+ 'oauth_version=1.0',
+ );
+
+ $queryString = (string) $event['request']->getQuery();
+
+ $totalLength = strlen('?');
+
+ //Separator is not used before first parameter.
+ $separator = '';
+
+ foreach ($stringsToCheck as $stringToCheck) {
+ $this->assertContains($stringToCheck, $queryString);
+ $totalLength += strlen($separator);
+ $totalLength += strlen($stringToCheck);
+ $separator = '&';
+ }
+
+ // Removes the last query string separator '&'
+ $totalLength -= 1;
+
+ $this->assertEquals($totalLength, strlen($queryString), 'Query string has extra characters i.e. contains extra elements compared to stringsToCheck.');
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testInvalidArgumentExceptionOnMethodError()
+ {
+ $config = array_merge(
+ $this->config,
+ array('request_method' => 'FakeMethod')
+ );
+
+ $p = new OauthPlugin($config);
+ $event = new Event(array(
+ 'request' => $this->getRequest(),
+ 'timestamp' => self::TIMESTAMP
+ ));
+
+ $p->onRequestBeforeSend($event);
+ }
+
+ public function testDoesNotAddFalseyValuesToAuthorization()
+ {
+ unset($this->config['token']);
+ $p = new OauthPlugin($this->config);
+ $event = new Event(array('request' => $this->getRequest(), 'timestamp' => self::TIMESTAMP));
+ $p->onRequestBeforeSend($event);
+ $this->assertTrue($event['request']->hasHeader('Authorization'));
+ $this->assertNotContains('oauth_token=', (string) $event['request']->getHeader('Authorization'));
+ }
+
+ public function testOptionalOauthParametersAreNotAutomaticallyAdded()
+ {
+ // The only required Oauth parameters are the consumer key and secret. That is enough credentials
+ // for signing oauth requests.
+ $config = array(
+ 'consumer_key' => 'foo',
+ 'consumer_secret' => 'bar',
+ );
+
+ $plugin = new OauthPlugin($config);
+ $event = new Event(array(
+ 'request' => $this->getRequest(),
+ 'timestamp' => self::TIMESTAMP
+ ));
+
+ $timestamp = $plugin->getTimestamp($event);
+ $request = $event['request'];
+ $nonce = $plugin->generateNonce($request);
+
+ $paramsToSign = $plugin->getParamsToSign($request, $timestamp, $nonce);
+
+ $optionalParams = array(
+ 'callback' => 'oauth_callback',
+ 'token' => 'oauth_token',
+ 'verifier' => 'oauth_verifier',
+ 'token_secret' => 'token_secret'
+ );
+
+ foreach ($optionalParams as $optionName => $oauthName) {
+ $this->assertArrayNotHasKey($oauthName, $paramsToSign, "Optional Oauth param '$oauthName' was not set via config variable '$optionName', but it is listed in getParamsToSign().");
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/AbstractConfigLoaderTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/AbstractConfigLoaderTest.php
new file mode 100644
index 0000000..8b42fb8
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/AbstractConfigLoaderTest.php
@@ -0,0 +1,149 @@
+<?php
+
+namespace Guzzle\Tests\Service;
+
+/**
+ * @covers Guzzle\Service\AbstractConfigLoader
+ */
+class AbstractConfigLoaderTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var \Guzzle\Service\AbstractConfigLoader */
+ protected $loader;
+
+ /** @var array Any files that need to be deleted on tear down */
+ protected $cleanup = array();
+
+ public function setUp()
+ {
+ $this->loader = $this->getMockBuilder('Guzzle\Service\AbstractConfigLoader')
+ ->setMethods(array('build'))
+ ->getMockForAbstractClass();
+ }
+
+ public function tearDown()
+ {
+ foreach ($this->cleanup as $file) {
+ unlink($file);
+ }
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testOnlyLoadsSupportedTypes()
+ {
+ $this->loader->load(new \stdClass());
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ * @expectedExceptionMessage Unable to open fooooooo.json
+ */
+ public function testFileMustBeReadable()
+ {
+ $this->loader->load('fooooooo.json');
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ * @expectedExceptionMessage Unknown file extension
+ */
+ public function testMustBeSupportedExtension()
+ {
+ $this->loader->load(dirname(__DIR__) . '/TestData/FileBody.txt');
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ * @expectedExceptionMessage Error loading JSON data from
+ */
+ public function testJsonMustBeValue()
+ {
+ $filename = tempnam(sys_get_temp_dir(), 'json') . '.json';
+ file_put_contents($filename, '{/{./{}foo');
+ $this->cleanup[] = $filename;
+ $this->loader->load($filename);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ * @expectedExceptionMessage PHP files must return an array
+ */
+ public function testPhpFilesMustReturnAnArray()
+ {
+ $filename = tempnam(sys_get_temp_dir(), 'php') . '.php';
+ file_put_contents($filename, '<?php $fdr = false;');
+ $this->cleanup[] = $filename;
+ $this->loader->load($filename);
+ }
+
+ public function testLoadsPhpFileIncludes()
+ {
+ $filename = tempnam(sys_get_temp_dir(), 'php') . '.php';
+ file_put_contents($filename, '<?php return array("foo" => "bar");');
+ $this->cleanup[] = $filename;
+ $this->loader->expects($this->exactly(1))->method('build')->will($this->returnArgument(0));
+ $config = $this->loader->load($filename);
+ $this->assertEquals(array('foo' => 'bar'), $config);
+ }
+
+ public function testCanCreateFromJson()
+ {
+ $file = dirname(__DIR__) . '/TestData/services/json1.json';
+ // The build method will just return the config data
+ $this->loader->expects($this->exactly(1))->method('build')->will($this->returnArgument(0));
+ $data = $this->loader->load($file);
+ // Ensure that the config files were merged using the includes directives
+ $this->assertArrayHasKey('includes', $data);
+ $this->assertArrayHasKey('services', $data);
+ $this->assertInternalType('array', $data['services']['foo']);
+ $this->assertInternalType('array', $data['services']['abstract']);
+ $this->assertInternalType('array', $data['services']['mock']);
+ $this->assertEquals('bar', $data['services']['foo']['params']['baz']);
+ }
+
+ public function testUsesAliases()
+ {
+ $file = dirname(__DIR__) . '/TestData/services/json1.json';
+ $this->loader->addAlias('foo', $file);
+ // The build method will just return the config data
+ $this->loader->expects($this->exactly(1))->method('build')->will($this->returnArgument(0));
+ $data = $this->loader->load('foo');
+ $this->assertEquals('bar', $data['services']['foo']['params']['baz']);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ * @expectedExceptionMessage Unable to open foo.json
+ */
+ public function testCanRemoveAliases()
+ {
+ $file = dirname(__DIR__) . '/TestData/services/json1.json';
+ $this->loader->addAlias('foo.json', $file);
+ $this->loader->removeAlias('foo.json');
+ $this->loader->load('foo.json');
+ }
+
+ public function testCanLoadArraysWithIncludes()
+ {
+ $file = dirname(__DIR__) . '/TestData/services/json1.json';
+ $config = array('includes' => array($file));
+ // The build method will just return the config data
+ $this->loader->expects($this->exactly(1))->method('build')->will($this->returnArgument(0));
+ $data = $this->loader->load($config);
+ $this->assertEquals('bar', $data['services']['foo']['params']['baz']);
+ }
+
+ public function testDoesNotEnterInfiniteLoop()
+ {
+ $prefix = $file = dirname(__DIR__) . '/TestData/description';
+ $this->loader->load("{$prefix}/baz.json");
+ $this->assertCount(4, $this->readAttribute($this->loader, 'loadedFiles'));
+ // Ensure that the internal list of loaded files is reset
+ $this->loader->load("{$prefix}/../test_service2.json");
+ $this->assertCount(1, $this->readAttribute($this->loader, 'loadedFiles'));
+ // Ensure that previously loaded files will be reloaded when starting fresh
+ $this->loader->load("{$prefix}/baz.json");
+ $this->assertCount(4, $this->readAttribute($this->loader, 'loadedFiles'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderLoaderTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderLoaderTest.php
new file mode 100644
index 0000000..f63070e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderLoaderTest.php
@@ -0,0 +1,177 @@
+<?php
+
+namespace Guzzle\Tests\Service\Builder;
+
+use Guzzle\Service\Builder\ServiceBuilderLoader;
+
+/**
+ * @covers Guzzle\Service\Builder\ServiceBuilderLoader
+ */
+class ServiceBuilderLoaderTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testBuildsServiceBuilders()
+ {
+ $arrayFactory = new ServiceBuilderLoader();
+
+ $data = array(
+ 'services' => array(
+ 'abstract' => array(
+ 'params' => array(
+ 'access_key' => 'xyz',
+ 'secret' => 'abc',
+ ),
+ ),
+ 'foo' => array(
+ 'extends' => 'abstract',
+ 'params' => array(
+ 'baz' => 'bar',
+ ),
+ ),
+ 'mock' => array(
+ 'extends' => 'abstract',
+ 'params' => array(
+ 'username' => 'foo',
+ 'password' => 'baz',
+ 'subdomain' => 'bar',
+ )
+ )
+ )
+ );
+
+ $builder = $arrayFactory->load($data);
+
+ // Ensure that services were parsed
+ $this->assertTrue(isset($builder['mock']));
+ $this->assertTrue(isset($builder['abstract']));
+ $this->assertTrue(isset($builder['foo']));
+ $this->assertFalse(isset($builder['jimmy']));
+ }
+
+ /**
+ * @expectedException Guzzle\Service\Exception\ServiceNotFoundException
+ * @expectedExceptionMessage foo is trying to extend a non-existent service: abstract
+ */
+ public function testThrowsExceptionWhenExtendingNonExistentService()
+ {
+ $arrayFactory = new ServiceBuilderLoader();
+
+ $data = array(
+ 'services' => array(
+ 'foo' => array(
+ 'extends' => 'abstract'
+ )
+ )
+ );
+
+ $builder = $arrayFactory->load($data);
+ }
+
+ public function testAllowsGlobalParameterOverrides()
+ {
+ $arrayFactory = new ServiceBuilderLoader();
+
+ $data = array(
+ 'services' => array(
+ 'foo' => array(
+ 'params' => array(
+ 'foo' => 'baz',
+ 'bar' => 'boo'
+ )
+ )
+ )
+ );
+
+ $builder = $arrayFactory->load($data, array(
+ 'bar' => 'jar',
+ 'far' => 'car'
+ ));
+
+ $compiled = json_decode($builder->serialize(), true);
+ $this->assertEquals(array(
+ 'foo' => 'baz',
+ 'bar' => 'jar',
+ 'far' => 'car'
+ ), $compiled['foo']['params']);
+ }
+
+ public function tstDoesNotErrorOnCircularReferences()
+ {
+ $arrayFactory = new ServiceBuilderLoader();
+ $arrayFactory->load(array(
+ 'services' => array(
+ 'too' => array('extends' => 'ball'),
+ 'ball' => array('extends' => 'too'),
+ )
+ ));
+ }
+
+ public function configProvider()
+ {
+ $foo = array(
+ 'extends' => 'bar',
+ 'class' => 'stdClass',
+ 'params' => array('a' => 'test', 'b' => '456')
+ );
+
+ return array(
+ array(
+ // Does not extend the existing `foo` service but overwrites it
+ array(
+ 'services' => array(
+ 'foo' => $foo,
+ 'bar' => array('params' => array('baz' => '123'))
+ )
+ ),
+ array(
+ 'services' => array(
+ 'foo' => array('class' => 'Baz')
+ )
+ ),
+ array(
+ 'services' => array(
+ 'foo' => array('class' => 'Baz'),
+ 'bar' => array('params' => array('baz' => '123'))
+ )
+ )
+ ),
+ array(
+ // Extends the existing `foo` service
+ array(
+ 'services' => array(
+ 'foo' => $foo,
+ 'bar' => array('params' => array('baz' => '123'))
+ )
+ ),
+ array(
+ 'services' => array(
+ 'foo' => array(
+ 'extends' => 'foo',
+ 'params' => array('b' => '123', 'c' => 'def')
+ )
+ )
+ ),
+ array(
+ 'services' => array(
+ 'foo' => array(
+ 'extends' => 'bar',
+ 'class' => 'stdClass',
+ 'params' => array('a' => 'test', 'b' => '123', 'c' => 'def')
+ ),
+ 'bar' => array('params' => array('baz' => '123'))
+ )
+ )
+ )
+ );
+ }
+
+ /**
+ * @dataProvider configProvider
+ */
+ public function testCombinesConfigs($a, $b, $c)
+ {
+ $l = new ServiceBuilderLoader();
+ $m = new \ReflectionMethod($l, 'mergeData');
+ $m->setAccessible(true);
+ $this->assertEquals($c, $m->invoke($l, $a, $b));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderTest.php
new file mode 100644
index 0000000..e1b3a1d
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Builder/ServiceBuilderTest.php
@@ -0,0 +1,317 @@
+<?php
+
+namespace Guzzle\Tests\Service;
+
+use Guzzle\Plugin\History\HistoryPlugin;
+use Guzzle\Service\Builder\ServiceBuilder;
+use Guzzle\Service\Client;
+
+/**
+ * @covers Guzzle\Service\Builder\ServiceBuilder
+ */
+class ServiceBuilderTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $arrayData = array(
+ 'michael.mock' => array(
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'username' => 'michael',
+ 'password' => 'testing123',
+ 'subdomain' => 'michael',
+ ),
+ ),
+ 'billy.mock' => array(
+ 'alias' => 'Hello!',
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'username' => 'billy',
+ 'password' => 'passw0rd',
+ 'subdomain' => 'billy',
+ ),
+ ),
+ 'billy.testing' => array(
+ 'extends' => 'billy.mock',
+ 'params' => array(
+ 'subdomain' => 'test.billy',
+ ),
+ ),
+ 'missing_params' => array(
+ 'extends' => 'billy.mock'
+ )
+ );
+
+ public function testAllowsSerialization()
+ {
+ $builder = ServiceBuilder::factory($this->arrayData);
+ $cached = unserialize(serialize($builder));
+ $this->assertEquals($cached, $builder);
+ }
+
+ public function testDelegatesFactoryMethodToAbstractFactory()
+ {
+ $builder = ServiceBuilder::factory($this->arrayData);
+ $c = $builder->get('michael.mock');
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\MockClient', $c);
+ }
+
+ /**
+ * @expectedException Guzzle\Service\Exception\ServiceNotFoundException
+ * @expectedExceptionMessage No service is registered as foobar
+ */
+ public function testThrowsExceptionWhenGettingInvalidClient()
+ {
+ ServiceBuilder::factory($this->arrayData)->get('foobar');
+ }
+
+ public function testStoresClientCopy()
+ {
+ $builder = ServiceBuilder::factory($this->arrayData);
+ $client = $builder->get('michael.mock');
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\MockClient', $client);
+ $this->assertEquals('http://127.0.0.1:8124/v1/michael', $client->getBaseUrl());
+ $this->assertEquals($client, $builder->get('michael.mock'));
+
+ // Get another client but throw this one away
+ $client2 = $builder->get('billy.mock', true);
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\MockClient', $client2);
+ $this->assertEquals('http://127.0.0.1:8124/v1/billy', $client2->getBaseUrl());
+
+ // Make sure the original client is still there and set
+ $this->assertTrue($client === $builder->get('michael.mock'));
+
+ // Create a new billy.mock client that is stored
+ $client3 = $builder->get('billy.mock');
+
+ // Make sure that the stored billy.mock client is equal to the other stored client
+ $this->assertTrue($client3 === $builder->get('billy.mock'));
+
+ // Make sure that this client is not equal to the previous throwaway client
+ $this->assertFalse($client2 === $builder->get('billy.mock'));
+ }
+
+ public function testBuildersPassOptionsThroughToClients()
+ {
+ $s = new ServiceBuilder(array(
+ 'michael.mock' => array(
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'base_url' => 'http://www.test.com/',
+ 'subdomain' => 'michael',
+ 'password' => 'test',
+ 'username' => 'michael',
+ 'curl.curlopt_proxyport' => 8080
+ )
+ )
+ ));
+
+ $c = $s->get('michael.mock');
+ $this->assertEquals(8080, $c->getConfig('curl.curlopt_proxyport'));
+ }
+
+ public function testUsesTheDefaultBuilderWhenNoBuilderIsSpecified()
+ {
+ $s = new ServiceBuilder(array(
+ 'michael.mock' => array(
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'base_url' => 'http://www.test.com/',
+ 'subdomain' => 'michael',
+ 'password' => 'test',
+ 'username' => 'michael',
+ 'curl.curlopt_proxyport' => 8080
+ )
+ )
+ ));
+
+ $c = $s->get('michael.mock');
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\MockClient', $c);
+ }
+
+ public function testUsedAsArray()
+ {
+ $b = ServiceBuilder::factory($this->arrayData);
+ $this->assertTrue($b->offsetExists('michael.mock'));
+ $this->assertFalse($b->offsetExists('not_there'));
+ $this->assertInstanceOf('Guzzle\Service\Client', $b['michael.mock']);
+
+ unset($b['michael.mock']);
+ $this->assertFalse($b->offsetExists('michael.mock'));
+
+ $b['michael.mock'] = new Client('http://www.test.com/');
+ $this->assertInstanceOf('Guzzle\Service\Client', $b['michael.mock']);
+ }
+
+ public function testFactoryCanCreateFromJson()
+ {
+ $tmp = sys_get_temp_dir() . '/test.js';
+ file_put_contents($tmp, json_encode($this->arrayData));
+ $b = ServiceBuilder::factory($tmp);
+ unlink($tmp);
+ $s = $b->get('billy.testing');
+ $this->assertEquals('test.billy', $s->getConfig('subdomain'));
+ $this->assertEquals('billy', $s->getConfig('username'));
+ }
+
+ public function testFactoryCanCreateFromArray()
+ {
+ $b = ServiceBuilder::factory($this->arrayData);
+ $s = $b->get('billy.testing');
+ $this->assertEquals('test.billy', $s->getConfig('subdomain'));
+ $this->assertEquals('billy', $s->getConfig('username'));
+ }
+
+ public function testFactoryDoesNotRequireParams()
+ {
+ $b = ServiceBuilder::factory($this->arrayData);
+ $s = $b->get('missing_params');
+ $this->assertEquals('billy', $s->getConfig('username'));
+ }
+
+ public function testBuilderAllowsReferencesBetweenClients()
+ {
+ $builder = ServiceBuilder::factory(array(
+ 'a' => array(
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'other_client' => '{b}',
+ 'username' => 'x',
+ 'password' => 'y',
+ 'subdomain' => 'z'
+ )
+ ),
+ 'b' => array(
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'username' => '1',
+ 'password' => '2',
+ 'subdomain' => '3'
+ )
+ )
+ ));
+
+ $client = $builder['a'];
+ $this->assertEquals('x', $client->getConfig('username'));
+ $this->assertSame($builder['b'], $client->getConfig('other_client'));
+ $this->assertEquals('1', $builder['b']->getConfig('username'));
+ }
+
+ public function testEmitsEventsWhenClientsAreCreated()
+ {
+ // Ensure that the client signals that it emits an event
+ $this->assertEquals(array('service_builder.create_client'), ServiceBuilder::getAllEvents());
+
+ // Create a test service builder
+ $builder = ServiceBuilder::factory(array(
+ 'a' => array(
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'username' => 'test',
+ 'password' => '123',
+ 'subdomain' => 'z'
+ )
+ )
+ ));
+
+ // Add an event listener to pick up client creation events
+ $emits = 0;
+ $builder->getEventDispatcher()->addListener('service_builder.create_client', function($event) use (&$emits) {
+ $emits++;
+ });
+
+ // Get the 'a' client by name
+ $client = $builder->get('a');
+
+ // Ensure that the event was emitted once, and that the client was present
+ $this->assertEquals(1, $emits);
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\MockClient', $client);
+ }
+
+ public function testCanAddGlobalParametersToServicesOnLoad()
+ {
+ $builder = ServiceBuilder::factory($this->arrayData, array(
+ 'username' => 'fred',
+ 'new_value' => 'test'
+ ));
+
+ $data = json_decode($builder->serialize(), true);
+
+ foreach ($data as $service) {
+ $this->assertEquals('fred', $service['params']['username']);
+ $this->assertEquals('test', $service['params']['new_value']);
+ }
+ }
+
+ public function testAddsGlobalPlugins()
+ {
+ $b = new ServiceBuilder($this->arrayData);
+ $b->addGlobalPlugin(new HistoryPlugin());
+ $s = $b->get('michael.mock');
+ $this->assertTrue($s->getEventDispatcher()->hasListeners('request.sent'));
+ }
+
+ public function testCanGetData()
+ {
+ $b = new ServiceBuilder($this->arrayData);
+ $this->assertEquals($this->arrayData['michael.mock'], $b->getData('michael.mock'));
+ $this->assertNull($b->getData('ewofweoweofe'));
+ }
+
+ public function testCanGetByAlias()
+ {
+ $b = new ServiceBuilder($this->arrayData);
+ $this->assertSame($b->get('billy.mock'), $b->get('Hello!'));
+ }
+
+ public function testCanOverwriteParametersForThrowawayClients()
+ {
+ $b = new ServiceBuilder($this->arrayData);
+
+ $c1 = $b->get('michael.mock');
+ $this->assertEquals('michael', $c1->getConfig('username'));
+
+ $c2 = $b->get('michael.mock', array('username' => 'jeremy'));
+ $this->assertEquals('jeremy', $c2->getConfig('username'));
+ }
+
+ public function testGettingAThrowawayClientWithParametersDoesNotAffectGettingOtherClients()
+ {
+ $b = new ServiceBuilder($this->arrayData);
+
+ $c1 = $b->get('michael.mock', array('username' => 'jeremy'));
+ $this->assertEquals('jeremy', $c1->getConfig('username'));
+
+ $c2 = $b->get('michael.mock');
+ $this->assertEquals('michael', $c2->getConfig('username'));
+ }
+
+ public function testCanUseArbitraryData()
+ {
+ $b = new ServiceBuilder();
+ $b['a'] = 'foo';
+ $this->assertTrue(isset($b['a']));
+ $this->assertEquals('foo', $b['a']);
+ unset($b['a']);
+ $this->assertFalse(isset($b['a']));
+ }
+
+ public function testCanRegisterServiceData()
+ {
+ $b = new ServiceBuilder();
+ $b['a'] = array(
+ 'class' => 'Guzzle\Tests\Service\Mock\MockClient',
+ 'params' => array(
+ 'username' => 'billy',
+ 'password' => 'passw0rd',
+ 'subdomain' => 'billy',
+ )
+ );
+ $this->assertTrue(isset($b['a']));
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\MockClient', $b['a']);
+ $client = $b['a'];
+ unset($b['a']);
+ $this->assertFalse(isset($b['a']));
+ // Ensure that instantiated clients can be registered
+ $b['mock'] = $client;
+ $this->assertSame($client, $b['mock']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/CachingConfigLoaderTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/CachingConfigLoaderTest.php
new file mode 100644
index 0000000..b8245ad
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/CachingConfigLoaderTest.php
@@ -0,0 +1,43 @@
+<?php
+
+namespace Guzzle\Tests\Service;
+
+use Guzzle\Cache\DoctrineCacheAdapter;
+use Guzzle\Service\CachingConfigLoader;
+use Doctrine\Common\Cache\ArrayCache;
+
+/**
+ * @covers Guzzle\Service\CachingConfigLoader
+ */
+class CachingConfigLoaderTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testLoadsPhpFileIncludes()
+ {
+ $cache = new DoctrineCacheAdapter(new ArrayCache());
+ $loader = $this->getMockBuilder('Guzzle\Service\ConfigLoaderInterface')
+ ->setMethods(array('load'))
+ ->getMockForAbstractClass();
+ $data = array('foo' => 'bar');
+ $loader->expects($this->once())
+ ->method('load')
+ ->will($this->returnValue($data));
+ $cache = new CachingConfigLoader($loader, $cache);
+ $this->assertEquals($data, $cache->load('foo'));
+ $this->assertEquals($data, $cache->load('foo'));
+ }
+
+ public function testDoesNotCacheArrays()
+ {
+ $cache = new DoctrineCacheAdapter(new ArrayCache());
+ $loader = $this->getMockBuilder('Guzzle\Service\ConfigLoaderInterface')
+ ->setMethods(array('load'))
+ ->getMockForAbstractClass();
+ $data = array('foo' => 'bar');
+ $loader->expects($this->exactly(2))
+ ->method('load')
+ ->will($this->returnValue($data));
+ $cache = new CachingConfigLoader($loader, $cache);
+ $this->assertEquals($data, $cache->load(array()));
+ $this->assertEquals($data, $cache->load(array()));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/ClientTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/ClientTest.php
new file mode 100644
index 0000000..aee29ed
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/ClientTest.php
@@ -0,0 +1,320 @@
+<?php
+
+namespace Guzzle\Tests\Service;
+
+use Guzzle\Inflection\Inflector;
+use Guzzle\Http\Message\Response;
+use Guzzle\Plugin\Mock\MockPlugin;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Client;
+use Guzzle\Service\Exception\CommandTransferException;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+use Guzzle\Service\Resource\ResourceIteratorClassFactory;
+use Guzzle\Service\Command\AbstractCommand;
+
+/**
+ * @group server
+ * @covers Guzzle\Service\Client
+ */
+class ClientTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $service;
+ protected $serviceTest;
+
+ public function setUp()
+ {
+ $this->serviceTest = new ServiceDescription(array(
+ 'test_command' => new Operation(array(
+ 'doc' => 'documentationForCommand',
+ 'method' => 'DELETE',
+ 'class' => 'Guzzle\\Tests\\Service\\Mock\\Command\\MockCommand',
+ 'args' => array(
+ 'bucket' => array(
+ 'required' => true
+ ),
+ 'key' => array(
+ 'required' => true
+ )
+ )
+ ))
+ ));
+
+ $this->service = ServiceDescription::factory(__DIR__ . '/../TestData/test_service.json');
+ }
+
+ public function testAllowsCustomClientParameters()
+ {
+ $client = new Mock\MockClient(null, array(
+ Client::COMMAND_PARAMS => array(AbstractCommand::RESPONSE_PROCESSING => 'foo')
+ ));
+ $command = $client->getCommand('mock_command');
+ $this->assertEquals('foo', $command->get(AbstractCommand::RESPONSE_PROCESSING));
+ }
+
+ public function testFactoryCreatesClient()
+ {
+ $client = Client::factory(array(
+ 'base_url' => 'http://www.test.com/',
+ 'test' => '123'
+ ));
+
+ $this->assertEquals('http://www.test.com/', $client->getBaseUrl());
+ $this->assertEquals('123', $client->getConfig('test'));
+ }
+
+ public function testFactoryDoesNotRequireBaseUrl()
+ {
+ $client = Client::factory();
+ }
+
+ public function testDescribesEvents()
+ {
+ $this->assertInternalType('array', Client::getAllEvents());
+ }
+
+ public function testExecutesCommands()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+
+ $client = new Client($this->getServer()->getUrl());
+ $cmd = new MockCommand();
+ $client->execute($cmd);
+
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $cmd->getResponse());
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Response', $cmd->getResult());
+ $this->assertEquals(1, count($this->getServer()->getReceivedRequests(false)));
+ }
+
+ public function testExecutesCommandsWithArray()
+ {
+ $client = new Client('http://www.test.com/');
+ $client->getEventDispatcher()->addSubscriber(new MockPlugin(array(
+ new Response(200),
+ new Response(200)
+ )));
+
+ // Create a command set and a command
+ $set = array(new MockCommand(), new MockCommand());
+ $client->execute($set);
+
+ // Make sure it sent
+ $this->assertTrue($set[0]->isExecuted());
+ $this->assertTrue($set[1]->isExecuted());
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testThrowsExceptionWhenInvalidCommandIsExecuted()
+ {
+ $client = new Client();
+ $client->execute(new \stdClass());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ */
+ public function testThrowsExceptionWhenMissingCommand()
+ {
+ $client = new Client();
+
+ $mock = $this->getMock('Guzzle\\Service\\Command\\Factory\\FactoryInterface');
+ $mock->expects($this->any())
+ ->method('factory')
+ ->with($this->equalTo('test'))
+ ->will($this->returnValue(null));
+
+ $client->setCommandFactory($mock);
+ $client->getCommand('test');
+ }
+
+ public function testCreatesCommandsUsingCommandFactory()
+ {
+ $mockCommand = new MockCommand();
+
+ $client = new Mock\MockClient();
+ $mock = $this->getMock('Guzzle\\Service\\Command\\Factory\\FactoryInterface');
+ $mock->expects($this->any())
+ ->method('factory')
+ ->with($this->equalTo('foo'))
+ ->will($this->returnValue($mockCommand));
+
+ $client->setCommandFactory($mock);
+
+ $command = $client->getCommand('foo', array('acl' => '123'));
+ $this->assertSame($mockCommand, $command);
+ $command = $client->getCommand('foo', array('acl' => '123'));
+ $this->assertSame($mockCommand, $command);
+ $this->assertSame($client, $command->getClient());
+ }
+
+ public function testOwnsServiceDescription()
+ {
+ $client = new Mock\MockClient();
+ $this->assertNull($client->getDescription());
+
+ $description = $this->getMock('Guzzle\\Service\\Description\\ServiceDescription');
+ $this->assertSame($client, $client->setDescription($description));
+ $this->assertSame($description, $client->getDescription());
+ }
+
+ public function testOwnsResourceIteratorFactory()
+ {
+ $client = new Mock\MockClient();
+
+ $method = new \ReflectionMethod($client, 'getResourceIteratorFactory');
+ $method->setAccessible(TRUE);
+ $rf1 = $method->invoke($client);
+
+ $rf = $this->readAttribute($client, 'resourceIteratorFactory');
+ $this->assertInstanceOf('Guzzle\\Service\\Resource\\ResourceIteratorClassFactory', $rf);
+ $this->assertSame($rf1, $rf);
+
+ $rf = new ResourceIteratorClassFactory('Guzzle\Tests\Service\Mock');
+ $client->setResourceIteratorFactory($rf);
+ $this->assertNotSame($rf1, $rf);
+ }
+
+ public function testClientResetsRequestsBeforeExecutingCommands()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nHi",
+ "HTTP/1.1 200 OK\r\nContent-Length: 1\r\n\r\nI"
+ ));
+
+ $client = new Mock\MockClient($this->getServer()->getUrl());
+
+ $command = $client->getCommand('mock_command');
+ $client->execute($command);
+ $client->execute($command);
+ $this->assertEquals('I', $command->getResponse()->getBody(true));
+ }
+
+ public function testClientCreatesIterators()
+ {
+ $client = new Mock\MockClient();
+
+ $iterator = $client->getIterator('mock_command', array(
+ 'foo' => 'bar'
+ ), array(
+ 'limit' => 10
+ ));
+
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
+ $this->assertEquals(10, $this->readAttribute($iterator, 'limit'));
+
+ $command = $this->readAttribute($iterator, 'originalCommand');
+ $this->assertEquals('bar', $command->get('foo'));
+ }
+
+ public function testClientCreatesIteratorsWithNoOptions()
+ {
+ $client = new Mock\MockClient();
+ $iterator = $client->getIterator('mock_command');
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
+ }
+
+ public function testClientCreatesIteratorsWithCommands()
+ {
+ $client = new Mock\MockClient();
+ $command = new MockCommand();
+ $iterator = $client->getIterator($command);
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
+ $iteratorCommand = $this->readAttribute($iterator, 'originalCommand');
+ $this->assertSame($command, $iteratorCommand);
+ }
+
+ public function testClientHoldsInflector()
+ {
+ $client = new Mock\MockClient();
+ $this->assertInstanceOf('Guzzle\Inflection\MemoizingInflector', $client->getInflector());
+
+ $inflector = new Inflector();
+ $client->setInflector($inflector);
+ $this->assertSame($inflector, $client->getInflector());
+ }
+
+ public function testClientAddsGlobalCommandOptions()
+ {
+ $client = new Mock\MockClient('http://www.foo.com', array(
+ Client::COMMAND_PARAMS => array(
+ 'mesa' => 'bar'
+ )
+ ));
+ $command = $client->getCommand('mock_command');
+ $this->assertEquals('bar', $command->get('mesa'));
+ }
+
+ public function testSupportsServiceDescriptionBaseUrls()
+ {
+ $description = new ServiceDescription(array('baseUrl' => 'http://foo.com'));
+ $client = new Client();
+ $client->setDescription($description);
+ $this->assertEquals('http://foo.com', $client->getBaseUrl());
+ }
+
+ public function testMergesDefaultCommandParamsCorrectly()
+ {
+ $client = new Mock\MockClient('http://www.foo.com', array(
+ Client::COMMAND_PARAMS => array(
+ 'mesa' => 'bar',
+ 'jar' => 'jar'
+ )
+ ));
+ $command = $client->getCommand('mock_command', array('jar' => 'test'));
+ $this->assertEquals('bar', $command->get('mesa'));
+ $this->assertEquals('test', $command->get('jar'));
+ }
+
+ /**
+ * @expectedException \Guzzle\Http\Exception\BadResponseException
+ */
+ public function testWrapsSingleCommandExceptions()
+ {
+ $client = new Mock\MockClient('http://foobaz.com');
+ $mock = new MockPlugin(array(new Response(401)));
+ $client->addSubscriber($mock);
+ $client->execute(new MockCommand());
+ }
+
+ public function testWrapsMultipleCommandExceptions()
+ {
+ $client = new Mock\MockClient('http://foobaz.com');
+ $mock = new MockPlugin(array(new Response(200), new Response(200), new Response(404), new Response(500)));
+ $client->addSubscriber($mock);
+
+ $cmds = array(new MockCommand(), new MockCommand(), new MockCommand(), new MockCommand());
+ try {
+ $client->execute($cmds);
+ } catch (CommandTransferException $e) {
+ $this->assertEquals(2, count($e->getFailedRequests()));
+ $this->assertEquals(2, count($e->getSuccessfulRequests()));
+ $this->assertEquals(2, count($e->getFailedCommands()));
+ $this->assertEquals(2, count($e->getSuccessfulCommands()));
+
+ foreach ($e->getSuccessfulCommands() as $c) {
+ $this->assertTrue($c->getResponse()->isSuccessful());
+ }
+
+ foreach ($e->getFailedCommands() as $c) {
+ $this->assertFalse($c->getRequest()->getResponse()->isSuccessful());
+ }
+ }
+ }
+
+ public function testGetCommandAfterTwoSetDescriptions()
+ {
+ $service1 = ServiceDescription::factory(__DIR__ . '/../TestData/test_service.json');
+ $service2 = ServiceDescription::factory(__DIR__ . '/../TestData/test_service_3.json');
+
+ $client = new Mock\MockClient();
+
+ $client->setDescription($service1);
+ $client->getCommand('foo_bar');
+ $client->setDescription($service2);
+ $client->getCommand('baz_qux');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/AbstractCommandTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/AbstractCommandTest.php
new file mode 100644
index 0000000..1004fae
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/AbstractCommandTest.php
@@ -0,0 +1,16 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Service\Client;
+use Guzzle\Service\Description\ServiceDescription;
+
+abstract class AbstractCommandTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected function getClient()
+ {
+ $client = new Client('http://www.google.com/');
+
+ return $client->setDescription(ServiceDescription::factory(__DIR__ . '/../../TestData/test_service.json'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php
new file mode 100644
index 0000000..d762246
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/ClosureCommandTest.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Http\Message\RequestFactory;
+use Guzzle\Service\Command\ClosureCommand;
+use Guzzle\Service\Client;
+
+/**
+ * @covers Guzzle\Service\Command\ClosureCommand
+ */
+class ClosureCommandTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage A closure must be passed in the parameters array
+ */
+ public function testConstructorValidatesClosure()
+ {
+ $c = new ClosureCommand();
+ }
+
+ public function testExecutesClosure()
+ {
+ $c = new ClosureCommand(array(
+ 'closure' => function($command, $api) {
+ $command->set('testing', '123');
+ $request = RequestFactory::getInstance()->create('GET', 'http://www.test.com/');
+ return $request;
+ }
+ ));
+
+ $client = $this->getServiceBuilder()->get('mock');
+ $c->setClient($client)->prepare();
+ $this->assertEquals('123', $c->get('testing'));
+ $this->assertEquals('http://www.test.com/', $c->getRequest()->getUrl());
+ }
+
+ /**
+ * @expectedException UnexpectedValueException
+ * @expectedExceptionMessage Closure command did not return a RequestInterface object
+ */
+ public function testMustReturnRequest()
+ {
+ $c = new ClosureCommand(array(
+ 'closure' => function($command, $api) {
+ return false;
+ }
+ ));
+
+ $client = $this->getServiceBuilder()->get('mock');
+ $c->setClient($client)->prepare();
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/CommandTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/CommandTest.php
new file mode 100644
index 0000000..b7173d4
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/CommandTest.php
@@ -0,0 +1,445 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Plugin\Mock\MockPlugin;
+use Guzzle\Http\EntityBody;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Client;
+use Guzzle\Service\Command\AbstractCommand;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Description\SchemaValidator;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+use Guzzle\Tests\Service\Mock\Command\Sub\Sub;
+
+/**
+ * @covers Guzzle\Service\Command\AbstractCommand
+ */
+class CommandTest extends AbstractCommandTest
+{
+ public function testConstructorAddsDefaultParams()
+ {
+ $command = new MockCommand();
+ $this->assertEquals('123', $command->get('test'));
+ $this->assertFalse($command->isPrepared());
+ $this->assertFalse($command->isExecuted());
+ }
+
+ public function testDeterminesShortName()
+ {
+ $api = new Operation(array('name' => 'foobar'));
+ $command = new MockCommand(array(), $api);
+ $this->assertEquals('foobar', $command->getName());
+
+ $command = new MockCommand();
+ $this->assertEquals('mock_command', $command->getName());
+
+ $command = new Sub();
+ $this->assertEquals('sub.sub', $command->getName());
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testGetRequestThrowsExceptionBeforePreparation()
+ {
+ $command = new MockCommand();
+ $command->getRequest();
+ }
+
+ public function testGetResponseExecutesCommandsWhenNeeded()
+ {
+ $response = new Response(200);
+ $client = $this->getClient();
+ $this->setMockResponse($client, array($response));
+ $command = new MockCommand();
+ $command->setClient($client);
+ $this->assertSame($response, $command->getResponse());
+ $this->assertSame($response, $command->getResponse());
+ }
+
+ public function testGetResultExecutesCommandsWhenNeeded()
+ {
+ $response = new Response(200);
+ $client = $this->getClient();
+ $this->setMockResponse($client, array($response));
+ $command = new MockCommand();
+ $command->setClient($client);
+ $this->assertSame($response, $command->getResult());
+ $this->assertSame($response, $command->getResult());
+ }
+
+ public function testSetClient()
+ {
+ $command = new MockCommand();
+ $client = $this->getClient();
+
+ $command->setClient($client);
+ $this->assertEquals($client, $command->getClient());
+
+ unset($client);
+ unset($command);
+
+ $command = new MockCommand();
+ $client = $this->getClient();
+
+ $command->setClient($client)->prepare();
+ $this->assertEquals($client, $command->getClient());
+ $this->assertTrue($command->isPrepared());
+ }
+
+ public function testExecute()
+ {
+ $client = $this->getClient();
+ $response = new Response(200, array(
+ 'Content-Type' => 'application/xml'
+ ), '<xml><data>123</data></xml>');
+ $this->setMockResponse($client, array($response));
+ $command = new MockCommand();
+ $this->assertSame($command, $command->setClient($client));
+
+ // Returns the result of the command
+ $this->assertInstanceOf('SimpleXMLElement', $command->execute());
+
+ $this->assertTrue($command->isPrepared());
+ $this->assertTrue($command->isExecuted());
+ $this->assertSame($response, $command->getResponse());
+ $this->assertInstanceOf('Guzzle\\Http\\Message\\Request', $command->getRequest());
+ // Make sure that the result was automatically set to a SimpleXMLElement
+ $this->assertInstanceOf('SimpleXMLElement', $command->getResult());
+ $this->assertEquals('123', (string) $command->getResult()->data);
+ }
+
+ public function testConvertsJsonResponsesToArray()
+ {
+ $client = $this->getClient();
+ $this->setMockResponse($client, array(
+ new \Guzzle\Http\Message\Response(200, array(
+ 'Content-Type' => 'application/json'
+ ), '{ "key": "Hi!" }'
+ )
+ ));
+ $command = new MockCommand();
+ $command->setClient($client);
+ $command->execute();
+ $this->assertEquals(array(
+ 'key' => 'Hi!'
+ ), $command->getResult());
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ */
+ public function testConvertsInvalidJsonResponsesToArray()
+ {
+ $json = '{ "key": "Hi!" }invalid';
+ // Some implementations of php-json extension are not strict enough
+ // and allow to parse invalid json ignoring invalid parts
+ // See https://github.com/remicollet/pecl-json-c/issues/5
+ if (json_decode($json) && JSON_ERROR_NONE === json_last_error()) {
+ $this->markTestSkipped('php-pecl-json library regression issues');
+ }
+
+ $client = $this->getClient();
+ $this->setMockResponse($client, array(
+ new \Guzzle\Http\Message\Response(200, array(
+ 'Content-Type' => 'application/json'
+ ), $json
+ )
+ ));
+ $command = new MockCommand();
+ $command->setClient($client);
+ $command->execute();
+ }
+
+ public function testProcessResponseIsNotXml()
+ {
+ $client = $this->getClient();
+ $this->setMockResponse($client, array(
+ new Response(200, array(
+ 'Content-Type' => 'application/octet-stream'
+ ), 'abc,def,ghi')
+ ));
+ $command = new MockCommand();
+ $client->execute($command);
+
+ // Make sure that the result was not converted to XML
+ $this->assertFalse($command->getResult() instanceof \SimpleXMLElement);
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testExecuteThrowsExceptionWhenNoClientIsSet()
+ {
+ $command = new MockCommand();
+ $command->execute();
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testPrepareThrowsExceptionWhenNoClientIsSet()
+ {
+ $command = new MockCommand();
+ $command->prepare();
+ }
+
+ public function testCommandsAllowsCustomRequestHeaders()
+ {
+ $command = new MockCommand();
+ $command->getRequestHeaders()->set('test', '123');
+ $this->assertInstanceOf('Guzzle\Common\Collection', $command->getRequestHeaders());
+ $this->assertEquals('123', $command->getRequestHeaders()->get('test'));
+
+ $command->setClient($this->getClient())->prepare();
+ $this->assertEquals('123', (string) $command->getRequest()->getHeader('test'));
+ }
+
+ public function testCommandsAllowsCustomRequestHeadersAsArray()
+ {
+ $command = new MockCommand(array(AbstractCommand::HEADERS_OPTION => array('Foo' => 'Bar')));
+ $this->assertInstanceOf('Guzzle\Common\Collection', $command->getRequestHeaders());
+ $this->assertEquals('Bar', $command->getRequestHeaders()->get('Foo'));
+ }
+
+ private function getOperation()
+ {
+ return new Operation(array(
+ 'name' => 'foobar',
+ 'httpMethod' => 'POST',
+ 'class' => 'Guzzle\\Tests\\Service\\Mock\\Command\\MockCommand',
+ 'parameters' => array(
+ 'test' => array(
+ 'default' => '123',
+ 'type' => 'string'
+ )
+ )));
+ }
+
+ public function testCommandsUsesOperation()
+ {
+ $api = $this->getOperation();
+ $command = new MockCommand(array(), $api);
+ $this->assertSame($api, $command->getOperation());
+ $command->setClient($this->getClient())->prepare();
+ $this->assertEquals('123', $command->get('test'));
+ $this->assertSame($api, $command->getOperation($api));
+ }
+
+ public function testCloneMakesNewRequest()
+ {
+ $client = $this->getClient();
+ $command = new MockCommand(array(), $this->getOperation());
+ $command->setClient($client);
+
+ $command->prepare();
+ $this->assertTrue($command->isPrepared());
+
+ $command2 = clone $command;
+ $this->assertFalse($command2->isPrepared());
+ }
+
+ public function testHasOnCompleteMethod()
+ {
+ $that = $this;
+ $called = 0;
+
+ $testFunction = function($command) use (&$called, $that) {
+ $called++;
+ $that->assertInstanceOf('Guzzle\Service\Command\CommandInterface', $command);
+ };
+
+ $client = $this->getClient();
+ $command = new MockCommand(array(
+ 'command.on_complete' => $testFunction
+ ), $this->getOperation());
+ $command->setClient($client);
+
+ $command->prepare()->setResponse(new Response(200), true);
+ $command->execute();
+ $this->assertEquals(1, $called);
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testOnCompleteMustBeCallable()
+ {
+ $client = $this->getClient();
+ $command = new MockCommand();
+ $command->setOnComplete('foo');
+ }
+
+ public function testCanSetResultManually()
+ {
+ $client = $this->getClient();
+ $client->getEventDispatcher()->addSubscriber(new MockPlugin(array(
+ new Response(200)
+ )));
+ $command = new MockCommand();
+ $client->execute($command);
+ $command->setResult('foo!');
+ $this->assertEquals('foo!', $command->getResult());
+ }
+
+ public function testCanInitConfig()
+ {
+ $command = $this->getMockBuilder('Guzzle\\Service\\Command\\AbstractCommand')
+ ->setConstructorArgs(array(array(
+ 'foo' => 'bar'
+ ), new Operation(array(
+ 'parameters' => array(
+ 'baz' => new Parameter(array(
+ 'default' => 'baaar'
+ ))
+ )
+ ))))
+ ->getMockForAbstractClass();
+
+ $this->assertEquals('bar', $command['foo']);
+ $this->assertEquals('baaar', $command['baz']);
+ }
+
+ public function testAddsCurlOptionsToRequestsWhenPreparing()
+ {
+ $command = new MockCommand(array(
+ 'foo' => 'bar',
+ 'curl.options' => array('CURLOPT_PROXYPORT' => 8080)
+ ));
+ $client = new Client();
+ $command->setClient($client);
+ $request = $command->prepare();
+ $this->assertEquals(8080, $request->getCurlOptions()->get(CURLOPT_PROXYPORT));
+ }
+
+ public function testIsInvokable()
+ {
+ $client = $this->getClient();
+ $response = new Response(200);
+ $this->setMockResponse($client, array($response));
+ $command = new MockCommand();
+ $command->setClient($client);
+ // Returns the result of the command
+ $this->assertSame($response, $command());
+ }
+
+ public function testCreatesDefaultOperation()
+ {
+ $command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')->getMockForAbstractClass();
+ $this->assertInstanceOf('Guzzle\Service\Description\Operation', $command->getOperation());
+ }
+
+ public function testAllowsValidatorToBeInjected()
+ {
+ $command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')->getMockForAbstractClass();
+ $v = new SchemaValidator();
+ $command->setValidator($v);
+ $this->assertSame($v, $this->readAttribute($command, 'validator'));
+ }
+
+ public function testCanDisableValidation()
+ {
+ $command = new MockCommand();
+ $command->setClient(new \Guzzle\Service\Client());
+ $v = $this->getMockBuilder('Guzzle\Service\Description\SchemaValidator')
+ ->setMethods(array('validate'))
+ ->getMock();
+ $v->expects($this->never())->method('validate');
+ $command->setValidator($v);
+ $command->set(AbstractCommand::DISABLE_VALIDATION, true);
+ $command->prepare();
+ }
+
+ public function testValidatorDoesNotUpdateNonDefaultValues()
+ {
+ $command = new MockCommand(array('test' => 123, 'foo' => 'bar'));
+ $command->setClient(new \Guzzle\Service\Client());
+ $command->prepare();
+ $this->assertEquals(123, $command->get('test'));
+ $this->assertEquals('bar', $command->get('foo'));
+ }
+
+ public function testValidatorUpdatesDefaultValues()
+ {
+ $command = new MockCommand();
+ $command->setClient(new \Guzzle\Service\Client());
+ $command->prepare();
+ $this->assertEquals(123, $command->get('test'));
+ $this->assertEquals('abc', $command->get('_internal'));
+ }
+
+ /**
+ * @expectedException \Guzzle\Service\Exception\ValidationException
+ * @expectedExceptionMessage [Foo] Baz
+ */
+ public function testValidatesCommandBeforeSending()
+ {
+ $command = new MockCommand();
+ $command->setClient(new \Guzzle\Service\Client());
+ $v = $this->getMockBuilder('Guzzle\Service\Description\SchemaValidator')
+ ->setMethods(array('validate', 'getErrors'))
+ ->getMock();
+ $v->expects($this->any())->method('validate')->will($this->returnValue(false));
+ $v->expects($this->any())->method('getErrors')->will($this->returnValue(array('[Foo] Baz', '[Bar] Boo')));
+ $command->setValidator($v);
+ $command->prepare();
+ }
+
+ /**
+ * @expectedException \Guzzle\Service\Exception\ValidationException
+ * @expectedExceptionMessage Validation errors: [abc] must be of type string
+ */
+ public function testValidatesAdditionalParameters()
+ {
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'foo' => array(
+ 'parameters' => array(
+ 'baz' => array('type' => 'integer')
+ ),
+ 'additionalParameters' => array(
+ 'type' => 'string'
+ )
+ )
+ )
+ ));
+
+ $client = new Client();
+ $client->setDescription($description);
+ $command = $client->getCommand('foo', array(
+ 'abc' => false,
+ 'command.headers' => array('foo' => 'bar')
+ ));
+ $command->prepare();
+ }
+
+ public function testCanAccessValidationErrorsFromCommand()
+ {
+ $validationErrors = array('[Foo] Baz', '[Bar] Boo');
+ $command = new MockCommand();
+ $command->setClient(new \Guzzle\Service\Client());
+
+ $this->assertFalse($command->getValidationErrors());
+
+ $v = $this->getMockBuilder('Guzzle\Service\Description\SchemaValidator')
+ ->setMethods(array('validate', 'getErrors'))
+ ->getMock();
+ $v->expects($this->any())->method('getErrors')->will($this->returnValue($validationErrors));
+ $command->setValidator($v);
+
+ $this->assertEquals($validationErrors, $command->getValidationErrors());
+ }
+
+ public function testCanChangeResponseBody()
+ {
+ $body = EntityBody::factory();
+ $command = new MockCommand();
+ $command->setClient(new \Guzzle\Service\Client());
+ $command->set(AbstractCommand::RESPONSE_BODY, $body);
+ $request = $command->prepare();
+ $this->assertSame($body, $this->readAttribute($request, 'responseBody'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultRequestSerializerTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultRequestSerializerTest.php
new file mode 100644
index 0000000..b7a4682
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultRequestSerializerTest.php
@@ -0,0 +1,122 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Service\Command\DefaultRequestSerializer;
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Service\Client;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Command\LocationVisitor\Request\HeaderVisitor;
+use Guzzle\Service\Command\LocationVisitor\VisitorFlyweight;
+
+/**
+ * @covers Guzzle\Service\Command\DefaultRequestSerializer
+ */
+class DefaultRequestSerializerTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var EntityEnclosingRequest */
+ protected $request;
+
+ /** @var \Guzzle\Service\Command\AbstractCommand */
+ protected $command;
+
+ /** @var Client */
+ protected $client;
+
+ /** @var DefaultRequestSerializer */
+ protected $serializer;
+
+ /** @var Operation */
+ protected $operation;
+
+ public function setUp()
+ {
+ $this->serializer = DefaultRequestSerializer::getInstance();
+ $this->client = new Client('http://foo.com/baz');
+ $this->operation = new Operation(array('httpMethod' => 'POST'));
+ $this->command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')
+ ->setConstructorArgs(array(array(), $this->operation))
+ ->getMockForAbstractClass();
+ $this->command->setClient($this->client);
+ }
+
+ public function testAllowsCustomVisitor()
+ {
+ $this->serializer->addVisitor('custom', new HeaderVisitor());
+ $this->command['test'] = '123';
+ $this->operation->addParam(new Parameter(array('name' => 'test', 'location' => 'custom')));
+ $request = $this->serializer->prepare($this->command);
+ $this->assertEquals('123', (string) $request->getHeader('test'));
+ }
+
+ public function testUsesRelativePath()
+ {
+ $this->operation->setUri('bar');
+ $request = $this->serializer->prepare($this->command);
+ $this->assertEquals('http://foo.com/baz/bar', (string) $request->getUrl());
+ }
+
+ public function testUsesRelativePathWithUriLocations()
+ {
+ $this->command['test'] = '123';
+ $this->operation->setUri('bar/{test}');
+ $this->operation->addParam(new Parameter(array('name' => 'test', 'location' => 'uri')));
+ $request = $this->serializer->prepare($this->command);
+ $this->assertEquals('http://foo.com/baz/bar/123', (string) $request->getUrl());
+ }
+
+ public function testAllowsCustomFactory()
+ {
+ $f = new VisitorFlyweight();
+ $serializer = new DefaultRequestSerializer($f);
+ $this->assertSame($f, $this->readAttribute($serializer, 'factory'));
+ }
+
+ public function testMixedParams()
+ {
+ $this->operation->setUri('bar{?limit,fields}');
+ $this->operation->addParam(new Parameter(array(
+ 'name' => 'limit',
+ 'location' => 'uri',
+ 'required' => false,
+ )));
+ $this->operation->addParam(new Parameter(array(
+ 'name' => 'fields',
+ 'location' => 'uri',
+ 'required' => true,
+ )));
+
+ $this->command['fields'] = array('id', 'name');
+
+ $request = $this->serializer->prepare($this->command);
+ $this->assertEquals('http://foo.com/baz/bar?fields='.urlencode('id,name'), (string) $request->getUrl());
+ }
+
+ public function testValidatesAdditionalParameters()
+ {
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'foo' => array(
+ 'httpMethod' => 'PUT',
+ 'parameters' => array(
+ 'bar' => array('location' => 'header')
+ ),
+ 'additionalParameters' => array(
+ 'location' => 'json'
+ )
+ )
+ )
+ ));
+
+ $client = new Client();
+ $client->setDescription($description);
+ $command = $client->getCommand('foo');
+ $command['bar'] = 'test';
+ $command['hello'] = 'abc';
+ $request = $command->prepare();
+ $this->assertEquals('test', (string) $request->getHeader('bar'));
+ $this->assertEquals('{"hello":"abc"}', (string) $request->getBody());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultResponseParserTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultResponseParserTest.php
new file mode 100644
index 0000000..a6a02f9
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/DefaultResponseParserTest.php
@@ -0,0 +1,59 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Client;
+use Guzzle\Service\Command\DefaultResponseParser;
+use Guzzle\Service\Command\OperationCommand;
+use Guzzle\Service\Description\Operation;
+
+/**
+ * @covers Guzzle\Service\Command\DefaultResponseParser
+ */
+class DefaultResponseParserTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testParsesXmlResponses()
+ {
+ $op = new OperationCommand(array(), new Operation());
+ $op->setClient(new Client());
+ $request = $op->prepare();
+ $request->setResponse(new Response(200, array(
+ 'Content-Type' => 'application/xml'
+ ), '<Foo><Baz>Bar</Baz></Foo>'), true);
+ $this->assertInstanceOf('SimpleXMLElement', $op->execute());
+ }
+
+ public function testParsesJsonResponses()
+ {
+ $op = new OperationCommand(array(), new Operation());
+ $op->setClient(new Client());
+ $request = $op->prepare();
+ $request->setResponse(new Response(200, array(
+ 'Content-Type' => 'application/json'
+ ), '{"Baz":"Bar"}'), true);
+ $this->assertEquals(array('Baz' => 'Bar'), $op->execute());
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\RuntimeException
+ */
+ public function testThrowsExceptionWhenParsingJsonFails()
+ {
+ $op = new OperationCommand(array(), new Operation());
+ $op->setClient(new Client());
+ $request = $op->prepare();
+ $request->setResponse(new Response(200, array('Content-Type' => 'application/json'), '{"Baz":ddw}'), true);
+ $op->execute();
+ }
+
+ public function testAddsContentTypeWhenExpectsIsSetOnCommand()
+ {
+ $op = new OperationCommand(array(), new Operation());
+ $op['command.expects'] = 'application/json';
+ $op->setClient(new Client());
+ $request = $op->prepare();
+ $request->setResponse(new Response(200, null, '{"Baz":"Bar"}'), true);
+ $this->assertEquals(array('Baz' => 'Bar'), $op->execute());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/AliasFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/AliasFactoryTest.php
new file mode 100644
index 0000000..ab1041a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/AliasFactoryTest.php
@@ -0,0 +1,76 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Service\Client;
+use Guzzle\Service\Command\Factory\AliasFactory;
+use Guzzle\Service\Command\Factory\MapFactory;
+use Guzzle\Service\Command\Factory\CompositeFactory;
+
+/**
+ * @covers Guzzle\Service\Command\Factory\AliasFactory
+ */
+class AliasFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private $factory;
+ private $client;
+
+ public function setup()
+ {
+ $this->client = new Client();
+
+ $map = new MapFactory(array(
+ 'test' => 'Guzzle\Tests\Service\Mock\Command\MockCommand',
+ 'test1' => 'Guzzle\Tests\Service\Mock\Command\OtherCommand'
+ ));
+
+ $this->factory = new AliasFactory($this->client, array(
+ 'foo' => 'test',
+ 'bar' => 'sub',
+ 'sub' => 'test1',
+ 'krull' => 'test3',
+ 'krull_2' => 'krull',
+ 'sub_2' => 'bar',
+ 'bad_link' => 'jarjar'
+ ));
+
+ $map2 = new MapFactory(array(
+ 'test3' => 'Guzzle\Tests\Service\Mock\Command\Sub\Sub'
+ ));
+
+ $this->client->setCommandFactory(new CompositeFactory(array($map, $this->factory, $map2)));
+ }
+
+ public function aliasProvider()
+ {
+ return array(
+ array('foo', 'Guzzle\Tests\Service\Mock\Command\MockCommand', false),
+ array('bar', 'Guzzle\Tests\Service\Mock\Command\OtherCommand', false),
+ array('sub', 'Guzzle\Tests\Service\Mock\Command\OtherCommand', false),
+ array('sub_2', 'Guzzle\Tests\Service\Mock\Command\OtherCommand', false),
+ array('krull', 'Guzzle\Tests\Service\Mock\Command\Sub\Sub', false),
+ array('krull_2', 'Guzzle\Tests\Service\Mock\Command\Sub\Sub', false),
+ array('missing', null, true),
+ array('bad_link', null, true)
+ );
+ }
+
+ /**
+ * @dataProvider aliasProvider
+ */
+ public function testAliasesCommands($key, $result, $exception)
+ {
+ try {
+ $command = $this->client->getCommand($key);
+ if (is_null($result)) {
+ $this->assertNull($command);
+ } else {
+ $this->assertInstanceof($result, $command);
+ }
+ } catch (\Exception $e) {
+ if (!$exception) {
+ $this->fail('Got exception when it was not expected');
+ }
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/CompositeFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/CompositeFactoryTest.php
new file mode 100644
index 0000000..b896dcf
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/CompositeFactoryTest.php
@@ -0,0 +1,124 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Service\Command\Factory\CompositeFactory;
+
+/**
+ * @covers Guzzle\Service\Command\Factory\CompositeFactory
+ */
+class CompositeFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ private function getFactory($class = 'Guzzle\\Service\\Command\\Factory\\MapFactory')
+ {
+ return $mock = $this->getMockBuilder($class)
+ ->disableOriginalConstructor()
+ ->getMock();
+ }
+
+ public function testIsIterable()
+ {
+ $factory = new CompositeFactory(array($this->getFactory(), $this->getFactory()));
+ $this->assertEquals(2, count($factory));
+ $this->assertEquals(2, count(iterator_to_array($factory->getIterator())));
+ }
+
+ public function testFindsFactories()
+ {
+ $f1 = $this->getFactory();
+ $f2 = $this->getFactory('Guzzle\\Service\\Command\\Factory\\CompositeFactory');
+ $factory = new CompositeFactory(array($f1, $f2));
+ $this->assertNull($factory->find('foo'));
+ $this->assertNull($factory->find($this->getFactory()));
+ $this->assertSame($f1, $factory->find('Guzzle\\Service\\Command\\Factory\\MapFactory'));
+ $this->assertSame($f2, $factory->find('Guzzle\\Service\\Command\\Factory\\CompositeFactory'));
+ $this->assertSame($f1, $factory->find($f1));
+ $this->assertSame($f2, $factory->find($f2));
+
+ $this->assertFalse($factory->has('foo'));
+ $this->assertTrue($factory->has('Guzzle\\Service\\Command\\Factory\\MapFactory'));
+ $this->assertTrue($factory->has('Guzzle\\Service\\Command\\Factory\\CompositeFactory'));
+ }
+
+ public function testCreatesCommands()
+ {
+ $factory = new CompositeFactory();
+ $this->assertNull($factory->factory('foo'));
+
+ $f1 = $this->getFactory();
+ $mockCommand1 = $this->getMockForAbstractClass('Guzzle\\Service\\Command\\AbstractCommand');
+
+ $f1->expects($this->once())
+ ->method('factory')
+ ->with($this->equalTo('foo'))
+ ->will($this->returnValue($mockCommand1));
+
+ $factory = new CompositeFactory(array($f1));
+ $this->assertSame($mockCommand1, $factory->factory('foo'));
+ }
+
+ public function testAllowsRemovalOfFactories()
+ {
+ $f1 = $this->getFactory();
+ $f2 = $this->getFactory();
+ $f3 = $this->getFactory('Guzzle\\Service\\Command\\Factory\\CompositeFactory');
+ $factories = array($f1, $f2, $f3);
+ $factory = new CompositeFactory($factories);
+
+ $factory->remove('foo');
+ $this->assertEquals($factories, $factory->getIterator()->getArrayCopy());
+
+ $factory->remove($f1);
+ $this->assertEquals(array($f2, $f3), $factory->getIterator()->getArrayCopy());
+
+ $factory->remove('Guzzle\\Service\\Command\\Factory\\MapFactory');
+ $this->assertEquals(array($f3), $factory->getIterator()->getArrayCopy());
+
+ $factory->remove('Guzzle\\Service\\Command\\Factory\\CompositeFactory');
+ $this->assertEquals(array(), $factory->getIterator()->getArrayCopy());
+
+ $factory->remove('foo');
+ $this->assertEquals(array(), $factory->getIterator()->getArrayCopy());
+ }
+
+ public function testAddsFactoriesBeforeAndAtEnd()
+ {
+ $f1 = $this->getFactory();
+ $f2 = $this->getFactory();
+ $f3 = $this->getFactory('Guzzle\\Service\\Command\\Factory\\CompositeFactory');
+ $f4 = $this->getFactory();
+
+ $factory = new CompositeFactory();
+
+ $factory->add($f1);
+ $this->assertEquals(array($f1), $factory->getIterator()->getArrayCopy());
+
+ $factory->add($f2);
+ $this->assertEquals(array($f1, $f2), $factory->getIterator()->getArrayCopy());
+
+ $factory->add($f3, $f2);
+ $this->assertEquals(array($f1, $f3, $f2), $factory->getIterator()->getArrayCopy());
+
+ $factory->add($f4, 'Guzzle\\Service\\Command\\Factory\\CompositeFactory');
+ $this->assertEquals(array($f1, $f4, $f3, $f2), $factory->getIterator()->getArrayCopy());
+ }
+
+ public function testProvidesDefaultChainForClients()
+ {
+ $client = $this->getMock('Guzzle\\Service\\Client');
+ $chain = CompositeFactory::getDefaultChain($client);
+ $a = $chain->getIterator()->getArrayCopy();
+ $this->assertEquals(1, count($a));
+ $this->assertInstanceOf('Guzzle\\Service\\Command\\Factory\\ConcreteClassFactory', $a[0]);
+
+ $description = $this->getMock('Guzzle\\Service\\Description\\ServiceDescription');
+ $client->expects($this->once())
+ ->method('getDescription')
+ ->will($this->returnValue($description));
+ $chain = CompositeFactory::getDefaultChain($client);
+ $a = $chain->getIterator()->getArrayCopy();
+ $this->assertEquals(2, count($a));
+ $this->assertInstanceOf('Guzzle\\Service\\Command\\Factory\\ServiceDescriptionFactory', $a[0]);
+ $this->assertInstanceOf('Guzzle\\Service\\Command\\Factory\\ConcreteClassFactory', $a[1]);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ConcreteClassFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ConcreteClassFactoryTest.php
new file mode 100644
index 0000000..7664718
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ConcreteClassFactoryTest.php
@@ -0,0 +1,49 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Tests\Service\Mock\MockClient;
+use Guzzle\Service\Command\Factory\ConcreteClassFactory;
+
+/**
+ * @covers Guzzle\Service\Command\Factory\ConcreteClassFactory
+ */
+class ConcreteClassFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testProvider()
+ {
+ return array(
+ array('foo', null, 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
+ array('mock_command', 'Guzzle\Tests\Service\Mock\Command\MockCommand', 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
+ array('other_command', 'Guzzle\Tests\Service\Mock\Command\OtherCommand', 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
+ array('sub.sub', 'Guzzle\Tests\Service\Mock\Command\Sub\Sub', 'Guzzle\\Tests\\Service\\Mock\\Command\\'),
+ array('sub.sub', null, 'Guzzle\\Foo\\'),
+ array('foo', null, null),
+ array('mock_command', 'Guzzle\Tests\Service\Mock\Command\MockCommand', null),
+ array('other_command', 'Guzzle\Tests\Service\Mock\Command\OtherCommand', null),
+ array('sub.sub', 'Guzzle\Tests\Service\Mock\Command\Sub\Sub', null)
+ );
+ }
+
+ /**
+ * @dataProvider testProvider
+ */
+ public function testCreatesConcreteCommands($key, $result, $prefix)
+ {
+ if (!$prefix) {
+ $client = new MockClient();
+ } else {
+ $client = new MockClient('', array(
+ 'command.prefix' => $prefix
+ ));
+ }
+
+ $factory = new ConcreteClassFactory($client);
+
+ if (is_null($result)) {
+ $this->assertNull($factory->factory($key));
+ } else {
+ $this->assertInstanceof($result, $factory->factory($key));
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/MapFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/MapFactoryTest.php
new file mode 100644
index 0000000..ee720d1
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/MapFactoryTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Service\Command\Factory\MapFactory;
+
+/**
+ * @covers Guzzle\Service\Command\Factory\MapFactory
+ */
+class MapFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function mapProvider()
+ {
+ return array(
+ array('foo', null),
+ array('test', 'Guzzle\Tests\Service\Mock\Command\MockCommand'),
+ array('test1', 'Guzzle\Tests\Service\Mock\Command\OtherCommand')
+ );
+ }
+
+ /**
+ * @dataProvider mapProvider
+ */
+ public function testCreatesCommandsUsingMappings($key, $result)
+ {
+ $factory = new MapFactory(array(
+ 'test' => 'Guzzle\Tests\Service\Mock\Command\MockCommand',
+ 'test1' => 'Guzzle\Tests\Service\Mock\Command\OtherCommand'
+ ));
+
+ if (is_null($result)) {
+ $this->assertNull($factory->factory($key));
+ } else {
+ $this->assertInstanceof($result, $factory->factory($key));
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ServiceDescriptionFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ServiceDescriptionFactoryTest.php
new file mode 100644
index 0000000..3372634
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/Factory/ServiceDescriptionFactoryTest.php
@@ -0,0 +1,68 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Service\Command\Factory\ServiceDescriptionFactory;
+use Guzzle\Inflection\Inflector;
+
+/**
+ * @covers Guzzle\Service\Command\Factory\ServiceDescriptionFactory
+ */
+class ServiceDescriptionFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testProvider()
+ {
+ return array(
+ array('foo', null),
+ array('jar_jar', 'Guzzle\Tests\Service\Mock\Command\MockCommand'),
+ array('binks', 'Guzzle\Tests\Service\Mock\Command\OtherCommand')
+ );
+ }
+
+ /**
+ * @dataProvider testProvider
+ */
+ public function testCreatesCommandsUsingServiceDescriptions($key, $result)
+ {
+ $d = $this->getDescription();
+
+ $factory = new ServiceDescriptionFactory($d);
+ $this->assertSame($d, $factory->getServiceDescription());
+
+ if (is_null($result)) {
+ $this->assertNull($factory->factory($key));
+ } else {
+ $this->assertInstanceof($result, $factory->factory($key));
+ }
+ }
+
+ public function testUsesUcFirstIfNoExactMatch()
+ {
+ $d = $this->getDescription();
+ $factory = new ServiceDescriptionFactory($d, new Inflector());
+ $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('Test'));
+ $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('test'));
+ }
+
+ public function testUsesInflectionIfNoExactMatch()
+ {
+ $d = $this->getDescription();
+ $factory = new ServiceDescriptionFactory($d, new Inflector());
+ $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('Binks'));
+ $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\OtherCommand', $factory->factory('binks'));
+ $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\MockCommand', $factory->factory('JarJar'));
+ $this->assertInstanceof('Guzzle\Tests\Service\Mock\Command\MockCommand', $factory->factory('jar_jar'));
+ }
+
+ protected function getDescription()
+ {
+ return ServiceDescription::factory(array(
+ 'operations' => array(
+ 'jar_jar' => array('class' => 'Guzzle\Tests\Service\Mock\Command\MockCommand'),
+ 'binks' => array('class' => 'Guzzle\Tests\Service\Mock\Command\OtherCommand'),
+ 'Test' => array('class' => 'Guzzle\Tests\Service\Mock\Command\OtherCommand')
+ )
+ ));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php
new file mode 100644
index 0000000..46b472e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/AbstractVisitorTestCase.php
@@ -0,0 +1,110 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Description\SchemaValidator;
+use Guzzle\Service\Command\OperationCommand;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+use Guzzle\Tests\Service\Mock\MockClient;
+
+abstract class AbstractVisitorTestCase extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $command;
+ protected $request;
+ protected $param;
+ protected $validator;
+
+ public function setUp()
+ {
+ $this->command = new MockCommand();
+ $this->request = new EntityEnclosingRequest('POST', 'http://www.test.com/some/path.php');
+ $this->validator = new SchemaValidator();
+ }
+
+ protected function getCommand($location)
+ {
+ $command = new OperationCommand(array(), $this->getNestedCommand($location));
+ $command->setClient(new MockClient());
+
+ return $command;
+ }
+
+ protected function getNestedCommand($location)
+ {
+ return new Operation(array(
+ 'httpMethod' => 'POST',
+ 'parameters' => array(
+ 'foo' => new Parameter(array(
+ 'type' => 'object',
+ 'location' => $location,
+ 'sentAs' => 'Foo',
+ 'required' => true,
+ 'properties' => array(
+ 'test' => array(
+ 'type' => 'object',
+ 'required' => true,
+ 'properties' => array(
+ 'baz' => array(
+ 'type' => 'boolean',
+ 'default' => true
+ ),
+ 'jenga' => array(
+ 'type' => 'string',
+ 'default' => 'hello',
+ 'sentAs' => 'Jenga_Yall!',
+ 'filters' => array('strtoupper')
+ )
+ )
+ ),
+ 'bar' => array('default' => 123)
+ ),
+ 'additionalProperties' => array(
+ 'type' => 'string',
+ 'filters' => array('strtoupper'),
+ 'location' => $location
+ )
+ )),
+ 'arr' => new Parameter(array(
+ 'type' => 'array',
+ 'location' => $location,
+ 'items' => array(
+ 'type' => 'string',
+ 'filters' => array('strtoupper')
+ )
+ )),
+ )
+ ));
+ }
+
+ protected function getCommandWithArrayParamAndFilters()
+ {
+ $operation = new Operation(array(
+ 'httpMethod' => 'POST',
+ 'parameters' => array(
+ 'foo' => new Parameter(array(
+ 'type' => 'string',
+ 'location' => 'query',
+ 'sentAs' => 'Foo',
+ 'required' => true,
+ 'default' => 'bar',
+ 'filters' => array('strtoupper')
+ )),
+ 'arr' => new Parameter(array(
+ 'type' => 'array',
+ 'location' => 'query',
+ 'sentAs' => 'Arr',
+ 'required' => true,
+ 'default' => array(123, 456, 789),
+ 'filters' => array(array('method' => 'implode', 'args' => array(',', '@value')))
+ ))
+ )
+ ));
+ $command = new OperationCommand(array(), $operation);
+ $command->setClient(new MockClient());
+
+ return $command;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/BodyVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/BodyVisitorTest.php
new file mode 100644
index 0000000..2a95c45
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/BodyVisitorTest.php
@@ -0,0 +1,63 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Http\EntityBody;
+use Guzzle\Service\Command\LocationVisitor\Request\BodyVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\BodyVisitor
+ */
+class BodyVisitorTest extends AbstractVisitorTestCase
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('body')->getParam('foo')->setSentAs('Foo');
+ $visitor->visit($this->command, $this->request, $param, '123');
+ $this->assertEquals('123', (string) $this->request->getBody());
+ $this->assertNull($this->request->getHeader('Expect'));
+ }
+
+ public function testAddsExpectHeaderWhenSetToTrue()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('body')->getParam('foo')->setSentAs('Foo');
+ $param->setData('expect_header', true);
+ $visitor->visit($this->command, $this->request, $param, '123');
+ $this->assertEquals('123', (string) $this->request->getBody());
+ }
+
+ public function testCanDisableExpectHeader()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('body')->getParam('foo')->setSentAs('Foo');
+ $param->setData('expect_header', false);
+ $visitor->visit($this->command, $this->request, $param, '123');
+ $this->assertNull($this->request->getHeader('Expect'));
+ }
+
+ public function testCanSetExpectHeaderBasedOnSize()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('body')->getParam('foo')->setSentAs('Foo');
+ // The body is less than the cutoff
+ $param->setData('expect_header', 5);
+ $visitor->visit($this->command, $this->request, $param, '123');
+ $this->assertNull($this->request->getHeader('Expect'));
+ // Now check when the body is greater than the cutoff
+ $param->setData('expect_header', 2);
+ $visitor->visit($this->command, $this->request, $param, '123');
+ $this->assertEquals('100-Continue', (string) $this->request->getHeader('Expect'));
+ }
+
+ public function testAddsContentEncodingWhenSetOnBody()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('body')->getParam('foo')->setSentAs('Foo');
+ $body = EntityBody::factory('foo');
+ $body->compress();
+ $visitor->visit($this->command, $this->request, $param, $body);
+ $this->assertEquals('gzip', (string) $this->request->getHeader('Content-Encoding'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/HeaderVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/HeaderVisitorTest.php
new file mode 100644
index 0000000..7ea1ae9
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/HeaderVisitorTest.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Command\LocationVisitor\Request\HeaderVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\HeaderVisitor
+ */
+class HeaderVisitorTest extends AbstractVisitorTestCase
+{
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testValidatesHeaderMapsAreArrays()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('header')->getParam('foo')->setSentAs('test');
+ $param->setAdditionalProperties(new Parameter(array()));
+ $visitor->visit($this->command, $this->request, $param, 'test');
+ }
+
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('header')->getParam('foo')->setSentAs('test');
+ $param->setAdditionalProperties(false);
+ $visitor->visit($this->command, $this->request, $param, '123');
+ $this->assertEquals('123', (string) $this->request->getHeader('test'));
+ }
+
+ public function testVisitsMappedPrefixHeaders()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('header')->getParam('foo')->setSentAs('test');
+ $param->setSentAs('x-foo-');
+ $param->setAdditionalProperties(new Parameter(array(
+ 'type' => 'string'
+ )));
+ $visitor->visit($this->command, $this->request, $param, array(
+ 'bar' => 'test',
+ 'baz' => '123'
+ ));
+ $this->assertEquals('test', (string) $this->request->getHeader('x-foo-bar'));
+ $this->assertEquals('123', (string) $this->request->getHeader('x-foo-baz'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/JsonVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/JsonVisitorTest.php
new file mode 100644
index 0000000..ea6782f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/JsonVisitorTest.php
@@ -0,0 +1,60 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Command\LocationVisitor\Request\JsonVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\JsonVisitor
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\AbstractRequestVisitor::resolveRecursively
+ */
+class JsonVisitorTest extends AbstractVisitorTestCase
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ // Test after when no body query values were found
+ $visitor->after($this->command, $this->request);
+
+ $param = $this->getNestedCommand('json')->getParam('foo');
+ $visitor->visit($this->command, $this->request, $param->setSentAs('test'), '123');
+ $visitor->visit($this->command, $this->request, $param->setSentAs('test2'), 'abc');
+ $visitor->after($this->command, $this->request);
+ $this->assertEquals('{"test":"123","test2":"abc"}', (string) $this->request->getBody());
+ }
+
+ public function testAddsJsonHeader()
+ {
+ $visitor = new Visitor();
+ $visitor->setContentTypeHeader('application/json-foo');
+ $param = $this->getNestedCommand('json')->getParam('foo');
+ $visitor->visit($this->command, $this->request, $param->setSentAs('test'), '123');
+ $visitor->after($this->command, $this->request);
+ $this->assertEquals('application/json-foo', (string) $this->request->getHeader('Content-Type'));
+ }
+
+ public function testRecursivelyBuildsJsonBodies()
+ {
+ $command = $this->getCommand('json');
+ $request = $command->prepare();
+ $this->assertEquals('{"Foo":{"test":{"baz":true,"Jenga_Yall!":"HELLO"},"bar":123}}', (string) $request->getBody());
+ }
+
+ public function testAppliesFiltersToAdditionalProperties()
+ {
+ $command = $this->getCommand('json');
+ $command->set('foo', array('not_set' => 'abc'));
+ $request = $command->prepare();
+ $result = json_decode($request->getBody(), true);
+ $this->assertEquals('ABC', $result['Foo']['not_set']);
+ }
+
+ public function testAppliesFiltersToArrayItemValues()
+ {
+ $command = $this->getCommand('json');
+ $command->set('arr', array('a', 'b'));
+ $request = $command->prepare();
+ $result = json_decode($request->getBody(), true);
+ $this->assertEquals(array('A', 'B'), $result['arr']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFieldVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFieldVisitorTest.php
new file mode 100644
index 0000000..540b410
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFieldVisitorTest.php
@@ -0,0 +1,33 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Command\LocationVisitor\Request\PostFieldVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\PostFieldVisitor
+ */
+class PostFieldVisitorTest extends AbstractVisitorTestCase
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('postField')->getParam('foo');
+ $visitor->visit($this->command, $this->request, $param->setSentAs('test'), '123');
+ $this->assertEquals('123', (string) $this->request->getPostField('test'));
+ }
+
+ public function testRecursivelyBuildsPostFields()
+ {
+ $command = $this->getCommand('postField');
+ $request = $command->prepare();
+ $visitor = new Visitor();
+ $param = $command->getOperation()->getParam('foo');
+ $visitor->visit($command, $request, $param, $command['foo']);
+ $visitor->after($command, $request);
+ $this->assertEquals(
+ 'Foo[test][baz]=1&Foo[test][Jenga_Yall!]=HELLO&Foo[bar]=123',
+ rawurldecode((string) $request->getPostFields())
+ );
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFileVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFileVisitorTest.php
new file mode 100644
index 0000000..21e3cec
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/PostFileVisitorTest.php
@@ -0,0 +1,54 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Client;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Http\Message\PostFile;
+use Guzzle\Service\Command\LocationVisitor\Request\PostFileVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\PostFileVisitor
+ */
+class PostFileVisitorTest extends AbstractVisitorTestCase
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('postFile')->getParam('foo');
+
+ // Test using a path to a file
+ $visitor->visit($this->command, $this->request, $param->setSentAs('test_3'), __FILE__);
+ $this->assertInternalType('array', $this->request->getPostFile('test_3'));
+
+ // Test with a PostFile
+ $visitor->visit($this->command, $this->request, $param->setSentAs(null), new PostFile('baz', __FILE__));
+ $this->assertInternalType('array', $this->request->getPostFile('baz'));
+ }
+
+ public function testVisitsLocationWithMultipleFiles()
+ {
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'DoPost' => array(
+ 'httpMethod' => 'POST',
+ 'parameters' => array(
+ 'foo' => array(
+ 'location' => 'postFile',
+ 'type' => array('string', 'array')
+ )
+ )
+ )
+ )
+ ));
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array("HTTP/1.1 200 OK\r\nContent-Length:0\r\n\r\n"));
+ $client = new Client($this->getServer()->getUrl());
+ $client->setDescription($description);
+ $command = $client->getCommand('DoPost', array('foo' => array(__FILE__, __FILE__)));
+ $command->execute();
+ $received = $this->getServer()->getReceivedRequests();
+ $this->assertContains('name="foo[0]";', $received[0]);
+ $this->assertContains('name="foo[1]";', $received[0]);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php
new file mode 100644
index 0000000..607af76
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/QueryVisitorTest.php
@@ -0,0 +1,48 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Command\LocationVisitor\Request\QueryVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\QueryVisitor
+ */
+class QueryVisitorTest extends AbstractVisitorTestCase
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('query')->getParam('foo')->setSentAs('test');
+ $visitor->visit($this->command, $this->request, $param, '123');
+ $this->assertEquals('123', $this->request->getQuery()->get('test'));
+ }
+
+ /**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\QueryVisitor
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\AbstractRequestVisitor::resolveRecursively
+ */
+ public function testRecursivelyBuildsQueryStrings()
+ {
+ $command = $this->getCommand('query');
+ $command->getOperation()->getParam('foo')->setSentAs('Foo');
+ $request = $command->prepare();
+ $this->assertEquals(
+ 'Foo[test][baz]=1&Foo[test][Jenga_Yall!]=HELLO&Foo[bar]=123',
+ rawurldecode($request->getQuery())
+ );
+ }
+
+ /**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\AbstractRequestVisitor::resolveRecursively
+ */
+ public function testFiltersAreAppliedToArrayParamType()
+ {
+ $command = $this->getCommandWithArrayParamAndFilters();
+ $request = $command->prepare();
+ $query = $request->getQuery();
+ // param type 'string'
+ $this->assertEquals('BAR', $query->get('Foo'));
+ // param type 'array'
+ $this->assertEquals('123,456,789', $query->get('Arr'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/ResponseBodyVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/ResponseBodyVisitorTest.php
new file mode 100644
index 0000000..ff8cec5
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/ResponseBodyVisitorTest.php
@@ -0,0 +1,20 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Command\LocationVisitor\Request\ResponseBodyVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\ResponseBodyVisitor
+ */
+class ResponseBodyVisitorTest extends AbstractVisitorTestCase
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = $this->getNestedCommand('response_body')->getParam('foo');
+ $visitor->visit($this->command, $this->request, $param, sys_get_temp_dir() . '/foo.txt');
+ $body = $this->readAttribute($this->request, 'responseBody');
+ $this->assertContains('/foo.txt', $body->getUri());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/XmlVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/XmlVisitorTest.php
new file mode 100644
index 0000000..beb58b0
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Request/XmlVisitorTest.php
@@ -0,0 +1,558 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Request;
+
+use Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor;
+use Guzzle\Service\Client;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Http\Message\EntityEnclosingRequest;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Request\XmlVisitor
+ */
+class XmlVisitorTest extends AbstractVisitorTestCase
+{
+ public function xmlProvider()
+ {
+ return array(
+ array(
+ array(
+ 'data' => array(
+ 'xmlRoot' => array(
+ 'name' => 'test',
+ 'namespaces' => 'http://foo.com'
+ )
+ ),
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
+ 'Baz' => array('location' => 'xml', 'type' => 'string')
+ )
+ ),
+ array('Foo' => 'test', 'Baz' => 'bar'),
+ '<test xmlns="http://foo.com"><Foo>test</Foo><Baz>bar</Baz></test>'
+ ),
+ // Ensure that the content-type is not added
+ array(array('parameters' => array('Foo' => array('location' => 'xml', 'type' => 'string'))), array(), ''),
+ // Test with adding attributes and no namespace
+ array(
+ array(
+ 'data' => array(
+ 'xmlRoot' => array(
+ 'name' => 'test'
+ )
+ ),
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string', 'data' => array('xmlAttribute' => true))
+ )
+ ),
+ array('Foo' => 'test', 'Baz' => 'bar'),
+ '<test Foo="test"/>'
+ ),
+ // Test adding with an array
+ array(
+ array(
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
+ 'Baz' => array(
+ 'type' => 'array',
+ 'location' => 'xml',
+ 'items' => array(
+ 'type' => 'numeric',
+ 'sentAs' => 'Bar'
+ )
+ )
+ )
+ ),
+ array('Foo' => 'test', 'Baz' => array(1, 2)),
+ '<Request><Foo>test</Foo><Baz><Bar>1</Bar><Bar>2</Bar></Baz></Request>'
+ ),
+ // Test adding an object
+ array(
+ array(
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
+ 'Baz' => array(
+ 'type' => 'object',
+ 'location' => 'xml',
+ 'properties' => array(
+ 'Bar' => array('type' => 'string'),
+ 'Bam' => array()
+ )
+ )
+ )
+ ),
+ array('Foo' => 'test', 'Baz' => array('Bar' => 'abc', 'Bam' => 'foo')),
+ '<Request><Foo>test</Foo><Baz><Bar>abc</Bar><Bam>foo</Bam></Baz></Request>'
+ ),
+ // Add an array that contains an object
+ array(
+ array(
+ 'parameters' => array(
+ 'Baz' => array(
+ 'type' => 'array',
+ 'location' => 'xml',
+ 'items' => array(
+ 'type' => 'object',
+ 'sentAs' => 'Bar',
+ 'properties' => array('A' => array(), 'B' => array())
+ )
+ )
+ )
+ ),
+ array('Baz' => array(
+ array('A' => '1', 'B' => '2'),
+ array('A' => '3', 'B' => '4')
+ )),
+ '<Request><Baz><Bar><A>1</A><B>2</B></Bar><Bar><A>3</A><B>4</B></Bar></Baz></Request>'
+ ),
+ // Add an object of attributes
+ array(
+ array(
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
+ 'Baz' => array(
+ 'type' => 'object',
+ 'location' => 'xml',
+ 'properties' => array(
+ 'Bar' => array('type' => 'string', 'data' => array('xmlAttribute' => true)),
+ 'Bam' => array()
+ )
+ )
+ )
+ ),
+ array('Foo' => 'test', 'Baz' => array('Bar' => 'abc', 'Bam' => 'foo')),
+ '<Request><Foo>test</Foo><Baz Bar="abc"><Bam>foo</Bam></Baz></Request>'
+ ),
+ // Check order doesn't matter
+ array(
+ array(
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
+ 'Baz' => array(
+ 'type' => 'object',
+ 'location' => 'xml',
+ 'properties' => array(
+ 'Bar' => array('type' => 'string', 'data' => array('xmlAttribute' => true)),
+ 'Bam' => array()
+ )
+ )
+ )
+ ),
+ array('Foo' => 'test', 'Baz' => array('Bam' => 'foo', 'Bar' => 'abc')),
+ '<Request><Foo>test</Foo><Baz Bar="abc"><Bam>foo</Bam></Baz></Request>'
+ ),
+ // Add values with custom namespaces
+ array(
+ array(
+ 'parameters' => array(
+ 'Foo' => array(
+ 'location' => 'xml',
+ 'type' => 'string',
+ 'data' => array(
+ 'xmlNamespace' => 'http://foo.com'
+ )
+ )
+ )
+ ),
+ array('Foo' => 'test'),
+ '<Request><Foo xmlns="http://foo.com">test</Foo></Request>'
+ ),
+ // Add attributes with custom namespace prefix
+ array(
+ array(
+ 'parameters' => array(
+ 'Wrap' => array(
+ 'type' => 'object',
+ 'location' => 'xml',
+ 'properties' => array(
+ 'Foo' => array(
+ 'type' => 'string',
+ 'sentAs' => 'xsi:baz',
+ 'data' => array(
+ 'xmlNamespace' => 'http://foo.com',
+ 'xmlAttribute' => true
+ )
+ )
+ )
+ ),
+ )
+ ),
+ array('Wrap' => array(
+ 'Foo' => 'test'
+ )),
+ '<Request><Wrap xsi:baz="test" xmlns:xsi="http://foo.com"/></Request>'
+ ),
+ // Add nodes with custom namespace prefix
+ array(
+ array(
+ 'parameters' => array(
+ 'Wrap' => array(
+ 'type' => 'object',
+ 'location' => 'xml',
+ 'properties' => array(
+ 'Foo' => array(
+ 'type' => 'string',
+ 'sentAs' => 'xsi:Foo',
+ 'data' => array(
+ 'xmlNamespace' => 'http://foobar.com'
+ )
+ )
+ )
+ ),
+ )
+ ),
+ array('Wrap' => array(
+ 'Foo' => 'test'
+ )),
+ '<Request><Wrap><xsi:Foo xmlns:xsi="http://foobar.com">test</xsi:Foo></Wrap></Request>'
+ ),
+ array(
+ array(
+ 'parameters' => array(
+ 'Foo' => array(
+ 'location' => 'xml',
+ 'type' => 'string',
+ 'data' => array(
+ 'xmlNamespace' => 'http://foo.com'
+ )
+ )
+ )
+ ),
+ array('Foo' => '<h1>This is a title</h1>'),
+ '<Request><Foo xmlns="http://foo.com"><![CDATA[<h1>This is a title</h1>]]></Foo></Request>'
+ ),
+ // Flat array at top level
+ array(
+ array(
+ 'parameters' => array(
+ 'Bars' => array(
+ 'type' => 'array',
+ 'data' => array('xmlFlattened' => true),
+ 'location' => 'xml',
+ 'items' => array(
+ 'type' => 'object',
+ 'sentAs' => 'Bar',
+ 'properties' => array(
+ 'A' => array(),
+ 'B' => array()
+ )
+ )
+ ),
+ 'Boos' => array(
+ 'type' => 'array',
+ 'data' => array('xmlFlattened' => true),
+ 'location' => 'xml',
+ 'items' => array(
+ 'sentAs' => 'Boo',
+ 'type' => 'string'
+ )
+ )
+ )
+ ),
+ array(
+ 'Bars' => array(
+ array('A' => '1', 'B' => '2'),
+ array('A' => '3', 'B' => '4')
+ ),
+ 'Boos' => array('test', '123')
+ ),
+ '<Request><Bar><A>1</A><B>2</B></Bar><Bar><A>3</A><B>4</B></Bar><Boo>test</Boo><Boo>123</Boo></Request>'
+ ),
+ // Nested flat arrays
+ array(
+ array(
+ 'parameters' => array(
+ 'Delete' => array(
+ 'type' => 'object',
+ 'location' => 'xml',
+ 'properties' => array(
+ 'Items' => array(
+ 'type' => 'array',
+ 'data' => array('xmlFlattened' => true),
+ 'items' => array(
+ 'type' => 'object',
+ 'sentAs' => 'Item',
+ 'properties' => array(
+ 'A' => array(),
+ 'B' => array()
+ )
+ )
+ )
+ )
+ )
+ )
+ ),
+ array(
+ 'Delete' => array(
+ 'Items' => array(
+ array('A' => '1', 'B' => '2'),
+ array('A' => '3', 'B' => '4')
+ )
+ )
+ ),
+ '<Request><Delete><Item><A>1</A><B>2</B></Item><Item><A>3</A><B>4</B></Item></Delete></Request>'
+ )
+ );
+ }
+
+ /**
+ * @dataProvider xmlProvider
+ */
+ public function testSerializesXml(array $operation, array $input, $xml)
+ {
+ $operation = new Operation($operation);
+ $command = $this->getMockBuilder('Guzzle\Service\Command\OperationCommand')
+ ->setConstructorArgs(array($input, $operation))
+ ->getMockForAbstractClass();
+ $command->setClient(new Client('http://www.test.com/some/path.php'));
+ $request = $command->prepare();
+ if (!empty($input)) {
+ $this->assertEquals('application/xml', (string) $request->getHeader('Content-Type'));
+ } else {
+ $this->assertNull($request->getHeader('Content-Type'));
+ }
+ $body = str_replace(array("\n", "<?xml version=\"1.0\"?>"), '', (string) $request->getBody());
+ $this->assertEquals($xml, $body);
+ }
+
+ public function testAddsContentTypeAndTopLevelValues()
+ {
+ $operation = new Operation(array(
+ 'data' => array(
+ 'xmlRoot' => array(
+ 'name' => 'test',
+ 'namespaces' => array(
+ 'xsi' => 'http://foo.com'
+ )
+ )
+ ),
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string'),
+ 'Baz' => array('location' => 'xml', 'type' => 'string')
+ )
+ ));
+
+ $command = $this->getMockBuilder('Guzzle\Service\Command\OperationCommand')
+ ->setConstructorArgs(array(array(
+ 'Foo' => 'test',
+ 'Baz' => 'bar'
+ ), $operation))
+ ->getMockForAbstractClass();
+
+ $command->setClient(new Client());
+ $request = $command->prepare();
+ $this->assertEquals('application/xml', (string) $request->getHeader('Content-Type'));
+ $this->assertEquals(
+ '<?xml version="1.0"?>' . "\n"
+ . '<test xmlns:xsi="http://foo.com"><Foo>test</Foo><Baz>bar</Baz></test>' . "\n",
+ (string) $request->getBody()
+ );
+ }
+
+ public function testCanChangeContentType()
+ {
+ $visitor = new XmlVisitor();
+ $visitor->setContentTypeHeader('application/foo');
+ $this->assertEquals('application/foo', $this->readAttribute($visitor, 'contentType'));
+ }
+
+ public function testCanAddArrayOfSimpleTypes()
+ {
+ $request = new EntityEnclosingRequest('POST', 'http://foo.com');
+ $visitor = new XmlVisitor();
+ $param = new Parameter(array(
+ 'type' => 'object',
+ 'location' => 'xml',
+ 'name' => 'Out',
+ 'properties' => array(
+ 'Nodes' => array(
+ 'required' => true,
+ 'type' => 'array',
+ 'min' => 1,
+ 'items' => array('type' => 'string', 'sentAs' => 'Node')
+ )
+ )
+ ));
+
+ $param->setParent(new Operation(array(
+ 'data' => array(
+ 'xmlRoot' => array(
+ 'name' => 'Test',
+ 'namespaces' => array(
+ 'https://foo/'
+ )
+ )
+ )
+ )));
+
+ $value = array('Nodes' => array('foo', 'baz'));
+ $this->assertTrue($this->validator->validate($param, $value));
+ $visitor->visit($this->command, $request, $param, $value);
+ $visitor->after($this->command, $request);
+
+ $this->assertEquals(
+ "<?xml version=\"1.0\"?>\n"
+ . "<Test xmlns=\"https://foo/\"><Out><Nodes><Node>foo</Node><Node>baz</Node></Nodes></Out></Test>\n",
+ (string) $request->getBody()
+ );
+ }
+
+ public function testCanAddMultipleNamespacesToRoot()
+ {
+ $operation = new Operation(array(
+ 'data' => array(
+ 'xmlRoot' => array(
+ 'name' => 'Hi',
+ 'namespaces' => array(
+ 'xsi' => 'http://foo.com',
+ 'foo' => 'http://foobar.com'
+ )
+ )
+ ),
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml', 'type' => 'string')
+ )
+ ));
+
+ $command = $this->getMockBuilder('Guzzle\Service\Command\OperationCommand')
+ ->setConstructorArgs(array(array(
+ 'Foo' => 'test'
+ ), $operation))
+ ->getMockForAbstractClass();
+
+ $command->setClient(new Client());
+ $request = $command->prepare();
+ $this->assertEquals('application/xml', (string) $request->getHeader('Content-Type'));
+ $this->assertEquals(
+ '<?xml version="1.0"?>' . "\n"
+ . '<Hi xmlns:xsi="http://foo.com" xmlns:foo="http://foobar.com"><Foo>test</Foo></Hi>' . "\n",
+ (string) $request->getBody()
+ );
+ }
+
+ public function testValuesAreFiltered()
+ {
+ $operation = new Operation(array(
+ 'parameters' => array(
+ 'Foo' => array(
+ 'location' => 'xml',
+ 'type' => 'string',
+ 'filters' => array('strtoupper')
+ ),
+ 'Bar' => array(
+ 'location' => 'xml',
+ 'type' => 'object',
+ 'properties' => array(
+ 'Baz' => array(
+ 'filters' => array('strtoupper')
+ )
+ )
+ )
+ )
+ ));
+
+ $command = $this->getMockBuilder('Guzzle\Service\Command\OperationCommand')
+ ->setConstructorArgs(array(array(
+ 'Foo' => 'test',
+ 'Bar' => array(
+ 'Baz' => 'abc'
+ )
+ ), $operation))
+ ->getMockForAbstractClass();
+
+ $command->setClient(new Client());
+ $request = $command->prepare();
+ $this->assertEquals(
+ '<?xml version="1.0"?>' . "\n"
+ . '<Request><Foo>TEST</Foo><Bar><Baz>ABC</Baz></Bar></Request>' . "\n",
+ (string) $request->getBody()
+ );
+ }
+
+ public function testSkipsNullValues()
+ {
+ $operation = new Operation(array(
+ 'parameters' => array(
+ 'Foo' => array(
+ 'location' => 'xml',
+ 'type' => 'string'
+ ),
+ 'Bar' => array(
+ 'location' => 'xml',
+ 'type' => 'object',
+ 'properties' => array(
+ 'Baz' => array(),
+ 'Bam' => array(),
+ )
+ ),
+ 'Arr' => array(
+ 'type' => 'array',
+ 'items' => array(
+ 'type' => 'string'
+ )
+ )
+ )
+ ));
+
+ $command = $this->getMockBuilder('Guzzle\Service\Command\OperationCommand')
+ ->setConstructorArgs(array(array(
+ 'Foo' => null,
+ 'Bar' => array(
+ 'Bar' => null,
+ 'Bam' => 'test'
+ ),
+ 'Arr' => array(null)
+ ), $operation))
+ ->getMockForAbstractClass();
+
+ $command->setClient(new Client());
+ $request = $command->prepare();
+ $this->assertEquals(
+ '<?xml version="1.0"?>' . "\n"
+ . '<Request><Bar><Bam>test</Bam></Bar></Request>' . "\n",
+ (string) $request->getBody()
+ );
+ }
+
+ public function testAllowsXmlEncoding()
+ {
+ $operation = new Operation(array(
+ 'data' => array(
+ 'xmlEncoding' => 'UTF-8'
+ ),
+ 'parameters' => array(
+ 'Foo' => array('location' => 'xml')
+ )
+ ));
+ $command = $this->getMockBuilder('Guzzle\Service\Command\OperationCommand')
+ ->setConstructorArgs(array(array('Foo' => 'test'), $operation))
+ ->getMockForAbstractClass();
+ $command->setClient(new Client());
+ $request = $command->prepare();
+ $this->assertEquals(
+ '<?xml version="1.0" encoding="UTF-8"?>' . "\n"
+ . '<Request><Foo>test</Foo></Request>' . "\n",
+ (string) $request->getBody()
+ );
+ }
+
+ public function testAllowsSendingXmlPayloadIfNoXmlParamsWereSet()
+ {
+ $operation = new Operation(array(
+ 'httpMethod' => 'POST',
+ 'data' => array('xmlAllowEmpty' => true),
+ 'parameters' => array('Foo' => array('location' => 'xml'))
+ ));
+ $command = $this->getMockBuilder('Guzzle\Service\Command\OperationCommand')
+ ->setConstructorArgs(array(array(), $operation))
+ ->getMockForAbstractClass();
+ $command->setClient(new Client('http://foo.com'));
+ $request = $command->prepare();
+ $this->assertEquals(
+ '<?xml version="1.0"?>' . "\n"
+ . '<Request/>' . "\n",
+ (string) $request->getBody()
+ );
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/AbstractResponseVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/AbstractResponseVisitorTest.php
new file mode 100644
index 0000000..7b86003
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/AbstractResponseVisitorTest.php
@@ -0,0 +1,29 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Response;
+
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+use Guzzle\Http\Message\Response;
+
+abstract class AbstractResponseVisitorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var Response */
+ protected $response;
+
+ /** @var MockCommand */
+ protected $command;
+
+ /** @var array */
+ protected $value;
+
+ public function setUp()
+ {
+ $this->value = array();
+ $this->command = new MockCommand();
+ $this->response = new Response(200, array(
+ 'X-Foo' => 'bar',
+ 'Content-Length' => 3,
+ 'Content-Type' => 'text/plain'
+ ), 'Foo');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/BodyVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/BodyVisitorTest.php
new file mode 100644
index 0000000..932e39b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/BodyVisitorTest.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Response;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Command\LocationVisitor\Response\BodyVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Response\BodyVisitor
+ */
+class BodyVisitorTest extends AbstractResponseVisitorTest
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array('location' => 'body', 'name' => 'foo'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals('Foo', (string) $this->value['foo']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/HeaderVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/HeaderVisitorTest.php
new file mode 100644
index 0000000..db54b1a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/HeaderVisitorTest.php
@@ -0,0 +1,98 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Response;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Command\LocationVisitor\Response\HeaderVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Response\HeaderVisitor
+ */
+class HeaderVisitorTest extends AbstractResponseVisitorTest
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'header',
+ 'name' => 'ContentType',
+ 'sentAs' => 'Content-Type'
+ ));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals('text/plain', $this->value['ContentType']);
+ }
+
+ public function testVisitsLocationWithFilters()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'header',
+ 'name' => 'Content-Type',
+ 'filters' => array('strtoupper')
+ ));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals('TEXT/PLAIN', $this->value['Content-Type']);
+ }
+
+ public function testVisitsMappedPrefixHeaders()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'header',
+ 'name' => 'Metadata',
+ 'sentAs' => 'X-Baz-',
+ 'type' => 'object',
+ 'additionalProperties' => array(
+ 'type' => 'string'
+ )
+ ));
+ $response = new Response(200, array(
+ 'X-Baz-Test' => 'ABC',
+ 'X-Baz-Bar' => array('123', '456'),
+ 'Content-Length' => 3
+ ), 'Foo');
+ $visitor->visit($this->command, $response, $param, $this->value);
+ $this->assertEquals(array(
+ 'Metadata' => array(
+ 'Test' => 'ABC',
+ 'Bar' => array('123', '456')
+ )
+ ), $this->value);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/399
+ */
+ public function testDiscardingUnknownHeaders()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'header',
+ 'name' => 'Content-Type',
+ 'additionalParameters' => false
+ ));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals('text/plain', $this->value['Content-Type']);
+ $this->assertArrayNotHasKey('X-Foo', $this->value);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/399
+ */
+ public function testDiscardingUnknownPropertiesWithAliasing()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'header',
+ 'name' => 'ContentType',
+ 'sentAs' => 'Content-Type',
+ 'additionalParameters' => false
+ ));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals('text/plain', $this->value['ContentType']);
+ $this->assertArrayNotHasKey('X-Foo', $this->value);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/JsonVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/JsonVisitorTest.php
new file mode 100644
index 0000000..4f8d30b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/JsonVisitorTest.php
@@ -0,0 +1,157 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Response;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor
+ */
+class JsonVisitorTest extends AbstractResponseVisitorTest
+{
+ public function testBeforeMethodParsesXml()
+ {
+ $visitor = new Visitor();
+ $command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')
+ ->setMethods(array('getResponse'))
+ ->getMockForAbstractClass();
+ $command->expects($this->once())
+ ->method('getResponse')
+ ->will($this->returnValue(new Response(200, null, '{"foo":"bar"}')));
+ $result = array();
+ $visitor->before($command, $result);
+ $this->assertEquals(array('foo' => 'bar'), $result);
+ }
+
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'array',
+ 'items' => array(
+ 'filters' => 'strtoupper',
+ 'type' => 'string'
+ )
+ ));
+ $this->value = array('foo' => array('a', 'b', 'c'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('A', 'B', 'C'), $this->value['foo']);
+ }
+
+ public function testRenamesTopLevelValues()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'sentAs' => 'Baz',
+ 'type' => 'string',
+ ));
+ $this->value = array('Baz' => 'test');
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('foo' => 'test'), $this->value);
+ }
+
+ public function testRenamesDoesNotFailForNonExistentKey()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'properties' => array(
+ 'bar' => array(
+ 'name' => 'bar',
+ 'sentAs' => 'baz',
+ ),
+ ),
+ ));
+ $this->value = array('foo' => array('unknown' => 'Unknown'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('foo' => array('unknown' => 'Unknown')), $this->value);
+ }
+
+ public function testTraversesObjectsAndAppliesFilters()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'properties' => array(
+ 'foo' => array('filters' => 'strtoupper'),
+ 'bar' => array('filters' => 'strtolower')
+ )
+ ));
+ $this->value = array('foo' => array('foo' => 'hello', 'bar' => 'THERE'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('foo' => 'HELLO', 'bar' => 'there'), $this->value['foo']);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/399
+ */
+ public function testDiscardingUnknownProperties()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'additionalProperties' => false,
+ 'properties' => array(
+ 'bar' => array(
+ 'type' => 'string',
+ 'name' => 'bar',
+ ),
+ ),
+ ));
+ $this->value = array('foo' => array('bar' => 15, 'unknown' => 'Unknown'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('foo' => array('bar' => 15)), $this->value);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/399
+ */
+ public function testDiscardingUnknownPropertiesWithAliasing()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'additionalProperties' => false,
+ 'properties' => array(
+ 'bar' => array(
+ 'name' => 'bar',
+ 'sentAs' => 'baz',
+ ),
+ ),
+ ));
+ $this->value = array('foo' => array('baz' => 15, 'unknown' => 'Unknown'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('foo' => array('bar' => 15)), $this->value);
+ }
+
+ public function testWalksAdditionalProperties()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'additionalProperties' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'bar' => array(
+ 'type' => 'string',
+ 'filters' => array('base64_decode')
+ )
+ ),
+ ),
+ ));
+ $this->value = array('foo' => array('baz' => array('bar' => 'Zm9v')));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals('foo', $this->value['foo']['baz']['bar']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/ReasonPhraseVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/ReasonPhraseVisitorTest.php
new file mode 100644
index 0000000..23cd40f
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/ReasonPhraseVisitorTest.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Response;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Command\LocationVisitor\Response\ReasonPhraseVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Response\ReasonPhraseVisitor
+ */
+class ReasonPhraseVisitorTest extends AbstractResponseVisitorTest
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array('location' => 'reasonPhrase', 'name' => 'phrase'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals('OK', $this->value['phrase']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/StatusCodeVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/StatusCodeVisitorTest.php
new file mode 100644
index 0000000..7211a58
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/StatusCodeVisitorTest.php
@@ -0,0 +1,21 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Response;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Command\LocationVisitor\Response\StatusCodeVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Response\StatusCodeVisitor
+ */
+class StatusCodeVisitorTest extends AbstractResponseVisitorTest
+{
+ public function testVisitsLocation()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array('location' => 'statusCode', 'name' => 'code'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(200, $this->value['code']);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/XmlVisitorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/XmlVisitorTest.php
new file mode 100644
index 0000000..f87cec7
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/Response/XmlVisitorTest.php
@@ -0,0 +1,431 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command\LocationVisitor\Response;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Command\LocationVisitor\Response\XmlVisitor as Visitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\Response\XmlVisitor
+ */
+class XmlVisitorTest extends AbstractResponseVisitorTest
+{
+ public function testBeforeMethodParsesXml()
+ {
+ $visitor = new Visitor();
+ $command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')
+ ->setMethods(array('getResponse'))
+ ->getMockForAbstractClass();
+ $command->expects($this->once())
+ ->method('getResponse')
+ ->will($this->returnValue(new Response(200, null, '<foo><Bar>test</Bar></foo>')));
+ $result = array();
+ $visitor->before($command, $result);
+ $this->assertEquals(array('Bar' => 'test'), $result);
+ }
+
+ public function testBeforeMethodParsesXmlWithNamespace()
+ {
+ $this->markTestSkipped("Response/XmlVisitor cannot accept 'xmlns' in response, see #368 (http://git.io/USa1mA).");
+
+ $visitor = new Visitor();
+ $command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')
+ ->setMethods(array('getResponse'))
+ ->getMockForAbstractClass();
+ $command->expects($this->once())
+ ->method('getResponse')
+ ->will($this->returnValue(new Response(200, null, '<foo xmlns="urn:foo"><bar:Bar xmlns:bar="urn:bar">test</bar:Bar></foo>')));
+ $result = array();
+ $visitor->before($command, $result);
+ $this->assertEquals(array('Bar' => 'test'), $result);
+ }
+
+ public function testBeforeMethodParsesNestedXml()
+ {
+ $visitor = new Visitor();
+ $command = $this->getMockBuilder('Guzzle\Service\Command\AbstractCommand')
+ ->setMethods(array('getResponse'))
+ ->getMockForAbstractClass();
+ $command->expects($this->once())
+ ->method('getResponse')
+ ->will($this->returnValue(new Response(200, null, '<foo><Items><Bar>test</Bar></Items></foo>')));
+ $result = array();
+ $visitor->before($command, $result);
+ $this->assertEquals(array('Items' => array('Bar' => 'test')), $result);
+ }
+
+ public function testCanExtractAndRenameTopLevelXmlValues()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'xml',
+ 'name' => 'foo',
+ 'sentAs' => 'Bar'
+ ));
+ $value = array('Bar' => 'test');
+ $visitor->visit($this->command, $this->response, $param, $value);
+ $this->assertArrayHasKey('foo', $value);
+ $this->assertEquals('test', $value['foo']);
+ }
+
+ public function testEnsuresRepeatedArraysAreInCorrectLocations()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'xml',
+ 'name' => 'foo',
+ 'sentAs' => 'Foo',
+ 'type' => 'array',
+ 'items' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'Bar' => array('type' => 'string'),
+ 'Baz' => array('type' => 'string'),
+ 'Bam' => array('type' => 'string')
+ )
+ )
+ ));
+
+ $xml = new \SimpleXMLElement('<Test><Foo><Bar>1</Bar><Baz>2</Baz></Foo></Test>');
+ $value = json_decode(json_encode($xml), true);
+ $visitor->visit($this->command, $this->response, $param, $value);
+ $this->assertEquals(array(
+ 'foo' => array(
+ array (
+ 'Bar' => '1',
+ 'Baz' => '2'
+ )
+ )
+ ), $value);
+ }
+
+ public function testEnsuresFlatArraysAreFlat()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'location' => 'xml',
+ 'name' => 'foo',
+ 'type' => 'array',
+ 'items' => array('type' => 'string')
+ ));
+
+ $value = array('foo' => array('bar', 'baz'));
+ $visitor->visit($this->command, $this->response, $param, $value);
+ $this->assertEquals(array('foo' => array('bar', 'baz')), $value);
+
+ $value = array('foo' => 'bar');
+ $visitor->visit($this->command, $this->response, $param, $value);
+ $this->assertEquals(array('foo' => array('bar')), $value);
+ }
+
+ public function xmlDataProvider()
+ {
+ $param = new Parameter(array(
+ 'location' => 'xml',
+ 'name' => 'Items',
+ 'type' => 'array',
+ 'items' => array(
+ 'type' => 'object',
+ 'name' => 'Item',
+ 'properties' => array(
+ 'Bar' => array('type' => 'string'),
+ 'Baz' => array('type' => 'string')
+ )
+ )
+ ));
+
+ return array(
+ array($param, '<Test><Items><Item><Bar>1</Bar></Item><Item><Bar>2</Bar></Item></Items></Test>', array(
+ 'Items' => array(
+ array('Bar' => 1),
+ array('Bar' => 2)
+ )
+ )),
+ array($param, '<Test><Items><Item><Bar>1</Bar></Item></Items></Test>', array(
+ 'Items' => array(
+ array('Bar' => 1)
+ )
+ )),
+ array($param, '<Test><Items /></Test>', array(
+ 'Items' => array()
+ ))
+ );
+ }
+
+ /**
+ * @dataProvider xmlDataProvider
+ */
+ public function testEnsuresWrappedArraysAreInCorrectLocations($param, $xml, $result)
+ {
+ $visitor = new Visitor();
+ $xml = new \SimpleXMLElement($xml);
+ $value = json_decode(json_encode($xml), true);
+ $visitor->visit($this->command, $this->response, $param, $value);
+ $this->assertEquals($result, $value);
+ }
+
+ public function testCanRenameValues()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'TerminatingInstances',
+ 'type' => 'array',
+ 'location' => 'xml',
+ 'sentAs' => 'instancesSet',
+ 'items' => array(
+ 'name' => 'item',
+ 'type' => 'object',
+ 'sentAs' => 'item',
+ 'properties' => array(
+ 'InstanceId' => array(
+ 'type' => 'string',
+ 'sentAs' => 'instanceId',
+ ),
+ 'CurrentState' => array(
+ 'type' => 'object',
+ 'sentAs' => 'currentState',
+ 'properties' => array(
+ 'Code' => array(
+ 'type' => 'numeric',
+ 'sentAs' => 'code',
+ ),
+ 'Name' => array(
+ 'type' => 'string',
+ 'sentAs' => 'name',
+ ),
+ ),
+ ),
+ 'PreviousState' => array(
+ 'type' => 'object',
+ 'sentAs' => 'previousState',
+ 'properties' => array(
+ 'Code' => array(
+ 'type' => 'numeric',
+ 'sentAs' => 'code',
+ ),
+ 'Name' => array(
+ 'type' => 'string',
+ 'sentAs' => 'name',
+ ),
+ ),
+ ),
+ ),
+ )
+ ));
+
+ $value = array(
+ 'instancesSet' => array (
+ 'item' => array (
+ 'instanceId' => 'i-3ea74257',
+ 'currentState' => array(
+ 'code' => '32',
+ 'name' => 'shutting-down',
+ ),
+ 'previousState' => array(
+ 'code' => '16',
+ 'name' => 'running',
+ ),
+ ),
+ )
+ );
+
+ $visitor->visit($this->command, $this->response, $param, $value);
+
+ $this->assertEquals(array(
+ 'TerminatingInstances' => array(
+ array(
+ 'InstanceId' => 'i-3ea74257',
+ 'CurrentState' => array(
+ 'Code' => '32',
+ 'Name' => 'shutting-down',
+ ),
+ 'PreviousState' => array(
+ 'Code' => '16',
+ 'Name' => 'running',
+ )
+ )
+ )
+ ), $value);
+ }
+
+ public function testCanRenameAttributes()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'RunningQueues',
+ 'type' => 'array',
+ 'location' => 'xml',
+ 'items' => array(
+ 'type' => 'object',
+ 'sentAs' => 'item',
+ 'properties' => array(
+ 'QueueId' => array(
+ 'type' => 'string',
+ 'sentAs' => 'queue_id',
+ 'data' => array(
+ 'xmlAttribute' => true,
+ ),
+ ),
+ 'CurrentState' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'Code' => array(
+ 'type' => 'numeric',
+ 'sentAs' => 'code',
+ 'data' => array(
+ 'xmlAttribute' => true,
+ ),
+ ),
+ 'Name' => array(
+ 'sentAs' => 'name',
+ 'data' => array(
+ 'xmlAttribute' => true,
+ ),
+ ),
+ ),
+ ),
+ 'PreviousState' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'Code' => array(
+ 'type' => 'numeric',
+ 'sentAs' => 'code',
+ 'data' => array(
+ 'xmlAttribute' => true,
+ ),
+ ),
+ 'Name' => array(
+ 'sentAs' => 'name',
+ 'data' => array(
+ 'xmlAttribute' => true,
+ ),
+ ),
+ ),
+ ),
+ ),
+ )
+ ));
+
+ $xml = '<wrap><RunningQueues><item queue_id="q-3ea74257"><CurrentState code="32" name="processing" /><PreviousState code="16" name="wait" /></item></RunningQueues></wrap>';
+ $value = json_decode(json_encode(new \SimpleXMLElement($xml)), true);
+ $visitor->visit($this->command, $this->response, $param, $value);
+
+ $this->assertEquals(array(
+ 'RunningQueues' => array(
+ array(
+ 'QueueId' => 'q-3ea74257',
+ 'CurrentState' => array(
+ 'Code' => '32',
+ 'Name' => 'processing',
+ ),
+ 'PreviousState' => array(
+ 'Code' => '16',
+ 'Name' => 'wait',
+ ),
+ ),
+ )
+ ), $value);
+ }
+
+ public function testAddsEmptyArraysWhenValueIsMissing()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'Foo',
+ 'type' => 'array',
+ 'location' => 'xml',
+ 'items' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'Baz' => array('type' => 'array'),
+ 'Bar' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'Baz' => array('type' => 'array'),
+ )
+ )
+ )
+ )
+ ));
+
+ $value = array();
+ $visitor->visit($this->command, $this->response, $param, $value);
+
+ $value = array(
+ 'Foo' => array(
+ 'Bar' => array()
+ )
+ );
+ $visitor->visit($this->command, $this->response, $param, $value);
+ $this->assertEquals(array(
+ 'Foo' => array(
+ array(
+ 'Bar' => array()
+ )
+ )
+ ), $value);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/399
+ */
+ public function testDiscardingUnknownProperties()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'additionalProperties' => false,
+ 'properties' => array(
+ 'bar' => array(
+ 'type' => 'string',
+ 'name' => 'bar',
+ ),
+ ),
+ ));
+ $this->value = array('foo' => array('bar' => 15, 'unknown' => 'Unknown'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('foo' => array('bar' => 15)), $this->value);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/399
+ */
+ public function testDiscardingUnknownPropertiesWithAliasing()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'additionalProperties' => false,
+ 'properties' => array(
+ 'bar' => array(
+ 'name' => 'bar',
+ 'sentAs' => 'baz',
+ ),
+ ),
+ ));
+ $this->value = array('foo' => array('baz' => 15, 'unknown' => 'Unknown'));
+ $visitor->visit($this->command, $this->response, $param, $this->value);
+ $this->assertEquals(array('foo' => array('bar' => 15)), $this->value);
+ }
+
+ public function testProperlyHandlesEmptyStringValues()
+ {
+ $visitor = new Visitor();
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'properties' => array(
+ 'bar' => array('type' => 'string')
+ ),
+ ));
+ $xml = '<wrapper><foo><bar /></foo></wrapper>';
+ $value = json_decode(json_encode(new \SimpleXMLElement($xml)), true);
+ $visitor->visit($this->command, $this->response, $param, $value);
+ $this->assertEquals(array('foo' => array('bar' => '')), $value);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/VisitorFlyweightTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/VisitorFlyweightTest.php
new file mode 100644
index 0000000..a252ffe
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/LocationVisitor/VisitorFlyweightTest.php
@@ -0,0 +1,53 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Service\Command\LocationVisitor\VisitorFlyweight;
+use Guzzle\Service\Command\LocationVisitor\Request\JsonVisitor as JsonRequestVisitor;
+use Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor as JsonResponseVisitor;
+
+/**
+ * @covers Guzzle\Service\Command\LocationVisitor\VisitorFlyweight
+ */
+class VisitorFlyweightTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testUsesDefaultMappingsWithGetInstance()
+ {
+ $f = VisitorFlyweight::getInstance();
+ $this->assertInstanceOf('Guzzle\Service\Command\LocationVisitor\Request\JsonVisitor', $f->getRequestVisitor('json'));
+ $this->assertInstanceOf('Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor', $f->getResponseVisitor('json'));
+ }
+
+ public function testCanUseCustomMappings()
+ {
+ $f = new VisitorFlyweight(array());
+ $this->assertEquals(array(), $this->readAttribute($f, 'mappings'));
+ }
+
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage No request visitor has been mapped for foo
+ */
+ public function testThrowsExceptionWhenRetrievingUnknownVisitor()
+ {
+ VisitorFlyweight::getInstance()->getRequestVisitor('foo');
+ }
+
+ public function testCachesVisitors()
+ {
+ $f = new VisitorFlyweight();
+ $v1 = $f->getRequestVisitor('json');
+ $this->assertSame($v1, $f->getRequestVisitor('json'));
+ }
+
+ public function testAllowsAddingVisitors()
+ {
+ $f = new VisitorFlyweight();
+ $j1 = new JsonRequestVisitor();
+ $j2 = new JsonResponseVisitor();
+ $f->addRequestVisitor('json', $j1);
+ $f->addResponseVisitor('json', $j2);
+ $this->assertSame($j1, $f->getRequestVisitor('json'));
+ $this->assertSame($j2, $f->getResponseVisitor('json'));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationCommandTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationCommandTest.php
new file mode 100644
index 0000000..95fb533
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationCommandTest.php
@@ -0,0 +1,102 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Http\Message\EntityEnclosingRequest;
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Client;
+use Guzzle\Service\Command\OperationCommand;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Service\Command\DefaultRequestSerializer;
+use Guzzle\Service\Resource\Model;
+use Guzzle\Service\Command\LocationVisitor\VisitorFlyweight;
+
+/**
+ * @covers Guzzle\Service\Command\OperationCommand
+ */
+class OperationCommandTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testHasRequestSerializer()
+ {
+ $operation = new OperationCommand();
+ $a = $operation->getRequestSerializer();
+ $b = new DefaultRequestSerializer(VisitorFlyweight::getInstance());
+ $operation->setRequestSerializer($b);
+ $this->assertNotSame($a, $operation->getRequestSerializer());
+ }
+
+ public function testPreparesRequestUsingSerializer()
+ {
+ $op = new OperationCommand(array(), new Operation());
+ $op->setClient(new Client());
+ $s = $this->getMockBuilder('Guzzle\Service\Command\RequestSerializerInterface')
+ ->setMethods(array('prepare'))
+ ->getMockForAbstractClass();
+ $s->expects($this->once())
+ ->method('prepare')
+ ->will($this->returnValue(new EntityEnclosingRequest('POST', 'http://foo.com')));
+ $op->setRequestSerializer($s);
+ $op->prepare();
+ }
+
+ public function testParsesResponsesWithResponseParser()
+ {
+ $op = new OperationCommand(array(), new Operation());
+ $p = $this->getMockBuilder('Guzzle\Service\Command\ResponseParserInterface')
+ ->setMethods(array('parse'))
+ ->getMockForAbstractClass();
+ $p->expects($this->once())
+ ->method('parse')
+ ->will($this->returnValue(array('foo' => 'bar')));
+ $op->setResponseParser($p);
+ $op->setClient(new Client());
+ $request = $op->prepare();
+ $request->setResponse(new Response(200), true);
+ $this->assertEquals(array('foo' => 'bar'), $op->execute());
+ }
+
+ public function testParsesResponsesUsingModelParserWhenMatchingModelIsFound()
+ {
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'foo' => array('responseClass' => 'bar', 'responseType' => 'model')
+ ),
+ 'models' => array(
+ 'bar' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'Baz' => array('type' => 'string', 'location' => 'xml')
+ )
+ )
+ )
+ ));
+
+ $op = new OperationCommand(array(), $description->getOperation('foo'));
+ $op->setClient(new Client());
+ $request = $op->prepare();
+ $request->setResponse(new Response(200, array(
+ 'Content-Type' => 'application/xml'
+ ), '<Foo><Baz>Bar</Baz></Foo>'), true);
+ $result = $op->execute();
+ $this->assertEquals(new Model(array('Baz' => 'Bar')), $result);
+ }
+
+ public function testAllowsRawResponses()
+ {
+ $description = new ServiceDescription(array(
+ 'operations' => array('foo' => array('responseClass' => 'bar', 'responseType' => 'model')),
+ 'models' => array('bar' => array())
+ ));
+ $op = new OperationCommand(array(
+ OperationCommand::RESPONSE_PROCESSING => OperationCommand::TYPE_RAW
+ ), $description->getOperation('foo'));
+ $op->setClient(new Client());
+ $request = $op->prepare();
+ $response = new Response(200, array(
+ 'Content-Type' => 'application/xml'
+ ), '<Foo><Baz>Bar</Baz></Foo>');
+ $request->setResponse($response, true);
+ $this->assertSame($response, $op->execute());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationResponseParserTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationResponseParserTest.php
new file mode 100644
index 0000000..69ba1fc
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Command/OperationResponseParserTest.php
@@ -0,0 +1,335 @@
+<?php
+
+namespace Guzzle\Tests\Service\Command;
+
+use Guzzle\Http\Message\Response;
+use Guzzle\Service\Client;
+use Guzzle\Service\Command\OperationResponseParser;
+use Guzzle\Service\Command\OperationCommand;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Service\Command\LocationVisitor\Response\StatusCodeVisitor;
+use Guzzle\Service\Command\LocationVisitor\Response\ReasonPhraseVisitor;
+use Guzzle\Service\Command\LocationVisitor\Response\JsonVisitor;
+use Guzzle\Service\Command\LocationVisitor\Response\BodyVisitor;
+use Guzzle\Service\Command\LocationVisitor\VisitorFlyweight;
+
+/**
+ * @covers Guzzle\Service\Command\OperationResponseParser
+ * @covers Guzzle\Service\Command\CreateResponseClassEvent
+ */
+class OperationResponseParserTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testHasVisitors()
+ {
+ $p = new OperationResponseParser(new VisitorFlyweight(array()));
+ $visitor = new BodyVisitor();
+ $p->addVisitor('foo', $visitor);
+ $this->assertSame($visitor, $this->readAttribute($p, 'factory')->getResponseVisitor('foo'));
+ }
+
+ public function testUsesParentParser()
+ {
+ $p = new OperationResponseParser(new VisitorFlyweight());
+ $operation = new Operation();
+ $operation->setServiceDescription(new ServiceDescription());
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($p)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/xml'), '<F><B>C</B></F>'), true);
+ $this->assertInstanceOf('SimpleXMLElement', $op->execute());
+ }
+
+ public function testVisitsLocations()
+ {
+ $parser = new OperationResponseParser(new VisitorFlyweight(array()));
+ $parser->addVisitor('statusCode', new StatusCodeVisitor());
+ $parser->addVisitor('reasonPhrase', new ReasonPhraseVisitor());
+ $parser->addVisitor('json', new JsonVisitor());
+ $op = new OperationCommand(array(), $this->getDescription()->getOperation('test'));
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(201), true);
+ $result = $op->execute();
+ $this->assertEquals(201, $result['code']);
+ $this->assertEquals('Created', $result['phrase']);
+ }
+
+ public function testVisitsLocationsForJsonResponse()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $operation = $this->getDescription()->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(200, array(
+ 'Content-Type' => 'application/json'
+ ), '{"baz":"bar","enigma":"123"}'), true);
+ $result = $op->execute();
+ $this->assertEquals(array(
+ 'baz' => 'bar',
+ 'enigma' => '123',
+ 'code' => 200,
+ 'phrase' => 'OK'
+ ), $result->toArray());
+ }
+
+ public function testSkipsUnkownModels()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $operation = $this->getDescription()->getOperation('test');
+ $operation->setResponseClass('Baz')->setResponseType('model');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(201), true);
+ $this->assertInstanceOf('Guzzle\Http\Message\Response', $op->execute());
+ }
+
+ public function testAllowsModelProcessingToBeDisabled()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $operation = $this->getDescription()->getOperation('test');
+ $op = new OperationCommand(array('command.response_processing' => 'native'), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(200, array(
+ 'Content-Type' => 'application/json'
+ ), '{"baz":"bar","enigma":"123"}'), true);
+ $result = $op->execute();
+ $this->assertInstanceOf('Guzzle\Service\Resource\Model', $result);
+ $this->assertEquals(array(
+ 'baz' => 'bar',
+ 'enigma' => '123'
+ ), $result->toArray());
+ }
+
+ public function testCanInjectModelSchemaIntoModels()
+ {
+ $parser = new OperationResponseParser(VisitorFlyweight::getInstance(), true);
+ $desc = $this->getDescription();
+ $operation = $desc->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(200, array(
+ 'Content-Type' => 'application/json'
+ ), '{"baz":"bar","enigma":"123"}'), true);
+ $result = $op->execute();
+ $this->assertSame($result->getStructure(), $desc->getModel('Foo'));
+ }
+
+ public function testDoesNotParseXmlWhenNotUsingXmlVisitor()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $description = ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'Foo')),
+ 'models' => array(
+ 'Foo' => array(
+ 'type' => 'object',
+ 'properties' => array('baz' => array('location' => 'body'))
+ )
+ )
+ ));
+ $operation = $description->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $brokenXml = '<broken><><><<xml>>>>>';
+ $op->prepare()->setResponse(new Response(200, array(
+ 'Content-Type' => 'application/xml'
+ ), $brokenXml), true);
+ $result = $op->execute();
+ $this->assertEquals(array('baz'), $result->getKeys());
+ $this->assertEquals($brokenXml, (string) $result['baz']);
+ }
+
+ public function testVisitsAdditionalProperties()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $description = ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'Foo')),
+ 'models' => array(
+ 'Foo' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'code' => array('location' => 'statusCode')
+ ),
+ 'additionalProperties' => array(
+ 'location' => 'json',
+ 'type' => 'object',
+ 'properties' => array(
+ 'a' => array(
+ 'type' => 'string',
+ 'filters' => 'strtoupper'
+ )
+ )
+ )
+ )
+ )
+ ));
+
+ $operation = $description->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $json = '[{"a":"test"},{"a":"baz"}]';
+ $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), $json), true);
+ $result = $op->execute()->toArray();
+ $this->assertEquals(array(
+ 'code' => 200,
+ array('a' => 'TEST'),
+ array('a' => 'BAZ')
+ ), $result);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/399
+ */
+ public function testAdditionalPropertiesDisabledDiscardsData()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $description = ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'Foo')),
+ 'models' => array(
+ 'Foo' => array(
+ 'type' => 'object',
+ 'additionalProperties' => false,
+ 'properties' => array(
+ 'name' => array(
+ 'location' => 'json',
+ 'type' => 'string',
+ ),
+ 'nested' => array(
+ 'location' => 'json',
+ 'type' => 'object',
+ 'additionalProperties' => false,
+ 'properties' => array(
+ 'width' => array(
+ 'type' => 'integer'
+ )
+ ),
+ ),
+ 'code' => array('location' => 'statusCode')
+ ),
+
+ )
+ )
+ ));
+
+ $operation = $description->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $json = '{"name":"test", "volume":2.0, "nested":{"width":10,"bogus":1}}';
+ $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), $json), true);
+ $result = $op->execute()->toArray();
+ $this->assertEquals(array(
+ 'name' => 'test',
+ 'nested' => array(
+ 'width' => 10,
+ ),
+ 'code' => 200
+ ), $result);
+ }
+
+ public function testCreatesCustomResponseClassInterface()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $description = ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'Guzzle\Tests\Mock\CustomResponseModel'))
+ ));
+ $operation = $description->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), 'hi!'), true);
+ $result = $op->execute();
+ $this->assertInstanceOf('Guzzle\Tests\Mock\CustomResponseModel', $result);
+ $this->assertSame($op, $result->command);
+ }
+
+ /**
+ * @expectedException \Guzzle\Service\Exception\ResponseClassException
+ * @expectedExceptionMessage must exist
+ */
+ public function testEnsuresResponseClassExists()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $description = ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'Foo\Baz\Bar'))
+ ));
+ $operation = $description->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), 'hi!'), true);
+ $op->execute();
+ }
+
+ /**
+ * @expectedException \Guzzle\Service\Exception\ResponseClassException
+ * @expectedExceptionMessage and implement
+ */
+ public function testEnsuresResponseClassImplementsResponseClassInterface()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $description = ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => __CLASS__))
+ ));
+ $operation = $description->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), 'hi!'), true);
+ $op->execute();
+ }
+
+ protected function getDescription()
+ {
+ return ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'Foo')),
+ 'models' => array(
+ 'Foo' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'baz' => array('type' => 'string', 'location' => 'json'),
+ 'code' => array('location' => 'statusCode'),
+ 'phrase' => array('location' => 'reasonPhrase'),
+ )
+ )
+ )
+ ));
+ }
+
+ public function testCanAddListenerToParseDomainObjects()
+ {
+ $client = new Client();
+ $client->setDescription(ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'FooBazBar'))
+ )));
+ $foo = new \stdClass();
+ $client->getEventDispatcher()->addListener('command.parse_response', function ($e) use ($foo) {
+ $e['result'] = $foo;
+ });
+ $command = $client->getCommand('test');
+ $command->prepare()->setResponse(new Response(200), true);
+ $result = $command->execute();
+ $this->assertSame($result, $foo);
+ }
+
+ /**
+ * @group issue-399
+ * @link https://github.com/guzzle/guzzle/issues/501
+ */
+ public function testAdditionalPropertiesWithRefAreResolved()
+ {
+ $parser = OperationResponseParser::getInstance();
+ $description = ServiceDescription::factory(array(
+ 'operations' => array('test' => array('responseClass' => 'Foo')),
+ 'models' => array(
+ 'Baz' => array('type' => 'string'),
+ 'Foo' => array(
+ 'type' => 'object',
+ 'additionalProperties' => array('$ref' => 'Baz', 'location' => 'json')
+ )
+ )
+ ));
+ $operation = $description->getOperation('test');
+ $op = new OperationCommand(array(), $operation);
+ $op->setResponseParser($parser)->setClient(new Client());
+ $json = '{"a":"a","b":"b","c":"c"}';
+ $op->prepare()->setResponse(new Response(200, array('Content-Type' => 'application/json'), $json), true);
+ $result = $op->execute()->toArray();
+ $this->assertEquals(array('a' => 'a', 'b' => 'b', 'c' => 'c'), $result);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/OperationTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/OperationTest.php
new file mode 100644
index 0000000..ae33b69
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/OperationTest.php
@@ -0,0 +1,308 @@
+<?php
+
+namespace Guzzle\Tests\Service\Description;
+
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Description\ServiceDescription;
+
+/**
+ * @covers Guzzle\Service\Description\Operation
+ */
+class OperationTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public static function strtoupper($string)
+ {
+ return strtoupper($string);
+ }
+
+ public function testOperationIsDataObject()
+ {
+ $c = new Operation(array(
+ 'name' => 'test',
+ 'summary' => 'doc',
+ 'notes' => 'notes',
+ 'documentationUrl' => 'http://www.example.com',
+ 'httpMethod' => 'POST',
+ 'uri' => '/api/v1',
+ 'responseClass' => 'array',
+ 'responseNotes' => 'returns the json_decoded response',
+ 'deprecated' => true,
+ 'parameters' => array(
+ 'key' => array(
+ 'required' => true,
+ 'type' => 'string',
+ 'maxLength' => 10
+ ),
+ 'key_2' => array(
+ 'required' => true,
+ 'type' => 'integer',
+ 'default' => 10
+ )
+ )
+ ));
+
+ $this->assertEquals('test', $c->getName());
+ $this->assertEquals('doc', $c->getSummary());
+ $this->assertEquals('http://www.example.com', $c->getDocumentationUrl());
+ $this->assertEquals('POST', $c->getHttpMethod());
+ $this->assertEquals('/api/v1', $c->getUri());
+ $this->assertEquals('array', $c->getResponseClass());
+ $this->assertEquals('returns the json_decoded response', $c->getResponseNotes());
+ $this->assertTrue($c->getDeprecated());
+ $this->assertEquals('Guzzle\\Service\\Command\\OperationCommand', $c->getClass());
+ $this->assertEquals(array(
+ 'key' => new Parameter(array(
+ 'name' => 'key',
+ 'required' => true,
+ 'type' => 'string',
+ 'maxLength' => 10,
+ 'parent' => $c
+ )),
+ 'key_2' => new Parameter(array(
+ 'name' => 'key_2',
+ 'required' => true,
+ 'type' => 'integer',
+ 'default' => 10,
+ 'parent' => $c
+ ))
+ ), $c->getParams());
+
+ $this->assertEquals(new Parameter(array(
+ 'name' => 'key_2',
+ 'required' => true,
+ 'type' => 'integer',
+ 'default' => 10,
+ 'parent' => $c
+ )), $c->getParam('key_2'));
+
+ $this->assertNull($c->getParam('afefwef'));
+ $this->assertArrayNotHasKey('parent', $c->getParam('key_2')->toArray());
+ }
+
+ public function testAllowsConcreteCommands()
+ {
+ $c = new Operation(array(
+ 'name' => 'test',
+ 'class' => 'Guzzle\\Service\\Command\ClosureCommand',
+ 'parameters' => array(
+ 'p' => new Parameter(array(
+ 'name' => 'foo'
+ ))
+ )
+ ));
+ $this->assertEquals('Guzzle\\Service\\Command\ClosureCommand', $c->getClass());
+ }
+
+ public function testConvertsToArray()
+ {
+ $data = array(
+ 'name' => 'test',
+ 'class' => 'Guzzle\\Service\\Command\ClosureCommand',
+ 'summary' => 'test',
+ 'documentationUrl' => 'http://www.example.com',
+ 'httpMethod' => 'PUT',
+ 'uri' => '/',
+ 'parameters' => array('p' => array('name' => 'foo'))
+ );
+ $c = new Operation($data);
+ $toArray = $c->toArray();
+ unset($data['name']);
+ $this->assertArrayHasKey('parameters', $toArray);
+ $this->assertInternalType('array', $toArray['parameters']);
+
+ // Normalize the array
+ unset($data['parameters']);
+ unset($toArray['parameters']);
+
+ $data['responseType'] = 'primitive';
+ $data['responseClass'] = 'array';
+ $this->assertEquals($data, $toArray);
+ }
+
+ public function testDeterminesIfHasParam()
+ {
+ $command = $this->getTestCommand();
+ $this->assertTrue($command->hasParam('data'));
+ $this->assertFalse($command->hasParam('baz'));
+ }
+
+ public function testReturnsParamNames()
+ {
+ $command = $this->getTestCommand();
+ $this->assertEquals(array('data'), $command->getParamNames());
+ }
+
+ protected function getTestCommand()
+ {
+ return new Operation(array(
+ 'parameters' => array(
+ 'data' => new Parameter(array(
+ 'type' => 'string'
+ ))
+ )
+ ));
+ }
+
+ public function testCanBuildUpCommands()
+ {
+ $c = new Operation(array());
+ $c->setName('foo')
+ ->setClass('Baz')
+ ->setDeprecated(false)
+ ->setSummary('summary')
+ ->setDocumentationUrl('http://www.foo.com')
+ ->setHttpMethod('PUT')
+ ->setResponseNotes('oh')
+ ->setResponseClass('string')
+ ->setUri('/foo/bar')
+ ->addParam(new Parameter(array(
+ 'name' => 'test'
+ )));
+
+ $this->assertEquals('foo', $c->getName());
+ $this->assertEquals('Baz', $c->getClass());
+ $this->assertEquals(false, $c->getDeprecated());
+ $this->assertEquals('summary', $c->getSummary());
+ $this->assertEquals('http://www.foo.com', $c->getDocumentationUrl());
+ $this->assertEquals('PUT', $c->getHttpMethod());
+ $this->assertEquals('oh', $c->getResponseNotes());
+ $this->assertEquals('string', $c->getResponseClass());
+ $this->assertEquals('/foo/bar', $c->getUri());
+ $this->assertEquals(array('test'), $c->getParamNames());
+ }
+
+ public function testCanRemoveParams()
+ {
+ $c = new Operation(array());
+ $c->addParam(new Parameter(array('name' => 'foo')));
+ $this->assertTrue($c->hasParam('foo'));
+ $c->removeParam('foo');
+ $this->assertFalse($c->hasParam('foo'));
+ }
+
+ public function testAddsNameToParametersIfNeeded()
+ {
+ $command = new Operation(array('parameters' => array('foo' => new Parameter(array()))));
+ $this->assertEquals('foo', $command->getParam('foo')->getName());
+ }
+
+ public function testContainsApiErrorInformation()
+ {
+ $command = $this->getOperation();
+ $this->assertEquals(1, count($command->getErrorResponses()));
+ $arr = $command->toArray();
+ $this->assertEquals(1, count($arr['errorResponses']));
+ $command->addErrorResponse(400, 'Foo', 'Baz\\Bar');
+ $this->assertEquals(2, count($command->getErrorResponses()));
+ $command->setErrorResponses(array());
+ $this->assertEquals(0, count($command->getErrorResponses()));
+ }
+
+ public function testHasNotes()
+ {
+ $o = new Operation(array('notes' => 'foo'));
+ $this->assertEquals('foo', $o->getNotes());
+ $o->setNotes('bar');
+ $this->assertEquals('bar', $o->getNotes());
+ }
+
+ public function testHasData()
+ {
+ $o = new Operation(array('data' => array('foo' => 'baz', 'bar' => 123)));
+ $o->setData('test', false);
+ $this->assertEquals('baz', $o->getData('foo'));
+ $this->assertEquals(123, $o->getData('bar'));
+ $this->assertNull($o->getData('wfefwe'));
+ $this->assertEquals(array(
+ 'parameters' => array(),
+ 'class' => 'Guzzle\Service\Command\OperationCommand',
+ 'data' => array('foo' => 'baz', 'bar' => 123, 'test' => false),
+ 'responseClass' => 'array',
+ 'responseType' => 'primitive'
+ ), $o->toArray());
+ }
+
+ public function testHasServiceDescription()
+ {
+ $s = new ServiceDescription();
+ $o = new Operation(array(), $s);
+ $this->assertSame($s, $o->getServiceDescription());
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testValidatesResponseType()
+ {
+ $o = new Operation(array('responseClass' => 'array', 'responseType' => 'foo'));
+ }
+
+ public function testInfersResponseType()
+ {
+ $o = $this->getOperation();
+ $o->setServiceDescription(new ServiceDescription(array('models' => array('Foo' => array()))));
+ $this->assertEquals('primitive', $o->getResponseType());
+ $this->assertEquals('primitive', $o->setResponseClass('boolean')->getResponseType());
+ $this->assertEquals('primitive', $o->setResponseClass('array')->getResponseType());
+ $this->assertEquals('primitive', $o->setResponseClass('integer')->getResponseType());
+ $this->assertEquals('primitive', $o->setResponseClass('string')->getResponseType());
+ $this->assertEquals('class', $o->setResponseClass('foo')->getResponseType());
+ $this->assertEquals('class', $o->setResponseClass(__CLASS__)->getResponseType());
+ $this->assertEquals('model', $o->setResponseClass('Foo')->getResponseType());
+ }
+
+ public function testHasResponseType()
+ {
+ // infers in the constructor
+ $o = new Operation(array('responseClass' => 'array'));
+ $this->assertEquals('primitive', $o->getResponseType());
+ // Infers when set
+ $o = new Operation();
+ $this->assertEquals('primitive', $o->getResponseType());
+ $this->assertEquals('model', $o->setResponseType('model')->getResponseType());
+ }
+
+ public function testHasAdditionalParameters()
+ {
+ $o = new Operation(array(
+ 'additionalParameters' => array(
+ 'type' => 'string', 'name' => 'binks'
+ ),
+ 'parameters' => array(
+ 'foo' => array('type' => 'integer')
+ )
+ ));
+ $this->assertEquals('string', $o->getAdditionalParameters()->getType());
+ $arr = $o->toArray();
+ $this->assertEquals(array(
+ 'type' => 'string'
+ ), $arr['additionalParameters']);
+ }
+
+ /**
+ * @return Operation
+ */
+ protected function getOperation()
+ {
+ return new Operation(array(
+ 'name' => 'OperationTest',
+ 'class' => get_class($this),
+ 'parameters' => array(
+ 'test' => array('type' => 'object'),
+ 'bool_1' => array('default' => true, 'type' => 'boolean'),
+ 'bool_2' => array('default' => false),
+ 'float' => array('type' => 'numeric'),
+ 'int' => array('type' => 'integer'),
+ 'date' => array('type' => 'string'),
+ 'timestamp' => array('type' => 'string'),
+ 'string' => array('type' => 'string'),
+ 'username' => array('type' => 'string', 'required' => true, 'filters' => 'strtolower'),
+ 'test_function' => array('type' => 'string', 'filters' => __CLASS__ . '::strtoupper')
+ ),
+ 'errorResponses' => array(
+ array('code' => 503, 'reason' => 'InsufficientCapacity', 'class' => 'Guzzle\\Exception\\RuntimeException')
+ )
+ ));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ParameterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ParameterTest.php
new file mode 100644
index 0000000..b9c162a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ParameterTest.php
@@ -0,0 +1,411 @@
+<?php
+
+namespace Guzzle\Tests\Service\Description;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Description\ServiceDescription;
+
+/**
+ * @covers Guzzle\Service\Description\Parameter
+ */
+class ParameterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $data = array(
+ 'name' => 'foo',
+ 'type' => 'bar',
+ 'required' => true,
+ 'default' => '123',
+ 'description' => '456',
+ 'minLength' => 2,
+ 'maxLength' => 5,
+ 'location' => 'body',
+ 'static' => 'static!',
+ 'filters' => array('trim', 'json_encode')
+ );
+
+ public function testCreatesParamFromArray()
+ {
+ $p = new Parameter($this->data);
+ $this->assertEquals('foo', $p->getName());
+ $this->assertEquals('bar', $p->getType());
+ $this->assertEquals(true, $p->getRequired());
+ $this->assertEquals('123', $p->getDefault());
+ $this->assertEquals('456', $p->getDescription());
+ $this->assertEquals(2, $p->getMinLength());
+ $this->assertEquals(5, $p->getMaxLength());
+ $this->assertEquals('body', $p->getLocation());
+ $this->assertEquals('static!', $p->getStatic());
+ $this->assertEquals(array('trim', 'json_encode'), $p->getFilters());
+ }
+
+ public function testCanConvertToArray()
+ {
+ $p = new Parameter($this->data);
+ unset($this->data['name']);
+ $this->assertEquals($this->data, $p->toArray());
+ }
+
+ public function testUsesStatic()
+ {
+ $d = $this->data;
+ $d['default'] = 'booboo';
+ $d['static'] = true;
+ $p = new Parameter($d);
+ $this->assertEquals('booboo', $p->getValue('bar'));
+ }
+
+ public function testUsesDefault()
+ {
+ $d = $this->data;
+ $d['default'] = 'foo';
+ $d['static'] = null;
+ $p = new Parameter($d);
+ $this->assertEquals('foo', $p->getValue(null));
+ }
+
+ public function testReturnsYourValue()
+ {
+ $d = $this->data;
+ $d['static'] = null;
+ $p = new Parameter($d);
+ $this->assertEquals('foo', $p->getValue('foo'));
+ }
+
+ public function testZeroValueDoesNotCauseDefaultToBeReturned()
+ {
+ $d = $this->data;
+ $d['default'] = '1';
+ $d['static'] = null;
+ $p = new Parameter($d);
+ $this->assertEquals('0', $p->getValue('0'));
+ }
+
+ public function testFiltersValues()
+ {
+ $d = $this->data;
+ $d['static'] = null;
+ $d['filters'] = 'strtoupper';
+ $p = new Parameter($d);
+ $this->assertEquals('FOO', $p->filter('foo'));
+ }
+
+ public function testConvertsBooleans()
+ {
+ $p = new Parameter(array('type' => 'boolean'));
+ $this->assertEquals(true, $p->filter('true'));
+ $this->assertEquals(false, $p->filter('false'));
+ }
+
+ public function testUsesArrayByDefaultForFilters()
+ {
+ $d = $this->data;
+ $d['filters'] = null;
+ $p = new Parameter($d);
+ $this->assertEquals(array(), $p->getFilters());
+ }
+
+ public function testAllowsSimpleLocationValue()
+ {
+ $p = new Parameter(array('name' => 'myname', 'location' => 'foo', 'sentAs' => 'Hello'));
+ $this->assertEquals('foo', $p->getLocation());
+ $this->assertEquals('Hello', $p->getSentAs());
+ }
+
+ public function testParsesTypeValues()
+ {
+ $p = new Parameter(array('type' => 'foo'));
+ $this->assertEquals('foo', $p->getType());
+ }
+
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage A [method] value must be specified for each complex filter
+ */
+ public function testValidatesComplexFilters()
+ {
+ $p = new Parameter(array('filters' => array(array('args' => 'foo'))));
+ }
+
+ public function testCanBuildUpParams()
+ {
+ $p = new Parameter(array());
+ $p->setName('foo')
+ ->setDescription('c')
+ ->setFilters(array('d'))
+ ->setLocation('e')
+ ->setSentAs('f')
+ ->setMaxLength(1)
+ ->setMinLength(1)
+ ->setMinimum(2)
+ ->setMaximum(2)
+ ->setMinItems(3)
+ ->setMaxItems(3)
+ ->setRequired(true)
+ ->setStatic(true)
+ ->setDefault('h')
+ ->setType('i');
+
+ $p->addFilter('foo');
+
+ $this->assertEquals('foo', $p->getName());
+ $this->assertEquals('h', $p->getDefault());
+ $this->assertEquals('c', $p->getDescription());
+ $this->assertEquals(array('d', 'foo'), $p->getFilters());
+ $this->assertEquals('e', $p->getLocation());
+ $this->assertEquals('f', $p->getSentAs());
+ $this->assertEquals(1, $p->getMaxLength());
+ $this->assertEquals(1, $p->getMinLength());
+ $this->assertEquals(2, $p->getMaximum());
+ $this->assertEquals(2, $p->getMinimum());
+ $this->assertEquals(3, $p->getMaxItems());
+ $this->assertEquals(3, $p->getMinItems());
+ $this->assertEquals(true, $p->getRequired());
+ $this->assertEquals(true, $p->getStatic());
+ $this->assertEquals('i', $p->getType());
+ }
+
+ public function testAllowsNestedShape()
+ {
+ $command = $this->getServiceBuilder()->get('mock')->getCommand('mock_command')->getOperation();
+ $param = new Parameter(array(
+ 'parent' => $command,
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'location' => 'query',
+ 'properties' => array(
+ 'foo' => array(
+ 'type' => 'object',
+ 'required' => true,
+ 'properties' => array(
+ 'baz' => array(
+ 'name' => 'baz',
+ 'type' => 'bool',
+ )
+ )
+ ),
+ 'bar' => array(
+ 'name' => 'bar',
+ 'default' => '123'
+ )
+ )
+ ));
+
+ $this->assertSame($command, $param->getParent());
+ $this->assertNotEmpty($param->getProperties());
+ $this->assertInstanceOf('Guzzle\Service\Description\Parameter', $param->getProperty('foo'));
+ $this->assertSame($param, $param->getProperty('foo')->getParent());
+ $this->assertSame($param->getProperty('foo'), $param->getProperty('foo')->getProperty('baz')->getParent());
+ $this->assertInstanceOf('Guzzle\Service\Description\Parameter', $param->getProperty('bar'));
+ $this->assertSame($param, $param->getProperty('bar')->getParent());
+
+ $array = $param->toArray();
+ $this->assertInternalType('array', $array['properties']);
+ $this->assertArrayHasKey('foo', $array['properties']);
+ $this->assertArrayHasKey('bar', $array['properties']);
+ }
+
+ public function testAllowsComplexFilters()
+ {
+ $that = $this;
+ $param = new Parameter(array());
+ $param->setFilters(array(array('method' => function ($a, $b, $c, $d) use ($that, $param) {
+ $that->assertEquals('test', $a);
+ $that->assertEquals('my_value!', $b);
+ $that->assertEquals('bar', $c);
+ $that->assertSame($param, $d);
+ return 'abc' . $b;
+ }, 'args' => array('test', '@value', 'bar', '@api'))));
+ $this->assertEquals('abcmy_value!', $param->filter('my_value!'));
+ }
+
+ public function testCanChangeParentOfNestedParameter()
+ {
+ $param1 = new Parameter(array('name' => 'parent'));
+ $param2 = new Parameter(array('name' => 'child'));
+ $param2->setParent($param1);
+ $this->assertSame($param1, $param2->getParent());
+ }
+
+ public function testCanRemoveFromNestedStructure()
+ {
+ $param1 = new Parameter(array('name' => 'parent'));
+ $param2 = new Parameter(array('name' => 'child'));
+ $param1->addProperty($param2);
+ $this->assertSame($param1, $param2->getParent());
+ $this->assertSame($param2, $param1->getProperty('child'));
+
+ // Remove a single child from the structure
+ $param1->removeProperty('child');
+ $this->assertNull($param1->getProperty('child'));
+ // Remove the entire structure
+ $param1->addProperty($param2);
+ $param1->removeProperty('child');
+ $this->assertNull($param1->getProperty('child'));
+ }
+
+ public function testAddsAdditionalProperties()
+ {
+ $p = new Parameter(array(
+ 'type' => 'object',
+ 'additionalProperties' => array('type' => 'string')
+ ));
+ $this->assertInstanceOf('Guzzle\Service\Description\Parameter', $p->getAdditionalProperties());
+ $this->assertNull($p->getAdditionalProperties()->getAdditionalProperties());
+ $p = new Parameter(array('type' => 'object'));
+ $this->assertTrue($p->getAdditionalProperties());
+ }
+
+ public function testAddsItems()
+ {
+ $p = new Parameter(array(
+ 'type' => 'array',
+ 'items' => array('type' => 'string')
+ ));
+ $this->assertInstanceOf('Guzzle\Service\Description\Parameter', $p->getItems());
+ $out = $p->toArray();
+ $this->assertEquals('array', $out['type']);
+ $this->assertInternalType('array', $out['items']);
+ }
+
+ public function testHasExtraProperties()
+ {
+ $p = new Parameter();
+ $this->assertEquals(array(), $p->getData());
+ $p->setData(array('foo' => 'bar'));
+ $this->assertEquals('bar', $p->getData('foo'));
+ $p->setData('baz', 'boo');
+ $this->assertEquals(array('foo' => 'bar', 'baz' => 'boo'), $p->getData());
+ }
+
+ public function testCanRetrieveKnownPropertiesUsingDataMethod()
+ {
+ $p = new Parameter();
+ $this->assertEquals(null, $p->getData('foo'));
+ $p->setName('test');
+ $this->assertEquals('test', $p->getData('name'));
+ }
+
+ public function testHasInstanceOf()
+ {
+ $p = new Parameter();
+ $this->assertNull($p->getInstanceOf());
+ $p->setInstanceOf('Foo');
+ $this->assertEquals('Foo', $p->getInstanceOf());
+ }
+
+ public function testHasPattern()
+ {
+ $p = new Parameter();
+ $this->assertNull($p->getPattern());
+ $p->setPattern('/[0-9]+/');
+ $this->assertEquals('/[0-9]+/', $p->getPattern());
+ }
+
+ public function testHasEnum()
+ {
+ $p = new Parameter();
+ $this->assertNull($p->getEnum());
+ $p->setEnum(array('foo', 'bar'));
+ $this->assertEquals(array('foo', 'bar'), $p->getEnum());
+ }
+
+ public function testSerializesItems()
+ {
+ $p = new Parameter(array(
+ 'type' => 'object',
+ 'additionalProperties' => array('type' => 'string')
+ ));
+ $this->assertEquals(array(
+ 'type' => 'object',
+ 'additionalProperties' => array('type' => 'string')
+ ), $p->toArray());
+ }
+
+ public function testResolvesRefKeysRecursively()
+ {
+ $description = new ServiceDescription(array(
+ 'models' => array(
+ 'JarJar' => array('type' => 'string', 'default' => 'Mesa address tha senate!'),
+ 'Anakin' => array('type' => 'array', 'items' => array('$ref' => 'JarJar'))
+ )
+ ));
+ $p = new Parameter(array('$ref' => 'Anakin', 'description' => 'added'), $description);
+ $this->assertEquals(array(
+ 'type' => 'array',
+ 'items' => array('type' => 'string', 'default' => 'Mesa address tha senate!'),
+ 'description' => 'added'
+ ), $p->toArray());
+ }
+
+ public function testResolvesExtendsRecursively()
+ {
+ $jarJar = array('type' => 'string', 'default' => 'Mesa address tha senate!', 'description' => 'a');
+ $anakin = array('type' => 'array', 'items' => array('extends' => 'JarJar', 'description' => 'b'));
+ $description = new ServiceDescription(array(
+ 'models' => array('JarJar' => $jarJar, 'Anakin' => $anakin)
+ ));
+ // Description attribute will be updated, and format added
+ $p = new Parameter(array('extends' => 'Anakin', 'format' => 'date'), $description);
+ $this->assertEquals(array(
+ 'type' => 'array',
+ 'format' => 'date',
+ 'items' => array(
+ 'type' => 'string',
+ 'default' => 'Mesa address tha senate!',
+ 'description' => 'b'
+ )
+ ), $p->toArray());
+ }
+
+ public function testHasKeyMethod()
+ {
+ $p = new Parameter(array('name' => 'foo', 'sentAs' => 'bar'));
+ $this->assertEquals('bar', $p->getWireName());
+ $p->setSentAs(null);
+ $this->assertEquals('foo', $p->getWireName());
+ }
+
+ public function testIncludesNameInToArrayWhenItemsAttributeHasName()
+ {
+ $p = new Parameter(array(
+ 'type' => 'array',
+ 'name' => 'Abc',
+ 'items' => array(
+ 'name' => 'Foo',
+ 'type' => 'object'
+ )
+ ));
+ $result = $p->toArray();
+ $this->assertEquals(array(
+ 'type' => 'array',
+ 'items' => array(
+ 'name' => 'Foo',
+ 'type' => 'object',
+ 'additionalProperties' => true
+ )
+ ), $result);
+ }
+
+ public function dateTimeProvider()
+ {
+ $d = 'October 13, 2012 16:15:46 UTC';
+
+ return array(
+ array($d, 'date-time', '2012-10-13T16:15:46Z'),
+ array($d, 'date', '2012-10-13'),
+ array($d, 'timestamp', strtotime($d)),
+ array(new \DateTime($d), 'timestamp', strtotime($d))
+ );
+ }
+
+ /**
+ * @dataProvider dateTimeProvider
+ */
+ public function testAppliesFormat($d, $format, $result)
+ {
+ $p = new Parameter();
+ $p->setFormat($format);
+ $this->assertEquals($format, $p->getFormat());
+ $this->assertEquals($result, $p->filter($d));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaFormatterTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaFormatterTest.php
new file mode 100644
index 0000000..eb3619b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaFormatterTest.php
@@ -0,0 +1,61 @@
+<?php
+
+namespace Guzzle\Tests\Service\Description;
+
+use Guzzle\Service\Description\SchemaFormatter;
+
+/**
+ * @covers Guzzle\Service\Description\SchemaFormatter
+ */
+class SchemaFormatterTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function dateTimeProvider()
+ {
+ $dateUtc = 'October 13, 2012 16:15:46 UTC';
+ $dateOffset = 'October 13, 2012 10:15:46 -06:00';
+ $expectedDateTime = '2012-10-13T16:15:46Z';
+
+ return array(
+ array('foo', 'does-not-exist', 'foo'),
+ array($dateUtc, 'date-time', $expectedDateTime),
+ array($dateUtc, 'date-time-http', 'Sat, 13 Oct 2012 16:15:46 GMT'),
+ array($dateUtc, 'date', '2012-10-13'),
+ array($dateUtc, 'timestamp', strtotime($dateUtc)),
+ array(new \DateTime($dateUtc), 'timestamp', strtotime($dateUtc)),
+ array($dateUtc, 'time', '16:15:46'),
+ array(strtotime($dateUtc), 'time', '16:15:46'),
+ array(strtotime($dateUtc), 'timestamp', strtotime($dateUtc)),
+ array('true', 'boolean-string', 'true'),
+ array(true, 'boolean-string', 'true'),
+ array('false', 'boolean-string', 'false'),
+ array(false, 'boolean-string', 'false'),
+ array('1350144946', 'date-time', $expectedDateTime),
+ array(1350144946, 'date-time', $expectedDateTime),
+ array($dateOffset, 'date-time', $expectedDateTime)
+ );
+ }
+
+ /**
+ * @dataProvider dateTimeProvider
+ */
+ public function testFilters($value, $format, $result)
+ {
+ $this->assertEquals($result, SchemaFormatter::format($format, $value));
+ }
+
+ /**
+ * @expectedException \Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testValidatesDateTimeInput()
+ {
+ SchemaFormatter::format('date-time', false);
+ }
+
+ public function testEnsuresTimestampsAreIntegers()
+ {
+ $t = time();
+ $result = SchemaFormatter::format('timestamp', $t);
+ $this->assertSame($t, $result);
+ $this->assertInternalType('int', $result);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaValidatorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaValidatorTest.php
new file mode 100644
index 0000000..4d6cc87
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/SchemaValidatorTest.php
@@ -0,0 +1,326 @@
+<?php
+
+namespace Guzzle\Tests\Service\Description;
+
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Description\SchemaValidator;
+
+/**
+ * @covers Guzzle\Service\Description\SchemaValidator
+ */
+class SchemaValidatorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var SchemaValidator */
+ protected $validator;
+
+ public function setUp()
+ {
+ $this->validator = new SchemaValidator();
+ }
+
+ public function testValidatesArrayListsAreNumericallyIndexed()
+ {
+ $value = array(array(1));
+ $this->assertFalse($this->validator->validate($this->getComplexParam(), $value));
+ $this->assertEquals(
+ array('[Foo][0] must be an array of properties. Got a numerically indexed array.'),
+ $this->validator->getErrors()
+ );
+ }
+
+ public function testValidatesArrayListsContainProperItems()
+ {
+ $value = array(true);
+ $this->assertFalse($this->validator->validate($this->getComplexParam(), $value));
+ $this->assertEquals(
+ array('[Foo][0] must be of type object'),
+ $this->validator->getErrors()
+ );
+ }
+
+ public function testAddsDefaultValuesInLists()
+ {
+ $value = array(array());
+ $this->assertTrue($this->validator->validate($this->getComplexParam(), $value));
+ $this->assertEquals(array(array('Bar' => true)), $value);
+ }
+
+ public function testMergesDefaultValuesInLists()
+ {
+ $value = array(
+ array('Baz' => 'hello!'),
+ array('Bar' => false)
+ );
+ $this->assertTrue($this->validator->validate($this->getComplexParam(), $value));
+ $this->assertEquals(array(
+ array(
+ 'Baz' => 'hello!',
+ 'Bar' => true
+ ),
+ array('Bar' => false)
+ ), $value);
+ }
+
+ public function testCorrectlyConvertsParametersToArrayWhenArraysArePresent()
+ {
+ $param = $this->getComplexParam();
+ $result = $param->toArray();
+ $this->assertInternalType('array', $result['items']);
+ $this->assertEquals('array', $result['type']);
+ $this->assertInstanceOf('Guzzle\Service\Description\Parameter', $param->getItems());
+ }
+
+ public function testAllowsInstanceOf()
+ {
+ $p = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'instanceOf' => get_class($this)
+ ));
+ $this->assertTrue($this->validator->validate($p, $this));
+ $this->assertFalse($this->validator->validate($p, $p));
+ $this->assertEquals(array('[foo] must be an instance of ' . __CLASS__), $this->validator->getErrors());
+ }
+
+ public function testEnforcesInstanceOfOnlyWhenObject()
+ {
+ $p = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => array('object', 'string'),
+ 'instanceOf' => get_class($this)
+ ));
+ $this->assertTrue($this->validator->validate($p, $this));
+ $s = 'test';
+ $this->assertTrue($this->validator->validate($p, $s));
+ }
+
+ public function testConvertsObjectsToArraysWhenToArrayInterface()
+ {
+ $o = $this->getMockBuilder('Guzzle\Common\ToArrayInterface')
+ ->setMethods(array('toArray'))
+ ->getMockForAbstractClass();
+ $o->expects($this->once())
+ ->method('toArray')
+ ->will($this->returnValue(array(
+ 'foo' => 'bar'
+ )));
+ $p = new Parameter(array(
+ 'name' => 'test',
+ 'type' => 'object',
+ 'properties' => array(
+ 'foo' => array('required' => 'true')
+ )
+ ));
+ $this->assertTrue($this->validator->validate($p, $o));
+ }
+
+ public function testMergesValidationErrorsInPropertiesWithParent()
+ {
+ $p = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'properties' => array(
+ 'bar' => array('type' => 'string', 'required' => true, 'description' => 'This is what it does'),
+ 'test' => array('type' => 'string', 'minLength' => 2, 'maxLength' => 5),
+ 'test2' => array('type' => 'string', 'minLength' => 2, 'maxLength' => 2),
+ 'test3' => array('type' => 'integer', 'minimum' => 100),
+ 'test4' => array('type' => 'integer', 'maximum' => 10),
+ 'test5' => array('type' => 'array', 'maxItems' => 2),
+ 'test6' => array('type' => 'string', 'enum' => array('a', 'bc')),
+ 'test7' => array('type' => 'string', 'pattern' => '/[0-9]+/'),
+ 'test8' => array('type' => 'number'),
+ 'baz' => array(
+ 'type' => 'array',
+ 'minItems' => 2,
+ 'required' => true,
+ "items" => array("type" => "string")
+ )
+ )
+ ));
+
+ $value = array(
+ 'test' => 'a',
+ 'test2' => 'abc',
+ 'baz' => array(false),
+ 'test3' => 10,
+ 'test4' => 100,
+ 'test5' => array(1, 3, 4),
+ 'test6' => 'Foo',
+ 'test7' => 'abc',
+ 'test8' => 'abc'
+ );
+
+ $this->assertFalse($this->validator->validate($p, $value));
+ $this->assertEquals(array (
+ '[foo][bar] is a required string: This is what it does',
+ '[foo][baz] must contain 2 or more elements',
+ '[foo][baz][0] must be of type string',
+ '[foo][test2] length must be less than or equal to 2',
+ '[foo][test3] must be greater than or equal to 100',
+ '[foo][test4] must be less than or equal to 10',
+ '[foo][test5] must contain 2 or fewer elements',
+ '[foo][test6] must be one of "a" or "bc"',
+ '[foo][test7] must match the following regular expression: /[0-9]+/',
+ '[foo][test8] must be of type number',
+ '[foo][test] length must be greater than or equal to 2',
+ ), $this->validator->getErrors());
+ }
+
+ public function testHandlesNullValuesInArraysWithDefaults()
+ {
+ $p = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'required' => true,
+ 'properties' => array(
+ 'bar' => array(
+ 'type' => 'object',
+ 'required' => true,
+ 'properties' => array(
+ 'foo' => array('default' => 'hi')
+ )
+ )
+ )
+ ));
+ $value = array();
+ $this->assertTrue($this->validator->validate($p, $value));
+ $this->assertEquals(array('bar' => array('foo' => 'hi')), $value);
+ }
+
+ public function testFailsWhenNullValuesInArraysWithNoDefaults()
+ {
+ $p = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'required' => true,
+ 'properties' => array(
+ 'bar' => array(
+ 'type' => 'object',
+ 'required' => true,
+ 'properties' => array('foo' => array('type' => 'string'))
+ )
+ )
+ ));
+ $value = array();
+ $this->assertFalse($this->validator->validate($p, $value));
+ $this->assertEquals(array('[foo][bar] is a required object'), $this->validator->getErrors());
+ }
+
+ public function testChecksTypes()
+ {
+ $p = new SchemaValidator();
+ $r = new \ReflectionMethod($p, 'determineType');
+ $r->setAccessible(true);
+ $this->assertEquals('any', $r->invoke($p, 'any', 'hello'));
+ $this->assertEquals(false, $r->invoke($p, 'foo', 'foo'));
+ $this->assertEquals('string', $r->invoke($p, 'string', 'hello'));
+ $this->assertEquals(false, $r->invoke($p, 'string', false));
+ $this->assertEquals('integer', $r->invoke($p, 'integer', 1));
+ $this->assertEquals(false, $r->invoke($p, 'integer', 'abc'));
+ $this->assertEquals('numeric', $r->invoke($p, 'numeric', 1));
+ $this->assertEquals('numeric', $r->invoke($p, 'numeric', '1'));
+ $this->assertEquals('number', $r->invoke($p, 'number', 1));
+ $this->assertEquals('number', $r->invoke($p, 'number', '1'));
+ $this->assertEquals(false, $r->invoke($p, 'numeric', 'a'));
+ $this->assertEquals('boolean', $r->invoke($p, 'boolean', true));
+ $this->assertEquals('boolean', $r->invoke($p, 'boolean', false));
+ $this->assertEquals(false, $r->invoke($p, 'boolean', 'false'));
+ $this->assertEquals('null', $r->invoke($p, 'null', null));
+ $this->assertEquals(false, $r->invoke($p, 'null', 'abc'));
+ $this->assertEquals('array', $r->invoke($p, 'array', array()));
+ $this->assertEquals(false, $r->invoke($p, 'array', 'foo'));
+ }
+
+ public function testValidatesFalseAdditionalProperties()
+ {
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'properties' => array('bar' => array('type' => 'string')),
+ 'additionalProperties' => false
+ ));
+ $value = array('test' => '123');
+ $this->assertFalse($this->validator->validate($param, $value));
+ $this->assertEquals(array('[foo][test] is not an allowed property'), $this->validator->getErrors());
+ $value = array('bar' => '123');
+ $this->assertTrue($this->validator->validate($param, $value));
+ }
+
+ public function testAllowsUndefinedAdditionalProperties()
+ {
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'properties' => array('bar' => array('type' => 'string'))
+ ));
+ $value = array('test' => '123');
+ $this->assertTrue($this->validator->validate($param, $value));
+ }
+
+ public function testValidatesAdditionalProperties()
+ {
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'properties' => array('bar' => array('type' => 'string')),
+ 'additionalProperties' => array('type' => 'integer')
+ ));
+ $value = array('test' => 'foo');
+ $this->assertFalse($this->validator->validate($param, $value));
+ $this->assertEquals(array('[foo][test] must be of type integer'), $this->validator->getErrors());
+ }
+
+ public function testValidatesAdditionalPropertiesThatArrayArrays()
+ {
+ $param = new Parameter(array(
+ 'name' => 'foo',
+ 'type' => 'object',
+ 'additionalProperties' => array(
+ 'type' => 'array',
+ 'items' => array('type' => 'string')
+ )
+ ));
+ $value = array('test' => array(true));
+ $this->assertFalse($this->validator->validate($param, $value));
+ $this->assertEquals(array('[foo][test][0] must be of type string'), $this->validator->getErrors());
+ }
+
+ public function testIntegersCastToStringWhenTypeMismatch()
+ {
+ $param = new Parameter(array('name' => 'test', 'type' => 'string'));
+ $value = 12;
+ $this->assertTrue($this->validator->validate($param, $value));
+ $this->assertEquals('12', $value);
+ }
+
+ public function testRequiredMessageIncludesType()
+ {
+ $param = new Parameter(array('name' => 'test', 'type' => array('string', 'boolean'), 'required' => true));
+ $value = null;
+ $this->assertFalse($this->validator->validate($param, $value));
+ $this->assertEquals(array('[test] is a required string or boolean'), $this->validator->getErrors());
+ }
+
+ protected function getComplexParam()
+ {
+ return new Parameter(array(
+ 'name' => 'Foo',
+ 'type' => 'array',
+ 'required' => true,
+ 'min' => 1,
+ 'items' => array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'Baz' => array(
+ 'type' => 'string',
+ ),
+ 'Bar' => array(
+ 'required' => true,
+ 'type' => 'boolean',
+ 'default' => true
+ )
+ )
+ )
+ ));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionLoaderTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionLoaderTest.php
new file mode 100644
index 0000000..bbfd1d6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionLoaderTest.php
@@ -0,0 +1,177 @@
+<?php
+
+namespace Guzzle\Tests\Service\Description;
+
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Service\Description\ServiceDescriptionLoader;
+
+/**
+ * @covers Guzzle\Service\Description\ServiceDescriptionLoader
+ */
+class ServiceDescriptionLoaderTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testAllowsExtraData()
+ {
+ $d = ServiceDescription::factory(array(
+ 'foo' => true,
+ 'baz' => array('bar'),
+ 'apiVersion' => '123',
+ 'operations' => array()
+ ));
+
+ $this->assertEquals(true, $d->getData('foo'));
+ $this->assertEquals(array('bar'), $d->getData('baz'));
+ $this->assertEquals('123', $d->getApiVersion());
+ }
+
+ public function testAllowsDeepNestedInheritance()
+ {
+ $d = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'abstract' => array(
+ 'httpMethod' => 'HEAD',
+ 'parameters' => array(
+ 'test' => array('type' => 'string', 'required' => true)
+ )
+ ),
+ 'abstract2' => array('uri' => '/test', 'extends' => 'abstract'),
+ 'concrete' => array('extends' => 'abstract2'),
+ 'override' => array('extends' => 'abstract', 'httpMethod' => 'PUT'),
+ 'override2' => array('extends' => 'override', 'httpMethod' => 'POST', 'uri' => '/')
+ )
+ ));
+
+ $c = $d->getOperation('concrete');
+ $this->assertEquals('/test', $c->getUri());
+ $this->assertEquals('HEAD', $c->getHttpMethod());
+ $params = $c->getParams();
+ $param = $params['test'];
+ $this->assertEquals('string', $param->getType());
+ $this->assertTrue($param->getRequired());
+
+ // Ensure that merging HTTP method does not make an array
+ $this->assertEquals('PUT', $d->getOperation('override')->getHttpMethod());
+ $this->assertEquals('POST', $d->getOperation('override2')->getHttpMethod());
+ $this->assertEquals('/', $d->getOperation('override2')->getUri());
+ }
+
+ /**
+ * @expectedException RuntimeException
+ */
+ public function testThrowsExceptionWhenExtendingMissingCommand()
+ {
+ ServiceDescription::factory(array(
+ 'operations' => array(
+ 'concrete' => array(
+ 'extends' => 'missing'
+ )
+ )
+ ));
+ }
+
+ public function testAllowsMultipleInheritance()
+ {
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'a' => array(
+ 'httpMethod' => 'GET',
+ 'parameters' => array(
+ 'a1' => array(
+ 'default' => 'foo',
+ 'required' => true,
+ 'prepend' => 'hi'
+ )
+ )
+ ),
+ 'b' => array(
+ 'extends' => 'a',
+ 'parameters' => array(
+ 'b2' => array()
+ )
+ ),
+ 'c' => array(
+ 'parameters' => array(
+ 'a1' => array(
+ 'default' => 'bar',
+ 'required' => true,
+ 'description' => 'test'
+ ),
+ 'c3' => array()
+ )
+ ),
+ 'd' => array(
+ 'httpMethod' => 'DELETE',
+ 'extends' => array('b', 'c'),
+ 'parameters' => array(
+ 'test' => array()
+ )
+ )
+ )
+ ));
+
+ $command = $description->getOperation('d');
+ $this->assertEquals('DELETE', $command->getHttpMethod());
+ $this->assertContains('a1', $command->getParamNames());
+ $this->assertContains('b2', $command->getParamNames());
+ $this->assertContains('c3', $command->getParamNames());
+ $this->assertContains('test', $command->getParamNames());
+
+ $this->assertTrue($command->getParam('a1')->getRequired());
+ $this->assertEquals('bar', $command->getParam('a1')->getDefault());
+ $this->assertEquals('test', $command->getParam('a1')->getDescription());
+ }
+
+ public function testAddsOtherFields()
+ {
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(),
+ 'description' => 'Foo',
+ 'apiVersion' => 'bar'
+ ));
+ $this->assertEquals('Foo', $description->getDescription());
+ $this->assertEquals('bar', $description->getApiVersion());
+ }
+
+ public function testCanLoadNestedExtends()
+ {
+ $description = ServiceDescription::factory(array(
+ 'operations' => array(
+ 'root' => array(
+ 'class' => 'foo'
+ ),
+ 'foo' => array(
+ 'extends' => 'root',
+ 'parameters' => array(
+ 'baz' => array('type' => 'string')
+ )
+ ),
+ 'foo_2' => array(
+ 'extends' => 'foo',
+ 'parameters' => array(
+ 'bar' => array('type' => 'string')
+ )
+ ),
+ 'foo_3' => array(
+ 'class' => 'bar',
+ 'parameters' => array(
+ 'bar2' => array('type' => 'string')
+ )
+ ),
+ 'foo_4' => array(
+ 'extends' => array('foo_2', 'foo_3'),
+ 'parameters' => array(
+ 'bar3' => array('type' => 'string')
+ )
+ )
+ )
+ ));
+
+ $this->assertTrue($description->hasOperation('foo_4'));
+ $foo4 = $description->getOperation('foo_4');
+ $this->assertTrue($foo4->hasParam('baz'));
+ $this->assertTrue($foo4->hasParam('bar'));
+ $this->assertTrue($foo4->hasParam('bar2'));
+ $this->assertTrue($foo4->hasParam('bar3'));
+ $this->assertEquals('bar', $foo4->getClass());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionTest.php
new file mode 100644
index 0000000..ff25452
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Description/ServiceDescriptionTest.php
@@ -0,0 +1,240 @@
+<?php
+
+namespace Guzzle\Tests\Service\Description;
+
+use Guzzle\Service\Description\ServiceDescription;
+use Guzzle\Service\Description\Operation;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Service\Client;
+
+/**
+ * @covers Guzzle\Service\Description\ServiceDescription
+ */
+class ServiceDescriptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ protected $serviceData;
+
+ public function setup()
+ {
+ $this->serviceData = array(
+ 'test_command' => new Operation(array(
+ 'name' => 'test_command',
+ 'description' => 'documentationForCommand',
+ 'httpMethod' => 'DELETE',
+ 'class' => 'Guzzle\\Tests\\Service\\Mock\\Command\\MockCommand',
+ 'parameters' => array(
+ 'bucket' => array('required' => true),
+ 'key' => array('required' => true)
+ )
+ ))
+ );
+ }
+
+ /**
+ * @covers Guzzle\Service\Description\ServiceDescription::factory
+ * @covers Guzzle\Service\Description\ServiceDescriptionLoader::build
+ */
+ public function testFactoryDelegatesToConcreteFactories()
+ {
+ $jsonFile = __DIR__ . '/../../TestData/test_service.json';
+ $this->assertInstanceOf('Guzzle\Service\Description\ServiceDescription', ServiceDescription::factory($jsonFile));
+ }
+
+ public function testConstructor()
+ {
+ $service = new ServiceDescription(array('operations' => $this->serviceData));
+ $this->assertEquals(1, count($service->getOperations()));
+ $this->assertFalse($service->hasOperation('foobar'));
+ $this->assertTrue($service->hasOperation('test_command'));
+ }
+
+ public function testIsSerializable()
+ {
+ $service = new ServiceDescription(array('operations' => $this->serviceData));
+ $data = serialize($service);
+ $d2 = unserialize($data);
+ $this->assertEquals(serialize($service), serialize($d2));
+ }
+
+ public function testSerializesParameters()
+ {
+ $service = new ServiceDescription(array(
+ 'operations' => array(
+ 'foo' => new Operation(array('parameters' => array('foo' => array('type' => 'string'))))
+ )
+ ));
+ $serialized = serialize($service);
+ $this->assertContains('"parameters":{"foo":', $serialized);
+ $service = unserialize($serialized);
+ $this->assertTrue($service->getOperation('foo')->hasParam('foo'));
+ }
+
+ public function testAllowsForJsonBasedArrayParamsFunctionalTest()
+ {
+ $description = new ServiceDescription(array(
+ 'operations' => array(
+ 'test' => new Operation(array(
+ 'httpMethod' => 'PUT',
+ 'parameters' => array(
+ 'data' => array(
+ 'required' => true,
+ 'filters' => 'json_encode',
+ 'location' => 'body'
+ )
+ )
+ ))
+ )
+ ));
+ $client = new Client();
+ $client->setDescription($description);
+ $command = $client->getCommand('test', array(
+ 'data' => array(
+ 'foo' => 'bar'
+ )
+ ));
+
+ $request = $command->prepare();
+ $this->assertEquals('{"foo":"bar"}', (string) $request->getBody());
+ }
+
+ public function testContainsModels()
+ {
+ $d = new ServiceDescription(array(
+ 'operations' => array('foo' => array()),
+ 'models' => array(
+ 'Tag' => array('type' => 'object'),
+ 'Person' => array('type' => 'object')
+ )
+ ));
+ $this->assertTrue($d->hasModel('Tag'));
+ $this->assertTrue($d->hasModel('Person'));
+ $this->assertFalse($d->hasModel('Foo'));
+ $this->assertInstanceOf('Guzzle\Service\Description\Parameter', $d->getModel('Tag'));
+ $this->assertNull($d->getModel('Foo'));
+ $this->assertContains('"models":{', serialize($d));
+ $this->assertEquals(array('Tag', 'Person'), array_keys($d->getModels()));
+ }
+
+ public function testCanAddModels()
+ {
+ $d = new ServiceDescription(array());
+ $this->assertFalse($d->hasModel('Foo'));
+ $d->addModel(new Parameter(array('name' => 'Foo')));
+ $this->assertTrue($d->hasModel('Foo'));
+ }
+
+ public function testHasAttributes()
+ {
+ $d = new ServiceDescription(array(
+ 'operations' => array(),
+ 'name' => 'Name',
+ 'description' => 'Description',
+ 'apiVersion' => '1.24'
+ ));
+
+ $this->assertEquals('Name', $d->getName());
+ $this->assertEquals('Description', $d->getDescription());
+ $this->assertEquals('1.24', $d->getApiVersion());
+
+ $s = serialize($d);
+ $this->assertContains('"name":"Name"', $s);
+ $this->assertContains('"description":"Description"', $s);
+ $this->assertContains('"apiVersion":"1.24"', $s);
+
+ $d = unserialize($s);
+ $this->assertEquals('Name', $d->getName());
+ $this->assertEquals('Description', $d->getDescription());
+ $this->assertEquals('1.24', $d->getApiVersion());
+ }
+
+ public function testPersistsCustomAttributes()
+ {
+ $data = array(
+ 'operations' => array('foo' => array('class' => 'foo', 'parameters' => array())),
+ 'name' => 'Name',
+ 'description' => 'Test',
+ 'apiVersion' => '1.24',
+ 'auth' => 'foo',
+ 'keyParam' => 'bar'
+ );
+ $d = new ServiceDescription($data);
+ $d->setData('hello', 'baz');
+ $this->assertEquals('foo', $d->getData('auth'));
+ $this->assertEquals('baz', $d->getData('hello'));
+ $this->assertEquals('bar', $d->getData('keyParam'));
+ // responseClass and responseType are added by default
+ $data['operations']['foo']['responseClass'] = 'array';
+ $data['operations']['foo']['responseType'] = 'primitive';
+ $this->assertEquals($data + array('hello' => 'baz'), json_decode($d->serialize(), true));
+ }
+
+ public function testHasToArray()
+ {
+ $data = array(
+ 'operations' => array(),
+ 'name' => 'Name',
+ 'description' => 'Test'
+ );
+ $d = new ServiceDescription($data);
+ $arr = $d->toArray();
+ $this->assertEquals('Name', $arr['name']);
+ $this->assertEquals('Test', $arr['description']);
+ }
+
+ public function testReturnsNullWhenRetrievingMissingOperation()
+ {
+ $s = new ServiceDescription(array());
+ $this->assertNull($s->getOperation('foo'));
+ }
+
+ public function testCanAddOperations()
+ {
+ $s = new ServiceDescription(array());
+ $this->assertFalse($s->hasOperation('Foo'));
+ $s->addOperation(new Operation(array('name' => 'Foo')));
+ $this->assertTrue($s->hasOperation('Foo'));
+ }
+
+ /**
+ * @expectedException Guzzle\Common\Exception\InvalidArgumentException
+ */
+ public function testValidatesOperationTypes()
+ {
+ $s = new ServiceDescription(array(
+ 'operations' => array('foo' => new \stdClass())
+ ));
+ }
+
+ public function testHasBaseUrl()
+ {
+ $description = new ServiceDescription(array('baseUrl' => 'http://foo.com'));
+ $this->assertEquals('http://foo.com', $description->getBaseUrl());
+ $description->setBaseUrl('http://foobar.com');
+ $this->assertEquals('http://foobar.com', $description->getBaseUrl());
+ }
+
+ public function testCanUseBasePath()
+ {
+ $description = new ServiceDescription(array('basePath' => 'http://foo.com'));
+ $this->assertEquals('http://foo.com', $description->getBaseUrl());
+ }
+
+ public function testModelsHaveNames()
+ {
+ $desc = array(
+ 'models' => array(
+ 'date' => array('type' => 'string'),
+ 'user'=> array(
+ 'type' => 'object',
+ 'properties' => array(
+ 'dob' => array('$ref' => 'date')
+ )
+ )
+ )
+ );
+
+ $s = ServiceDescription::factory($desc);
+ $this->assertEquals('date', $s->getModel('date')->getName());
+ $this->assertEquals('dob', $s->getModel('user')->getProperty('dob')->getName());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/CommandTransferExceptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/CommandTransferExceptionTest.php
new file mode 100644
index 0000000..be0d4ac
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/CommandTransferExceptionTest.php
@@ -0,0 +1,66 @@
+<?php
+
+namespace Guzzle\Tests\Service\Exception;
+
+use Guzzle\Http\Exception\MultiTransferException;
+use Guzzle\Http\Message\Request;
+use Guzzle\Service\Exception\CommandTransferException;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+
+/**
+ * @covers Guzzle\Service\Exception\CommandTransferException
+ */
+class CommandTransferExceptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testStoresCommands()
+ {
+ $c1 = new MockCommand();
+ $c2 = new MockCommand();
+ $e = new CommandTransferException('Test');
+ $e->addSuccessfulCommand($c1)->addFailedCommand($c2);
+ $this->assertSame(array($c1), $e->getSuccessfulCommands());
+ $this->assertSame(array($c2), $e->getFailedCommands());
+ $this->assertSame(array($c1, $c2), $e->getAllCommands());
+ }
+
+ public function testConvertsMultiExceptionIntoCommandTransfer()
+ {
+ $r1 = new Request('GET', 'http://foo.com');
+ $r2 = new Request('GET', 'http://foobaz.com');
+ $e = new MultiTransferException('Test', 123);
+ $e->addSuccessfulRequest($r1)->addFailedRequest($r2);
+ $ce = CommandTransferException::fromMultiTransferException($e);
+
+ $this->assertInstanceOf('Guzzle\Service\Exception\CommandTransferException', $ce);
+ $this->assertEquals('Test', $ce->getMessage());
+ $this->assertEquals(123, $ce->getCode());
+ $this->assertSame(array($r1), $ce->getSuccessfulRequests());
+ $this->assertSame(array($r2), $ce->getFailedRequests());
+ }
+
+ public function testCanRetrieveExceptionForCommand()
+ {
+ $r1 = new Request('GET', 'http://foo.com');
+ $e1 = new \Exception('foo');
+ $c1 = $this->getMockBuilder('Guzzle\Tests\Service\Mock\Command\MockCommand')
+ ->setMethods(array('getRequest'))
+ ->getMock();
+ $c1->expects($this->once())->method('getRequest')->will($this->returnValue($r1));
+
+ $e = new MultiTransferException('Test', 123);
+ $e->addFailedRequestWithException($r1, $e1);
+ $ce = CommandTransferException::fromMultiTransferException($e);
+ $ce->addFailedCommand($c1);
+
+ $this->assertSame($e1, $ce->getExceptionForFailedCommand($c1));
+ }
+
+ public function testAddsNonRequestExceptions()
+ {
+ $e = new MultiTransferException();
+ $e->add(new \Exception('bar'));
+ $e->addFailedRequestWithException(new Request('GET', 'http://www.foo.com'), new \Exception('foo'));
+ $ce = CommandTransferException::fromMultiTransferException($e);
+ $this->assertEquals(2, count($ce));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/InconsistentClientTransferExceptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/InconsistentClientTransferExceptionTest.php
new file mode 100644
index 0000000..6455295
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/InconsistentClientTransferExceptionTest.php
@@ -0,0 +1,15 @@
+<?php
+
+namespace Guzzle\Tests\Service\Exception;
+
+use Guzzle\Service\Exception\InconsistentClientTransferException;
+
+class InconsistentClientTransferExceptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testStoresCommands()
+ {
+ $items = array('foo', 'bar');
+ $e = new InconsistentClientTransferException($items);
+ $this->assertEquals($items, $e->getCommands());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/ValidationExceptionTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/ValidationExceptionTest.php
new file mode 100644
index 0000000..ef789d8
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Exception/ValidationExceptionTest.php
@@ -0,0 +1,17 @@
+<?php
+
+namespace Guzzle\Tests\Service\Exception;
+
+use Guzzle\Service\Exception\ValidationException;
+
+class ValidationExceptionTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testCanSetAndRetrieveErrors()
+ {
+ $errors = array('foo', 'bar');
+
+ $e = new ValidationException('Foo');
+ $e->setErrors($errors);
+ $this->assertEquals($errors, $e->getErrors());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php
new file mode 100644
index 0000000..4ab423e
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/IterableCommand.php
@@ -0,0 +1,31 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command;
+
+use Guzzle\Service\Description\Operation;
+
+class IterableCommand extends MockCommand
+{
+ protected function createOperation()
+ {
+ return new Operation(array(
+ 'name' => 'iterable_command',
+ 'parameters' => array(
+ 'page_size' => array('type' => 'integer'),
+ 'next_token' => array('type' => 'string')
+ )
+ ));
+ }
+
+ protected function build()
+ {
+ $this->request = $this->client->createRequest('GET');
+
+ // Add the next token and page size query string values
+ $this->request->getQuery()->set('next_token', $this->get('next_token'));
+
+ if ($this->get('page_size')) {
+ $this->request->getQuery()->set('page_size', $this->get('page_size'));
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php
new file mode 100644
index 0000000..831a7e7
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/MockCommand.php
@@ -0,0 +1,32 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command;
+
+use Guzzle\Service\Description\Operation;
+
+class MockCommand extends \Guzzle\Service\Command\AbstractCommand
+{
+ protected function createOperation()
+ {
+ return new Operation(array(
+ 'name' => get_called_class() == __CLASS__ ? 'mock_command' : 'sub.sub',
+ 'httpMethod' => 'POST',
+ 'parameters' => array(
+ 'test' => array(
+ 'default' => 123,
+ 'required' => true,
+ 'doc' => 'Test argument'
+ ),
+ '_internal' => array(
+ 'default' => 'abc'
+ ),
+ 'foo' => array('filters' => array('strtoupper'))
+ )
+ ));
+ }
+
+ protected function build()
+ {
+ $this->request = $this->client->createRequest();
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php
new file mode 100644
index 0000000..72ae1f6
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/OtherCommand.php
@@ -0,0 +1,30 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command;
+
+use Guzzle\Service\Description\Operation;
+
+class OtherCommand extends MockCommand
+{
+ protected function createOperation()
+ {
+ return new Operation(array(
+ 'name' => 'other_command',
+ 'parameters' => array(
+ 'test' => array(
+ 'default' => '123',
+ 'required' => true,
+ 'doc' => 'Test argument'
+ ),
+ 'other' => array(),
+ 'arg' => array('type' => 'string'),
+ 'static' => array('static' => true, 'default' => 'this is static')
+ )
+ ));
+ }
+
+ protected function build()
+ {
+ $this->request = $this->client->getRequest('HEAD');
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php
new file mode 100644
index 0000000..d348480
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Command/Sub/Sub.php
@@ -0,0 +1,7 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Command\Sub;
+
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+
+class Sub extends MockCommand {}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php
new file mode 100644
index 0000000..6b9f55a
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/MockClient.php
@@ -0,0 +1,36 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock;
+
+use Guzzle\Common\Collection;
+use Guzzle\Service\Client;
+
+/**
+ * Mock Guzzle Service
+ */
+class MockClient extends Client
+{
+ /**
+ * Factory method to create a new mock client
+ *
+ * @param array|Collection $config Configuration data. Array keys:
+ * base_url - Base URL of web service
+ * api_version - API version
+ * scheme - URI scheme: http or https
+ * * username - API username
+ * * password - API password
+ * * subdomain - Unfuddle account subdomain
+ *
+ * @return MockClient
+ */
+ public static function factory($config = array())
+ {
+ $config = Collection::fromConfig($config, array(
+ 'base_url' => '{scheme}://127.0.0.1:8124/{api_version}/{subdomain}',
+ 'scheme' => 'http',
+ 'api_version' => 'v1'
+ ), array('username', 'password', 'subdomain'));
+
+ return new self($config->get('base_url'), $config);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php
new file mode 100644
index 0000000..8faf412
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Mock/Model/MockCommandIterator.php
@@ -0,0 +1,42 @@
+<?php
+
+namespace Guzzle\Tests\Service\Mock\Model;
+
+use Guzzle\Service\Resource\ResourceIterator;
+
+class MockCommandIterator extends ResourceIterator
+{
+ public $calledNext = 0;
+
+ protected function sendRequest()
+ {
+ if ($this->nextToken) {
+ $this->command->set('next_token', $this->nextToken);
+ }
+
+ $this->command->set('page_size', (int) $this->calculatePageSize());
+ $this->command->execute();
+
+ $data = json_decode($this->command->getResponse()->getBody(true), true);
+
+ $this->nextToken = $data['next_token'];
+
+ return $data['resources'];
+ }
+
+ public function next()
+ {
+ $this->calledNext++;
+ parent::next();
+ }
+
+ public function getResources()
+ {
+ return $this->resources;
+ }
+
+ public function getIteratedCount()
+ {
+ return $this->iteratedCount;
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/CompositeResourceIteratorFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/CompositeResourceIteratorFactoryTest.php
new file mode 100644
index 0000000..41c2073
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/CompositeResourceIteratorFactoryTest.php
@@ -0,0 +1,37 @@
+<?php
+
+namespace Guzzle\Tests\Service\Resource;
+
+use Guzzle\Service\Resource\CompositeResourceIteratorFactory;
+use Guzzle\Service\Resource\ResourceIteratorClassFactory;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+
+/**
+ * @covers Guzzle\Service\Resource\CompositeResourceIteratorFactory
+ */
+class CompositeResourceIteratorFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Iterator was not found for mock_command
+ */
+ public function testEnsuresIteratorClassExists()
+ {
+ $factory = new CompositeResourceIteratorFactory(array(
+ new ResourceIteratorClassFactory(array('Foo', 'Bar'))
+ ));
+ $cmd = new MockCommand();
+ $this->assertFalse($factory->canBuild($cmd));
+ $factory->build($cmd);
+ }
+
+ public function testBuildsResourceIterators()
+ {
+ $f1 = new ResourceIteratorClassFactory('Guzzle\Tests\Service\Mock\Model');
+ $factory = new CompositeResourceIteratorFactory(array());
+ $factory->addFactory($f1);
+ $command = new MockCommand();
+ $iterator = $factory->build($command, array('client.namespace' => 'Guzzle\Tests\Service\Mock'));
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/MapResourceIteratorFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/MapResourceIteratorFactoryTest.php
new file mode 100644
index 0000000..d166e92
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/MapResourceIteratorFactoryTest.php
@@ -0,0 +1,40 @@
+<?php
+
+namespace Guzzle\Tests\Service\Resource;
+
+use Guzzle\Service\Resource\MapResourceIteratorFactory;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+
+/**
+ * @covers Guzzle\Service\Resource\MapResourceIteratorFactory
+ */
+class MapResourceIteratorFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException InvalidArgumentException
+ * @expectedExceptionMessage Iterator was not found for mock_command
+ */
+ public function testEnsuresIteratorClassExists()
+ {
+ $factory = new MapResourceIteratorFactory(array('Foo', 'Bar'));
+ $factory->build(new MockCommand());
+ }
+
+ public function testBuildsResourceIterators()
+ {
+ $factory = new MapResourceIteratorFactory(array(
+ 'mock_command' => 'Guzzle\Tests\Service\Mock\Model\MockCommandIterator'
+ ));
+ $iterator = $factory->build(new MockCommand());
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
+ }
+
+ public function testUsesWildcardMappings()
+ {
+ $factory = new MapResourceIteratorFactory(array(
+ '*' => 'Guzzle\Tests\Service\Mock\Model\MockCommandIterator'
+ ));
+ $iterator = $factory->build(new MockCommand());
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ModelTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ModelTest.php
new file mode 100644
index 0000000..7214133
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ModelTest.php
@@ -0,0 +1,65 @@
+<?php
+
+namespace Guzzle\Tests\Service\Resource;
+
+use Guzzle\Service\Resource\Model;
+use Guzzle\Service\Description\Parameter;
+use Guzzle\Common\Collection;
+
+/**
+ * @covers Guzzle\Service\Resource\Model
+ */
+class ModelTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testOwnsStructure()
+ {
+ $param = new Parameter(array('type' => 'object'));
+ $model = new Model(array('foo' => 'bar'), $param);
+ $this->assertSame($param, $model->getStructure());
+ $this->assertEquals('bar', $model->get('foo'));
+ $this->assertEquals('bar', $model['foo']);
+ }
+
+ public function testCanBeUsedWithoutStructure()
+ {
+ $model = new Model(array(
+ 'Foo' => 'baz',
+ 'Bar' => array(
+ 'Boo' => 'Bam'
+ )
+ ));
+ $transform = function ($key, $value) {
+ return ($value && is_array($value)) ? new Collection($value) : $value;
+ };
+ $model = $model->map($transform);
+ $this->assertInstanceOf('Guzzle\Common\Collection', $model->getPath('Bar'));
+ }
+
+ public function testAllowsFiltering()
+ {
+ $model = new Model(array(
+ 'Foo' => 'baz',
+ 'Bar' => 'a'
+ ));
+ $model = $model->filter(function ($i, $v) {
+ return $v[0] == 'a';
+ });
+ $this->assertEquals(array('Bar' => 'a'), $model->toArray());
+ }
+
+ public function testDoesNotIncludeEmptyStructureInString()
+ {
+ $model = new Model(array('Foo' => 'baz'));
+ $str = (string) $model;
+ $this->assertContains('Debug output of model', $str);
+ $this->assertNotContains('Model structure', $str);
+ }
+
+ public function testDoesIncludeModelStructureInString()
+ {
+ $model = new Model(array('Foo' => 'baz'), new Parameter(array('name' => 'Foo')));
+ $str = (string) $model;
+ $this->assertContains('Debug output of Foo model', $str);
+ $this->assertContains('Model structure', $str);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorClassFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorClassFactoryTest.php
new file mode 100644
index 0000000..7b061b5
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorClassFactoryTest.php
@@ -0,0 +1,41 @@
+<?php
+
+namespace Guzzle\Tests\Service\Resource;
+
+use Guzzle\Service\Resource\ResourceIteratorClassFactory;
+use Guzzle\Tests\Service\Mock\Command\MockCommand;
+
+/**
+ * @covers Guzzle\Service\Resource\ResourceIteratorClassFactory
+ * @covers Guzzle\Service\Resource\AbstractResourceIteratorFactory
+ */
+class ResourceIteratorClassFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException \InvalidArgumentException
+ * @expectedExceptionMessage Iterator was not found for mock_command
+ */
+ public function testEnsuresIteratorClassExists()
+ {
+ $factory = new ResourceIteratorClassFactory(array('Foo', 'Bar'));
+ $factory->registerNamespace('Baz');
+ $command = new MockCommand();
+ $factory->build($command);
+ }
+
+ public function testBuildsResourceIterators()
+ {
+ $factory = new ResourceIteratorClassFactory('Guzzle\Tests\Service\Mock\Model');
+ $command = new MockCommand();
+ $iterator = $factory->build($command, array('client.namespace' => 'Guzzle\Tests\Service\Mock'));
+ $this->assertInstanceOf('Guzzle\Tests\Service\Mock\Model\MockCommandIterator', $iterator);
+ }
+
+ public function testChecksIfCanBuild()
+ {
+ $factory = new ResourceIteratorClassFactory('Guzzle\Tests\Service');
+ $this->assertFalse($factory->canBuild(new MockCommand()));
+ $factory = new ResourceIteratorClassFactory('Guzzle\Tests\Service\Mock\Model');
+ $this->assertTrue($factory->canBuild(new MockCommand()));
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorTest.php
new file mode 100644
index 0000000..573fb6d
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Service/Resource/ResourceIteratorTest.php
@@ -0,0 +1,184 @@
+<?php
+
+namespace Guzzle\Tests\Service\Resource;
+
+use Guzzle\Service\Resource\ResourceIterator;
+use Guzzle\Tests\Service\Mock\Model\MockCommandIterator;
+
+/**
+ * @group server
+ * @covers Guzzle\Service\Resource\ResourceIterator
+ */
+class ResourceIteratorTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ public function testDescribesEvents()
+ {
+ $this->assertInternalType('array', ResourceIterator::getAllEvents());
+ }
+
+ public function testConstructorConfiguresDefaults()
+ {
+ $ri = $this->getMockForAbstractClass('Guzzle\\Service\\Resource\\ResourceIterator', array(
+ $this->getServiceBuilder()->get('mock')->getCommand('iterable_command'),
+ array(
+ 'limit' => 10,
+ 'page_size' => 3
+ )
+ ), 'MockIterator');
+
+ $this->assertEquals(false, $ri->getNextToken());
+ $this->assertEquals(false, $ri->current());
+ }
+
+ public function testSendsRequestsForNextSetOfResources()
+ {
+ // Queue up an array of responses for iterating
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"g\", \"resources\": [\"d\", \"e\", \"f\"] }",
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"j\", \"resources\": [\"g\", \"h\", \"i\"] }",
+ "HTTP/1.1 200 OK\r\nContent-Length: 41\r\n\r\n{ \"next_token\": \"\", \"resources\": [\"j\"] }"
+ ));
+
+ // Create a new resource iterator using the IterableCommand mock
+ $ri = new MockCommandIterator($this->getServiceBuilder()->get('mock')->getCommand('iterable_command'), array(
+ 'page_size' => 3
+ ));
+
+ // Ensure that no requests have been sent yet
+ $this->assertEquals(0, count($this->getServer()->getReceivedRequests(false)));
+
+ //$this->assertEquals(array('d', 'e', 'f', 'g', 'h', 'i', 'j'), $ri->toArray());
+ $ri->toArray();
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals(3, count($requests));
+
+ $this->assertEquals(3, $requests[0]->getQuery()->get('page_size'));
+ $this->assertEquals(3, $requests[1]->getQuery()->get('page_size'));
+ $this->assertEquals(3, $requests[2]->getQuery()->get('page_size'));
+
+ // Reset and resend
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"g\", \"resources\": [\"d\", \"e\", \"f\"] }",
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"j\", \"resources\": [\"g\", \"h\", \"i\"] }",
+ "HTTP/1.1 200 OK\r\nContent-Length: 41\r\n\r\n{ \"next_token\": \"\", \"resources\": [\"j\"] }",
+ ));
+
+ $d = array();
+ foreach ($ri as $data) {
+ $d[] = $data;
+ }
+ $this->assertEquals(array('d', 'e', 'f', 'g', 'h', 'i', 'j'), $d);
+ }
+
+ public function testCalculatesPageSize()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"g\", \"resources\": [\"d\", \"e\", \"f\"] }",
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"j\", \"resources\": [\"g\", \"h\", \"i\"] }",
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"j\", \"resources\": [\"j\", \"k\"] }"
+ ));
+
+ $ri = new MockCommandIterator($this->getServiceBuilder()->get('mock')->getCommand('iterable_command'), array(
+ 'page_size' => 3,
+ 'limit' => 7
+ ));
+
+ $this->assertEquals(array('d', 'e', 'f', 'g', 'h', 'i', 'j'), $ri->toArray());
+ $requests = $this->getServer()->getReceivedRequests(true);
+ $this->assertEquals(3, count($requests));
+ $this->assertEquals(3, $requests[0]->getQuery()->get('page_size'));
+ $this->assertEquals(3, $requests[1]->getQuery()->get('page_size'));
+ $this->assertEquals(1, $requests[2]->getQuery()->get('page_size'));
+ }
+
+ public function testUseAsArray()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"g\", \"resources\": [\"d\", \"e\", \"f\"] }",
+ "HTTP/1.1 200 OK\r\nContent-Length: 52\r\n\r\n{ \"next_token\": \"\", \"resources\": [\"g\", \"h\", \"i\"] }"
+ ));
+
+ $ri = new MockCommandIterator($this->getServiceBuilder()->get('mock')->getCommand('iterable_command'));
+
+ // Ensure that the key is never < 0
+ $this->assertEquals(0, $ri->key());
+ $this->assertEquals(0, count($ri));
+
+ // Ensure that the iterator can be used as KVP array
+ $data = array();
+ foreach ($ri as $key => $value) {
+ $data[$key] = $value;
+ }
+
+ // Ensure that the iterate is countable
+ $this->assertEquals(6, count($ri));
+ $this->assertEquals(array('d', 'e', 'f', 'g', 'h', 'i'), $data);
+ }
+
+ public function testBailsWhenSendReturnsNoResults()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\n\r\n{ \"next_token\": \"g\", \"resources\": [\"d\", \"e\", \"f\"] }",
+ "HTTP/1.1 200 OK\r\n\r\n{ \"next_token\": \"\", \"resources\": [] }"
+ ));
+
+ $ri = new MockCommandIterator($this->getServiceBuilder()->get('mock')->getCommand('iterable_command'));
+
+ // Ensure that the iterator can be used as KVP array
+ $data = $ri->toArray();
+
+ // Ensure that the iterate is countable
+ $this->assertEquals(3, count($ri));
+ $this->assertEquals(array('d', 'e', 'f'), $data);
+
+ $this->assertEquals(2, $ri->getRequestCount());
+ }
+
+ public function testHoldsDataOptions()
+ {
+ $ri = new MockCommandIterator($this->getServiceBuilder()->get('mock')->getCommand('iterable_command'));
+ $this->assertNull($ri->get('foo'));
+ $this->assertSame($ri, $ri->set('foo', 'bar'));
+ $this->assertEquals('bar', $ri->get('foo'));
+ }
+
+ public function testSettingLimitOrPageSizeClearsData()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\n\r\n{ \"next_token\": \"\", \"resources\": [\"d\", \"e\", \"f\"] }",
+ "HTTP/1.1 200 OK\r\n\r\n{ \"next_token\": \"\", \"resources\": [\"d\", \"e\", \"f\"] }",
+ "HTTP/1.1 200 OK\r\n\r\n{ \"next_token\": \"\", \"resources\": [\"d\", \"e\", \"f\"] }"
+ ));
+
+ $ri = new MockCommandIterator($this->getServiceBuilder()->get('mock')->getCommand('iterable_command'));
+ $ri->toArray();
+ $this->assertNotEmpty($this->readAttribute($ri, 'resources'));
+
+ $ri->setLimit(10);
+ $this->assertEmpty($this->readAttribute($ri, 'resources'));
+
+ $ri->toArray();
+ $this->assertNotEmpty($this->readAttribute($ri, 'resources'));
+ $ri->setPageSize(10);
+ $this->assertEmpty($this->readAttribute($ri, 'resources'));
+ }
+
+ public function testWorksWithCustomAppendIterator()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue(array(
+ "HTTP/1.1 200 OK\r\n\r\n{ \"next_token\": \"\", \"resources\": [\"d\", \"e\", \"f\"] }"
+ ));
+ $ri = new MockCommandIterator($this->getServiceBuilder()->get('mock')->getCommand('iterable_command'));
+ $a = new \Guzzle\Iterator\AppendIterator();
+ $a->append($ri);
+ $results = iterator_to_array($a, false);
+ $this->assertEquals(4, $ri->calledNext);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/PhpStreamRequestFactoryTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/PhpStreamRequestFactoryTest.php
new file mode 100644
index 0000000..083aaa0
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/PhpStreamRequestFactoryTest.php
@@ -0,0 +1,172 @@
+<?php
+
+namespace Guzzle\Tests\Stream;
+
+use Guzzle\Stream\Stream;
+use Guzzle\Stream\PhpStreamRequestFactory;
+use Guzzle\Http\Client;
+
+/**
+ * @group server
+ * @covers \Guzzle\Stream\PhpStreamRequestFactory
+ */
+class PhpStreamRequestFactoryTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /** @var Client */
+ protected $client;
+
+ /** @var PhpStreamRequestFactory */
+ protected $factory;
+
+ protected function setUp()
+ {
+ $this->client = new Client($this->getServer()->getUrl());
+ $this->factory = new PhpStreamRequestFactory();
+ }
+
+ public function testOpensValidStreamByCreatingContext()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+ $request = $this->client->get('/');
+ $stream = $this->factory->fromRequest($request);
+ $this->assertEquals('hi', (string) $stream);
+ $headers = $this->factory->getLastResponseHeaders();
+ $this->assertContains('HTTP/1.1 200 OK', $headers);
+ $this->assertContains('Content-Length: 2', $headers);
+ $this->assertSame($headers, $stream->getCustomData('response_headers'));
+ $this->assertEquals(2, $stream->getSize());
+ }
+
+ public function testOpensValidStreamByPassingContextAndMerging()
+ {
+ $request = $this->client->get('/');
+ $this->factory = $this->getMockBuilder('Guzzle\Stream\PhpStreamRequestFactory')
+ ->setMethods(array('createContext', 'createStream'))
+ ->getMock();
+ $this->factory->expects($this->never())
+ ->method('createContext');
+ $this->factory->expects($this->once())
+ ->method('createStream')
+ ->will($this->returnValue(new Stream(fopen('php://temp', 'r'))));
+
+ $context = array('http' => array('method' => 'HEAD', 'ignore_errors' => false));
+ $this->factory->fromRequest($request, stream_context_create($context));
+ $options = stream_context_get_options($this->readAttribute($this->factory, 'context'));
+ $this->assertEquals('HEAD', $options['http']['method']);
+ $this->assertFalse($options['http']['ignore_errors']);
+ $this->assertEquals('1.1', $options['http']['protocol_version']);
+ }
+
+ public function testAppliesProxySettings()
+ {
+ $request = $this->client->get('/');
+ $request->getCurlOptions()->set(CURLOPT_PROXY, 'tcp://foo.com');
+ $this->factory = $this->getMockBuilder('Guzzle\Stream\PhpStreamRequestFactory')
+ ->setMethods(array('createStream'))
+ ->getMock();
+ $this->factory->expects($this->once())
+ ->method('createStream')
+ ->will($this->returnValue(new Stream(fopen('php://temp', 'r'))));
+ $this->factory->fromRequest($request);
+ $options = stream_context_get_options($this->readAttribute($this->factory, 'context'));
+ $this->assertEquals('tcp://foo.com', $options['http']['proxy']);
+ }
+
+ public function testAddsPostFields()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+ $request = $this->client->post('/', array('Foo' => 'Bar'), array('foo' => 'baz bar'));
+ $stream = $this->factory->fromRequest($request);
+ $this->assertEquals('hi', (string) $stream);
+
+ $headers = $this->factory->getLastResponseHeaders();
+ $this->assertContains('HTTP/1.1 200 OK', $headers);
+ $this->assertContains('Content-Length: 2', $headers);
+ $this->assertSame($headers, $stream->getCustomData('response_headers'));
+
+ $received = $this->getServer()->getReceivedRequests();
+ $this->assertEquals(1, count($received));
+ $this->assertContains('POST / HTTP/1.1', $received[0]);
+ $this->assertContains('host: ', $received[0]);
+ $this->assertContains('user-agent: Guzzle/', $received[0]);
+ $this->assertContains('foo: Bar', $received[0]);
+ $this->assertContains('content-length: 13', $received[0]);
+ $this->assertContains('foo=baz%20bar', $received[0]);
+ }
+
+ public function testAddsBody()
+ {
+ $this->getServer()->flush();
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+ $request = $this->client->put('/', array('Foo' => 'Bar'), 'Testing...123');
+ $stream = $this->factory->fromRequest($request);
+ $this->assertEquals('hi', (string) $stream);
+
+ $headers = $this->factory->getLastResponseHeaders();
+ $this->assertContains('HTTP/1.1 200 OK', $headers);
+ $this->assertContains('Content-Length: 2', $headers);
+ $this->assertSame($headers, $stream->getCustomData('response_headers'));
+
+ $received = $this->getServer()->getReceivedRequests();
+ $this->assertEquals(1, count($received));
+ $this->assertContains('PUT / HTTP/1.1', $received[0]);
+ $this->assertContains('host: ', $received[0]);
+ $this->assertContains('user-agent: Guzzle/', $received[0]);
+ $this->assertContains('foo: Bar', $received[0]);
+ $this->assertContains('content-length: 13', $received[0]);
+ $this->assertContains('Testing...123', $received[0]);
+ }
+
+ public function testCanDisableSslValidation()
+ {
+ $request = $this->client->get('/');
+ $request->getCurlOptions()->set(CURLOPT_SSL_VERIFYPEER, false);
+ $this->factory = $this->getMockBuilder('Guzzle\Stream\PhpStreamRequestFactory')
+ ->setMethods(array('createStream'))
+ ->getMock();
+ $this->factory->expects($this->once())
+ ->method('createStream')
+ ->will($this->returnValue(new Stream(fopen('php://temp', 'r'))));
+ $this->factory->fromRequest($request);
+ $options = stream_context_get_options($this->readAttribute($this->factory, 'context'));
+ $this->assertFalse($options['ssl']['verify_peer']);
+ }
+
+ public function testUsesSslValidationByDefault()
+ {
+ $request = $this->client->get('/');
+ $this->factory = $this->getMockBuilder('Guzzle\Stream\PhpStreamRequestFactory')
+ ->setMethods(array('createStream'))
+ ->getMock();
+ $this->factory->expects($this->once())
+ ->method('createStream')
+ ->will($this->returnValue(new Stream(fopen('php://temp', 'r'))));
+ $this->factory->fromRequest($request);
+ $options = stream_context_get_options($this->readAttribute($this->factory, 'context'));
+ $this->assertTrue($options['ssl']['verify_peer']);
+ $this->assertSame($request->getCurlOptions()->get(CURLOPT_CAINFO), $options['ssl']['cafile']);
+ }
+
+ public function testBasicAuthAddsUserAndPassToUrl()
+ {
+ $request = $this->client->get('/');
+ $request->setAuth('Foo', 'Bar');
+ $this->factory = $this->getMockBuilder('Guzzle\Stream\PhpStreamRequestFactory')
+ ->setMethods(array('createStream'))
+ ->getMock();
+ $this->factory->expects($this->once())
+ ->method('createStream')
+ ->will($this->returnValue(new Stream(fopen('php://temp', 'r'))));
+ $this->factory->fromRequest($request);
+ $this->assertContains('Foo:Bar@', (string) $this->readAttribute($this->factory, 'url'));
+ }
+
+ public function testCanCreateCustomStreamClass()
+ {
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 2\r\n\r\nhi");
+ $request = $this->client->get('/');
+ $stream = $this->factory->fromRequest($request, array(), array('stream_class' => 'Guzzle\Http\EntityBody'));
+ $this->assertInstanceOf('Guzzle\Http\EntityBody', $stream);
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/StreamTest.php b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/StreamTest.php
new file mode 100644
index 0000000..4973f25
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/Stream/StreamTest.php
@@ -0,0 +1,189 @@
+<?php
+
+namespace Guzzle\Tests\Stream;
+
+use Guzzle\Stream\Stream;
+
+/**
+ * @group server
+ * @covers Guzzle\Stream\Stream
+ */
+class StreamTest extends \Guzzle\Tests\GuzzleTestCase
+{
+ /**
+ * @expectedException \InvalidArgumentException
+ */
+ public function testConstructorThrowsExceptionOnInvalidArgument()
+ {
+ $stream = new Stream(true);
+ }
+
+ public function testConstructor()
+ {
+ $handle = fopen('php://temp', 'r+');
+ fwrite($handle, 'data');
+ $stream = new Stream($handle);
+ $this->assertEquals($handle, $stream->getStream());
+ $this->assertTrue($stream->isReadable());
+ $this->assertTrue($stream->isWritable());
+ $this->assertTrue($stream->isLocal());
+ $this->assertTrue($stream->isSeekable());
+ $this->assertEquals('PHP', $stream->getWrapper());
+ $this->assertEquals('TEMP', $stream->getStreamType());
+ $this->assertEquals(4, $stream->getSize());
+ $this->assertEquals('php://temp', $stream->getUri());
+ $this->assertEquals(array(), $stream->getWrapperData());
+ $this->assertFalse($stream->isConsumed());
+ unset($stream);
+ }
+
+ public function testCanModifyStream()
+ {
+ $handle1 = fopen('php://temp', 'r+');
+ $handle2 = fopen('php://temp', 'r+');
+ $stream = new Stream($handle1);
+ $this->assertSame($handle1, $stream->getStream());
+ $stream->setStream($handle2, 10);
+ $this->assertEquals(10, $stream->getSize());
+ $this->assertSame($handle2, $stream->getStream());
+ }
+
+ public function testStreamClosesHandleOnDestruct()
+ {
+ $handle = fopen('php://temp', 'r');
+ $stream = new Stream($handle);
+ unset($stream);
+ $this->assertFalse(is_resource($handle));
+ }
+
+ public function testConvertsToString()
+ {
+ $handle = fopen('php://temp', 'w+');
+ fwrite($handle, 'data');
+ $stream = new Stream($handle);
+ $this->assertEquals('data', (string) $stream);
+ unset($stream);
+
+ $handle = fopen(__DIR__ . '/../TestData/FileBody.txt', 'r');
+ $stream = new Stream($handle);
+ $this->assertEquals('', (string) $stream);
+ unset($stream);
+ }
+
+ public function testConvertsToStringAndRestoresCursorPos()
+ {
+ $handle = fopen('php://temp', 'w+');
+ $stream = new Stream($handle);
+ $stream->write('foobazbar');
+ $stream->seek(3);
+ $this->assertEquals('foobazbar', (string) $stream);
+ $this->assertEquals(3, $stream->ftell());
+ }
+
+ public function testIsConsumed()
+ {
+ $handle = fopen('php://temp', 'w+');
+ fwrite($handle, 'data');
+ $stream = new Stream($handle);
+ $this->assertFalse($stream->isConsumed());
+ $stream->read(4);
+ $this->assertTrue($stream->isConsumed());
+ }
+
+ public function testAllowsSettingManualSize()
+ {
+ $handle = fopen('php://temp', 'w+');
+ fwrite($handle, 'data');
+ $stream = new Stream($handle);
+ $stream->setSize(10);
+ $this->assertEquals(10, $stream->getSize());
+ unset($stream);
+ }
+
+ public function testWrapsStream()
+ {
+ $handle = fopen('php://temp', 'w+');
+ fwrite($handle, 'data');
+ $stream = new Stream($handle);
+ $this->assertTrue($stream->isSeekable());
+ $this->assertTrue($stream->isReadable());
+ $this->assertTrue($stream->seek(0));
+ $this->assertEquals('da', $stream->read(2));
+ $this->assertEquals('ta', $stream->read(2));
+ $this->assertTrue($stream->seek(0));
+ $this->assertEquals('data', $stream->read(4));
+ $stream->write('_appended');
+ $stream->seek(0);
+ $this->assertEquals('data_appended', $stream->read(13));
+ }
+
+ public function testGetSize()
+ {
+ $size = filesize(__DIR__ . '/../../../bootstrap.php');
+ $handle = fopen(__DIR__ . '/../../../bootstrap.php', 'r');
+ $stream = new Stream($handle);
+ $this->assertEquals($handle, $stream->getStream());
+ $this->assertEquals($size, $stream->getSize());
+ $this->assertEquals($size, $stream->getSize());
+ unset($stream);
+
+ // Make sure that false is returned when the size cannot be determined
+ $this->getServer()->enqueue("HTTP/1.1 200 OK\r\nContent-Length: 0\r\n\r\n");
+ $handle = fopen('http://127.0.0.1:' . $this->getServer()->getPort(), 'r');
+ $stream = new Stream($handle);
+ $this->assertEquals(false, $stream->getSize());
+ unset($stream);
+ }
+
+ public function testEnsuresSizeIsConsistent()
+ {
+ $h = fopen('php://temp', 'r+');
+ fwrite($h, 'foo');
+ $stream = new Stream($h);
+ $this->assertEquals(3, $stream->getSize());
+ $stream->write('test');
+ $this->assertEquals(7, $stream->getSize());
+ fclose($h);
+ }
+
+ public function testAbstractsMetaData()
+ {
+ $handle = fopen(__DIR__ . '/../../../bootstrap.php', 'r');
+ $stream = new Stream($handle);
+ $this->assertEquals('plainfile', $stream->getMetaData('wrapper_type'));
+ $this->assertEquals(null, $stream->getMetaData('wrapper_data'));
+ $this->assertInternalType('array', $stream->getMetaData());
+ }
+
+ public function testDoesNotAttemptToWriteToReadonlyStream()
+ {
+ $handle = fopen(__DIR__ . '/../../../bootstrap.php', 'r');
+ $stream = new Stream($handle);
+ $this->assertEquals(0, $stream->write('foo'));
+ }
+
+ public function testProvidesStreamPosition()
+ {
+ $handle = fopen(__DIR__ . '/../../../bootstrap.php', 'r');
+ $stream = new Stream($handle);
+ $stream->read(2);
+ $this->assertSame(ftell($handle), $stream->ftell());
+ $this->assertEquals(2, $stream->ftell());
+ }
+
+ public function testRewindIsSeekZero()
+ {
+ $stream = new Stream(fopen('php://temp', 'w+'));
+ $stream->write('foobazbar');
+ $this->assertTrue($stream->rewind());
+ $this->assertEquals('foobazbar', $stream->read(9));
+ }
+
+ public function testCanDetachStream()
+ {
+ $r = fopen('php://temp', 'w+');
+ $stream = new Stream($r);
+ $stream->detachStream();
+ $this->assertNull($stream->getStream());
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/FileBody.txt b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/FileBody.txt
new file mode 100644
index 0000000..e69de29
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/FileBody.txt
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/bar.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/bar.json
new file mode 100644
index 0000000..c354ed7
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/bar.json
@@ -0,0 +1,3 @@
+{
+ "includes": ["foo.json"]
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/baz.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/baz.json
new file mode 100644
index 0000000..765237b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/baz.json
@@ -0,0 +1,3 @@
+{
+ "includes": ["foo.json", "bar.json"]
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/foo.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/foo.json
new file mode 100644
index 0000000..cee5005
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/foo.json
@@ -0,0 +1,8 @@
+{
+ "includes": ["recursive.json"],
+ "operations": {
+ "abstract": {
+ "httpMethod": "POST"
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/recursive.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/recursive.json
new file mode 100644
index 0000000..c354ed7
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/description/recursive.json
@@ -0,0 +1,3 @@
+{
+ "includes": ["foo.json"]
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/mock_response b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/mock_response
new file mode 100644
index 0000000..b6938a2
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/mock_response
@@ -0,0 +1,3 @@
+HTTP/1.1 200 OK
+Content-Length: 0
+
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json1.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json1.json
new file mode 100644
index 0000000..7b2a9da
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json1.json
@@ -0,0 +1,18 @@
+{
+ "includes": [ "json2.json" ],
+ "services": {
+ "abstract": {
+ "access_key": "xyz",
+ "secret": "abc"
+ },
+ "mock": {
+ "class": "Guzzle\\Tests\\Service\\Mock\\MockClient",
+ "extends": "abstract",
+ "params": {
+ "username": "foo",
+ "password": "baz",
+ "subdomain": "bar"
+ }
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json2.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json2.json
new file mode 100644
index 0000000..08e5566
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/json2.json
@@ -0,0 +1,11 @@
+{
+ "services": {
+ "foo": {
+ "class": "Guzzle\\Tests\\Service\\Mock\\MockClient",
+ "extends": "abstract",
+ "params": {
+ "baz": "bar"
+ }
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/services.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/services.json
new file mode 100644
index 0000000..25452e4
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/services/services.json
@@ -0,0 +1,71 @@
+{
+ "abstract": {
+ "access_key": "xyz",
+ "secret": "abc"
+ },
+ "mock": {
+ "class": "Guzzle\\Tests\\Service\\Mock\\MockClient",
+ "extends": "abstract",
+ "params": {
+ "username": "foo",
+ "password": "baz",
+ "subdomain": "bar"
+ }
+ },
+
+ "test.abstract.aws": {
+ "params": {
+ "access_key": "12345",
+ "secret_key": "abcd"
+ }
+ },
+
+ "test.s3": {
+ "class": "Guzzle\\Service\\Aws\\S3Client",
+ "extends": "test.abstract.aws",
+ "params": {
+ "devpay_product_token": "",
+ "devpay_user_token": ""
+ }
+ },
+
+ "test.simple_db": {
+ "class": "Guzzle\\Service\\Aws\\SimpleDb\\SimpleDbClient",
+ "extends": "test.abstract.aws"
+ },
+
+ "test.sqs": {
+ "class": "Guzzle\\Service\\Aws\\Sqs\\SqsClient",
+ "extends": "test.abstract.aws"
+ },
+
+ "test.centinel": {
+ "class": "Guzzle\\Service\\CardinalCommerce\\Centinel.CentinelClient",
+ "params": {
+ "password": "test",
+ "processor_id": "123",
+ "merchant_id": "456"
+ }
+ },
+
+ "test.mws": {
+ "class": "Guzzle\\Service\\Mws\\MwsClient",
+ "extends": "test.abstract.aws",
+ "params": {
+ "merchant_id": "ABCDE",
+ "marketplace_id": "FGHIJ",
+ "application_name": "GuzzleTest",
+ "application_version": "0.1",
+ "base_url": "https://mws.amazonservices.com"
+ }
+ },
+
+ "mock": {
+ "class": "Guzzle\\Tests\\Service\\Mock\\MockClient",
+ "params": {
+ "username": "test_user",
+ "password": "****",
+ "subdomain": "test"
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service.json
new file mode 100644
index 0000000..01557ca
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service.json
@@ -0,0 +1,40 @@
+{
+ "includes": [ "test_service2.json" ],
+ "operations": {
+ "test": {
+ "uri": "/path"
+ },
+ "concrete": {
+ "extends": "abstract"
+ },
+ "foo_bar": {
+ "uri": "/testing",
+ "parameters": {
+ "other": {
+ "location": "json",
+ "location_key": "Other"
+ },
+ "test": {
+ "type": "object",
+ "location": "json",
+ "properties": {
+ "baz": {
+ "type": "boolean",
+ "default": true
+ },
+ "bar": {
+ "type": "string",
+ "filters": [
+ {
+ "method": "strtolower",
+ "args": ["test", "@value"]
+ },
+ "strtoupper"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service2.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service2.json
new file mode 100644
index 0000000..66dd9ef
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service2.json
@@ -0,0 +1,7 @@
+{
+ "operations": {
+ "abstract": {
+ "uri": "/abstract"
+ }
+ }
+}
diff --git a/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service_3.json b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service_3.json
new file mode 100644
index 0000000..ae2ae0b
--- /dev/null
+++ b/vendor/guzzle/guzzle/tests/Guzzle/Tests/TestData/test_service_3.json
@@ -0,0 +1,40 @@
+{
+ "includes": [ "test_service2.json" ],
+ "operations": {
+ "test": {
+ "uri": "/path"
+ },
+ "concrete": {
+ "extends": "abstract"
+ },
+ "baz_qux": {
+ "uri": "/testing",
+ "parameters": {
+ "other": {
+ "location": "json",
+ "location_key": "Other"
+ },
+ "test": {
+ "type": "object",
+ "location": "json",
+ "properties": {
+ "baz": {
+ "type": "boolean",
+ "default": true
+ },
+ "bar": {
+ "type": "string",
+ "filters": [
+ {
+ "method": "strtolower",
+ "args": ["test", "@value"]
+ },
+ "strtoupper"
+ ]
+ }
+ }
+ }
+ }
+ }
+ }
+}