From e1ed48b68d258c6208fe1d01aec001f91639f874 Mon Sep 17 00:00:00 2001 From: Igor Santos Date: Sun, 7 May 2017 03:41:53 -0300 Subject: [PATCH 01/13] Adding descriptive error message on parameter failure --- src/Operation.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Operation.php b/src/Operation.php index f9c2feb6..57b75ca2 100644 --- a/src/Operation.php +++ b/src/Operation.php @@ -288,7 +288,7 @@ private function resolveParameters() foreach ($this->config['parameters'] as $name => $param) { if (!is_array($param)) { throw new \InvalidArgumentException( - 'Parameters must be arrays' + "Parameters must be arrays, {$this->config['name']}.$name is ".gettype($param) ); } $param['name'] = $name; From 8fe99a991ba3ba6a82ececae9b21f4dfdc25c243 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Fri, 19 May 2017 11:17:34 +0200 Subject: [PATCH 02/13] Revert "Do not mutate command at validation" Revert the commit 2b191b10d920f790abb7a24a8892e8913670a697 since it introduced a regression which affects the usage of operation extension. See #145 --- src/Handler/ValidatedDescriptionHandler.php | 6 +++ .../ValidatedDescriptionHandlerTest.php | 38 ------------------- 2 files changed, 6 insertions(+), 38 deletions(-) diff --git a/src/Handler/ValidatedDescriptionHandler.php b/src/Handler/ValidatedDescriptionHandler.php index 2003a35a..7bb2569a 100644 --- a/src/Handler/ValidatedDescriptionHandler.php +++ b/src/Handler/ValidatedDescriptionHandler.php @@ -49,6 +49,10 @@ public function __invoke(callable $handler) if (! $this->validator->validate($schema, $value)) { $errors = array_merge($errors, $this->validator->getErrors()); + } elseif ($value !== $command[$name]) { + // Update the config value if it changed and no validation + // errors were encountered + $command[$name] = $value; } } @@ -60,6 +64,8 @@ public function __invoke(callable $handler) $params->setName($name); if (! $this->validator->validate($params, $value)) { $errors = array_merge($errors, $this->validator->getErrors()); + } elseif ($value !== $command[$name]) { + $command[$name] = $value; } } } diff --git a/tests/Handler/ValidatedDescriptionHandlerTest.php b/tests/Handler/ValidatedDescriptionHandlerTest.php index e5dcce88..f02396c5 100644 --- a/tests/Handler/ValidatedDescriptionHandlerTest.php +++ b/tests/Handler/ValidatedDescriptionHandlerTest.php @@ -2,7 +2,6 @@ namespace GuzzleHttp\Tests\Command\Guzzle\Handler; use GuzzleHttp\Client as HttpClient; -use GuzzleHttp\Command\Command; use GuzzleHttp\Command\Guzzle\Description; use GuzzleHttp\Command\Guzzle\GuzzleClient; @@ -110,41 +109,4 @@ public function testFilterBeforeValidate() $client = new GuzzleClient(new HttpClient(), $description); $client->foo(['bar' => new \DateTimeImmutable()]); // Should not throw any exception } - - public function testValidationDoesNotMutateCommand() - { - $description = new Description([ - 'operations' => [ - 'foo' => [ - 'uri' => 'http://httpbin.org', - 'httpMethod' => 'GET', - 'parameters' => [ - 'bar' => [ - 'location' => 'query', - 'type' => 'string', - 'filters' => ['json_encode'], - 'required' => true, - ] - ] - ] - ] - ]); - - $client = new GuzzleClient(new HttpClient(), $description); - $command = new Command('foo', ['bar' => ['baz' => 'bat']]); - - $paramsBeforeValidation = $command->toArray(); - - $client->getHandlerStack()->after('validate_description', function (callable $next) use ($paramsBeforeValidation) { - return function (Command $command) use ($next, $paramsBeforeValidation) { - $paramsAfterValidation = $command->toArray(); - - $this->assertSame($paramsBeforeValidation, $paramsAfterValidation); - - return $next($command); - }; - }); - - $client->execute($command); - } } From ecbec30aefa396210c769ec834fcb240090e6c80 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Fri, 19 May 2017 11:20:36 +0200 Subject: [PATCH 03/13] Add Unit Test which covers the regression Thanks to @delamart for reporting and providing the test. Closes #145, closes #146 --- src/Handler/ValidatedDescriptionHandler.php | 5 ++- tests/GuzzleClientTest.php | 44 +++++++++++++++++++++ 2 files changed, 47 insertions(+), 2 deletions(-) diff --git a/src/Handler/ValidatedDescriptionHandler.php b/src/Handler/ValidatedDescriptionHandler.php index 7bb2569a..c5ec2d6e 100644 --- a/src/Handler/ValidatedDescriptionHandler.php +++ b/src/Handler/ValidatedDescriptionHandler.php @@ -50,8 +50,9 @@ public function __invoke(callable $handler) if (! $this->validator->validate($schema, $value)) { $errors = array_merge($errors, $this->validator->getErrors()); } elseif ($value !== $command[$name]) { - // Update the config value if it changed and no validation - // errors were encountered + // Update the config value if it changed and no validation errors were encountered. + // This happen when the user extending an operation + // See https://github.com/guzzle/guzzle-services/issues/145 $command[$name] = $value; } } diff --git a/tests/GuzzleClientTest.php b/tests/GuzzleClientTest.php index 6aeb3852..0e5c9d9c 100644 --- a/tests/GuzzleClientTest.php +++ b/tests/GuzzleClientTest.php @@ -990,4 +990,48 @@ public function testDocumentationExampleFromReadme() $result = $guzzle->testing(['foo' => 'bar']); $this->assertEquals('bar', $result['args']['foo']); } + + public function testDescriptionWithExtends() + { + $client = new HttpClient(); + $description = new Description([ + 'baseUrl' => 'http://httpbin.org/', + 'operations' => [ + 'testing' => [ + 'httpMethod' => 'GET', + 'uri' => '/get', + 'responseModel' => 'getResponse', + 'parameters' => [ + 'foo' => [ + 'type' => 'string', + 'default' => 'foo', + 'location' => 'query' + ] + ] + ], + 'testing_extends' => [ + 'extends' => 'testing', + 'responseModel' => 'getResponse', + 'parameters' => [ + 'bar' => [ + 'type' => 'string', + 'location' => 'query' + ] + ] + ], + ], + 'models' => [ + 'getResponse' => [ + 'type' => 'object', + 'additionalProperties' => [ + 'location' => 'json' + ] + ] + ] + ]); + $guzzle = new GuzzleClient($client, $description); + $result = $guzzle->testing_extends(['bar' => 'bar']); + $this->assertEquals('bar', $result['args']['bar']); + $this->assertEquals('foo', $result['args']['foo']); + } } From 5d8e6e8dda64168240635a64c546bd2095405b69 Mon Sep 17 00:00:00 2001 From: Rom Palmas Date: Thu, 28 Sep 2017 11:44:34 +1000 Subject: [PATCH 04/13] Use wire name when visiting array If the wire name isn't set then the name is used instead. See src/Parameter.php:327 --- src/ResponseLocation/JsonLocation.php | 2 +- tests/ResponseLocation/JsonLocationTest.php | 44 +++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/src/ResponseLocation/JsonLocation.php b/src/ResponseLocation/JsonLocation.php index 115da71c..f94c7844 100644 --- a/src/ResponseLocation/JsonLocation.php +++ b/src/ResponseLocation/JsonLocation.php @@ -102,7 +102,7 @@ public function visit( // Treat as javascript array if ($name) { // name provided, store it under a key in the array - $subArray = isset($this->json[$name]) ? $this->json[$name] : null; + $subArray = isset($this->json[$key]) ? $this->json[$key] : null; $result[$name] = $this->recurse($param, $subArray); } else { // top-level `array` or an empty name diff --git a/tests/ResponseLocation/JsonLocationTest.php b/tests/ResponseLocation/JsonLocationTest.php index caa1c3cc..52a44a8d 100644 --- a/tests/ResponseLocation/JsonLocationTest.php +++ b/tests/ResponseLocation/JsonLocationTest.php @@ -35,6 +35,50 @@ public function testVisitsLocation() $result = $location->visit($result, $response, $parameter); $this->assertEquals('BAR', $result['val']); } + /** + * @group ResponseLocation + * @param $name + * @param $expected + */ + public function testVisitsWiredArray() + { + $json = ['car_models' => ['ferrari', 'aston martin']]; + $body = \GuzzleHttp\json_encode($json); + $response = new Response(200, ['Content-Type' => 'application/json'], $body); + $mock = new MockHandler([$response]); + + $guzzle = new Client(['handler' => $mock]); + + $description = new Description([ + 'operations' => [ + 'getCars' => [ + 'uri' => 'http://httpbin.org', + 'httpMethod' => 'GET', + 'responseModel' => 'Cars' + ] + ], + 'models' => [ + 'Cars' => [ + 'type' => 'object', + 'location' => 'json', + 'properties' => [ + 'cars' => [ + 'type' => 'array', + 'sentAs' => 'car_models', + 'items' => [ + 'type' => 'object', + ] + ] + ], + ] + ] + ]); + + $guzzle = new GuzzleClient($guzzle, $description); + $result = $guzzle->getCars(); + + $this->assertEquals(['cars' => ['ferrari', 'aston martin']], $result->toArray()); + } /** * @group ResponseLocation From 9b7365edf59795e11b915b0b4961e8867ebfe434 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Fri, 6 Oct 2017 16:29:34 +0200 Subject: [PATCH 05/13] Update Changelog --- CHANGELOG.md | 151 ++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 148 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 62e98d9d..5754bcee 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,71 +1,115 @@ # Change Log +## [Unreleased](https://github.com/guzzle/guzzle-services/tree/HEAD) + +[Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.1.2...HEAD) + +**Closed issues:** + +- Parameter type configuration causes issue when filters change input type [\#147](https://github.com/guzzle/guzzle-services/issues/147) + +**Merged pull requests:** + +- Use wire name when visiting array [\#152](https://github.com/guzzle/guzzle-services/pull/152) ([my2ter](https://github.com/my2ter)) + +- Adding descriptive error message on parameter failure [\#144](https://github.com/guzzle/guzzle-services/pull/144) ([igorsantos07](https://github.com/igorsantos07)) + ## [1.1.2](https://github.com/guzzle/guzzle-services/tree/1.1.2) (2017-05-19) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.1.1...1.1.2) **Closed issues:** -- Operations extends is broken in 1.1.1 [\#145](https://github.com/guzzle/guzzle-services/issues/145) - Default values ignored in 1.1 [\#146](https://github.com/guzzle/guzzle-services/issues/146) +- Operations extends is broken in 1.1.1 [\#145](https://github.com/guzzle/guzzle-services/issues/145) + ## [1.1.1](https://github.com/guzzle/guzzle-services/tree/1.1.1) (2017-05-15) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.1.0...1.1.1) **Closed issues:** - Filters are applied twice [\#134](https://github.com/guzzle/guzzle-services/issues/134) + - Is it possible to NOT urlencode a specific uri parameter value? [\#97](https://github.com/guzzle/guzzle-services/issues/97) **Merged pull requests:** - Fix minor typos in documentation. [\#139](https://github.com/guzzle/guzzle-services/pull/139) ([forevermatt](https://github.com/forevermatt)) + - Do not mutate command at validation [\#135](https://github.com/guzzle/guzzle-services/pull/135) ([danizord](https://github.com/danizord)) + - Added tests for JSON array of arrays and array of objects [\#131](https://github.com/guzzle/guzzle-services/pull/131) ([selfcatering](https://github.com/selfcatering)) +- Allow filters on response model [\#138](https://github.com/guzzle/guzzle-services/pull/138) ([danizord](https://github.com/danizord)) + +- Exposing properties to a parent class [\#136](https://github.com/guzzle/guzzle-services/pull/136) ([Napas](https://github.com/Napas)) + ## [1.1.0](https://github.com/guzzle/guzzle-services/tree/1.1.0) (2017-01-31) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.0.1...1.1.0) **Closed issues:** - Grab a list of objects when they are not located at top level of a json response \(HATEOAS\) [\#90](https://github.com/guzzle/guzzle-services/issues/90) + - Regression of Issue \#51 - XmlLocation response not handling multiple tags of the same name correctly [\#82](https://github.com/guzzle/guzzle-services/issues/82) + - PUT requests with parameters with location of "postField" result in Exception [\#78](https://github.com/guzzle/guzzle-services/issues/78) + - Allow to provide Post Body as an Array [\#77](https://github.com/guzzle/guzzle-services/issues/77) **Merged pull requests:** - Bring more flexibility to query params serialization [\#132](https://github.com/guzzle/guzzle-services/pull/132) ([bakura10](https://github.com/bakura10)) + - Allow to fix validation for parameters with a format [\#130](https://github.com/guzzle/guzzle-services/pull/130) ([bakura10](https://github.com/bakura10)) ## [1.0.1](https://github.com/guzzle/guzzle-services/tree/1.0.1) (2017-01-13) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.0.0...1.0.1) **Implemented enhancements:** -- guzzle 6 [\#89](https://github.com/guzzle/guzzle-services/issues/89) - Set a name when pushing ValidatedDescriptionHandler to stack [\#127](https://github.com/guzzle/guzzle-services/issues/127) **Fixed bugs:** - combine method in Uri [\#101](https://github.com/guzzle/guzzle-services/issues/101) + - Undefined Variable [\#88](https://github.com/guzzle/guzzle-services/issues/88) + - Regression in array parameter serialization [\#128](https://github.com/guzzle/guzzle-services/issues/128) + - Unable to POST multiple multipart parameters [\#123](https://github.com/guzzle/guzzle-services/issues/123) -- Fix serialization of query params [\#129](https://github.com/guzzle/guzzle-services/pull/129) ([bakura10](https://github.com/bakura10)) **Closed issues:** - Tag pre 1.0.0 release [\#121](https://github.com/guzzle/guzzle-services/issues/121) + - Adjust inline documentation of Parameter [\#120](https://github.com/guzzle/guzzle-services/issues/120) + - postField location not recognized after upgrading to 1.0 [\#119](https://github.com/guzzle/guzzle-services/issues/119) + - Create a new release for the guzzle6 branch [\#118](https://github.com/guzzle/guzzle-services/issues/118) + - Compatibility problem with PHP7.0 ? [\#116](https://github.com/guzzle/guzzle-services/issues/116) + - What is the correct type of Parameter static option [\#113](https://github.com/guzzle/guzzle-services/issues/113) + - Improve the construction of baseUri in Description [\#112](https://github.com/guzzle/guzzle-services/issues/112) + - Please create version tag for current master branch [\#110](https://github.com/guzzle/guzzle-services/issues/110) + - Problems with postField params [\#98](https://github.com/guzzle/guzzle-services/issues/98) +**Merged pull requests:** + +- Fix serialization of query params [\#129](https://github.com/guzzle/guzzle-services/pull/129) ([bakura10](https://github.com/bakura10)) + ## [1.0.0](https://github.com/guzzle/guzzle-services/tree/1.0.0) (2016-11-24) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/0.6.0...1.0.0) **Closed issues:** @@ -77,53 +121,99 @@ - Make Guzzle Services compatible with Guzzle6 [\#109](https://github.com/guzzle/guzzle-services/pull/109) ([Konafets](https://github.com/Konafets)) ## [0.6.0](https://github.com/guzzle/guzzle-services/tree/0.6.0) (2016-10-21) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/0.5.0...0.6.0) **Closed issues:** - Broken composer install [\#111](https://github.com/guzzle/guzzle-services/issues/111) + - The visit\(\) method is expected to return a RequestInterface but it doesn't in JsonLocation [\#106](https://github.com/guzzle/guzzle-services/issues/106) + - Allow parameters in baseUrl [\#102](https://github.com/guzzle/guzzle-services/issues/102) + - Have default params at client construction, gone away? [\#100](https://github.com/guzzle/guzzle-services/issues/100) + - Runtime Exception Error is always empty [\#99](https://github.com/guzzle/guzzle-services/issues/99) + - PHP Fatal error: Unsupported operand types in guzzlehttp/guzzle-services/src/GuzzleClient.php on line 72 [\#95](https://github.com/guzzle/guzzle-services/issues/95) + - Date of next version [\#94](https://github.com/guzzle/guzzle-services/issues/94) + - Map null reponse values to defined reponse model properties [\#91](https://github.com/guzzle/guzzle-services/issues/91) + - Map a json-array into a Model [\#80](https://github.com/guzzle/guzzle-services/issues/80) + - If property specified in json model but empty, notice raised [\#75](https://github.com/guzzle/guzzle-services/issues/75) + - Allow primitive response types for operations [\#73](https://github.com/guzzle/guzzle-services/issues/73) + - Allow shortened definition of properties in models [\#71](https://github.com/guzzle/guzzle-services/issues/71) + - Where's the ServiceDescriptionLoader/AbstractConfigLoader? [\#68](https://github.com/guzzle/guzzle-services/issues/68) + - errorResposnes from operation is never used [\#66](https://github.com/guzzle/guzzle-services/issues/66) + - Updating the description [\#65](https://github.com/guzzle/guzzle-services/issues/65) + - Parameter type validation is too strict [\#7](https://github.com/guzzle/guzzle-services/issues/7) **Merged pull requests:** - fix code example [\#115](https://github.com/guzzle/guzzle-services/pull/115) ([snoek09](https://github.com/snoek09)) + - Bug Fix for GuzzleClient constructor [\#96](https://github.com/guzzle/guzzle-services/pull/96) ([peterfox](https://github.com/peterfox)) + - add plugin section to readme [\#93](https://github.com/guzzle/guzzle-services/pull/93) ([gimler](https://github.com/gimler)) + - Allow mapping null response values to defined response model properties [\#92](https://github.com/guzzle/guzzle-services/pull/92) ([shaun785](https://github.com/shaun785)) + - Updated exception message for better debugging [\#85](https://github.com/guzzle/guzzle-services/pull/85) ([stovak](https://github.com/stovak)) + - Gracefully handle null return from $this-\>getConfig\('defaults'\) [\#84](https://github.com/guzzle/guzzle-services/pull/84) ([fuhry](https://github.com/fuhry)) + - Fixing issue \#82 to address regression for handling elements with the sa... [\#83](https://github.com/guzzle/guzzle-services/pull/83) ([sprak3000](https://github.com/sprak3000)) + - Fix for specified property but no value in json \(notice for undefined in... [\#76](https://github.com/guzzle/guzzle-services/pull/76) ([rfink](https://github.com/rfink)) + - Add ErrorHandler subscriber [\#67](https://github.com/guzzle/guzzle-services/pull/67) ([bakura10](https://github.com/bakura10)) +- Fix combine base url and command uri [\#108](https://github.com/guzzle/guzzle-services/pull/108) ([vlastv](https://github.com/vlastv)) + +- Fixing JsonLocation::visit\(\) not returning a request \#106 [\#107](https://github.com/guzzle/guzzle-services/pull/107) ([Pinolo](https://github.com/Pinolo)) + +- Fix call to undefined method "GuzzleHttp\Psr7\Uri::combine" [\#105](https://github.com/guzzle/guzzle-services/pull/105) ([horrorin](https://github.com/horrorin)) + +- fix description for get request example [\#87](https://github.com/guzzle/guzzle-services/pull/87) ([snoek09](https://github.com/snoek09)) + +- Allow raw values \(non array/object\) for root model definitions [\#74](https://github.com/guzzle/guzzle-services/pull/74) ([rfink](https://github.com/rfink)) + +- Allow shortened definition of properties by assigning them directly to a type [\#72](https://github.com/guzzle/guzzle-services/pull/72) ([rfink](https://github.com/rfink)) + ## [0.5.0](https://github.com/guzzle/guzzle-services/tree/0.5.0) (2014-12-23) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/0.4.0...0.5.0) **Closed issues:** - Does it supports custom class instantiate to define an operation using a service description [\#62](https://github.com/guzzle/guzzle-services/issues/62) + - Tag version 0.4.0 [\#61](https://github.com/guzzle/guzzle-services/issues/61) + - XmlLocation not adding attributes to non-leaf child nodes [\#52](https://github.com/guzzle/guzzle-services/issues/52) + - XmlLocation response not handling multiple tags of the same name correctly [\#51](https://github.com/guzzle/guzzle-services/issues/51) + - Validation Bug [\#47](https://github.com/guzzle/guzzle-services/issues/47) + - CommandException doesn't contain response data [\#44](https://github.com/guzzle/guzzle-services/issues/44) + - \[Fix included\] XmlLocation requires text value to have attributes [\#37](https://github.com/guzzle/guzzle-services/issues/37) + - Question: Mocking a Response does not throw exception [\#35](https://github.com/guzzle/guzzle-services/issues/35) + - allow default 'location' on Model [\#26](https://github.com/guzzle/guzzle-services/issues/26) + - create mock subscriber requests from descriptions [\#25](https://github.com/guzzle/guzzle-services/issues/25) **Merged pull requests:** @@ -131,76 +221,131 @@ - Documentation: Add 'boolean-string' as a supported "format" value [\#63](https://github.com/guzzle/guzzle-services/pull/63) ([jwcobb](https://github.com/jwcobb)) ## [0.4.0](https://github.com/guzzle/guzzle-services/tree/0.4.0) (2014-11-03) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/0.3.0...0.4.0) **Closed issues:** - Exceptions Thrown From Subscribers Are Ignored? [\#58](https://github.com/guzzle/guzzle-services/issues/58) + - Totally Broken With Guzzle 5 [\#57](https://github.com/guzzle/guzzle-services/issues/57) + - GuzzleHTTP/Command Dependency fail [\#50](https://github.com/guzzle/guzzle-services/issues/50) + - Request parameter PathLocation [\#46](https://github.com/guzzle/guzzle-services/issues/46) + - Requesting a new version tag [\#45](https://github.com/guzzle/guzzle-services/issues/45) + - CommandException expects second parameter to be CommandTransaction instance [\#43](https://github.com/guzzle/guzzle-services/issues/43) + - Cannot add Autorization header to my requests [\#39](https://github.com/guzzle/guzzle-services/issues/39) + - Resouce Itterators [\#36](https://github.com/guzzle/guzzle-services/issues/36) + - Question [\#33](https://github.com/guzzle/guzzle-services/issues/33) + - query location array can be comma separated [\#31](https://github.com/guzzle/guzzle-services/issues/31) + - Automatically returns array from command? [\#30](https://github.com/guzzle/guzzle-services/issues/30) + - Arrays nested under objects in JSON response broken? [\#27](https://github.com/guzzle/guzzle-services/issues/27) + - Question? [\#23](https://github.com/guzzle/guzzle-services/issues/23) **Merged pull requests:** - Bump the version in the readme [\#60](https://github.com/guzzle/guzzle-services/pull/60) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - Bump the next version to 0.4 [\#56](https://github.com/guzzle/guzzle-services/pull/56) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - Fixed the guzzlehttp/command version constraint [\#55](https://github.com/guzzle/guzzle-services/pull/55) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - Work with latest Guzzle 5 and Command updates [\#54](https://github.com/guzzle/guzzle-services/pull/54) ([mtdowling](https://github.com/mtdowling)) + - Addressing Issue \#51 & Issue \#52 [\#53](https://github.com/guzzle/guzzle-services/pull/53) ([sprak3000](https://github.com/sprak3000)) + - added description interface to extend it [\#49](https://github.com/guzzle/guzzle-services/pull/49) ([danieledangeli](https://github.com/danieledangeli)) + - Update readme to improve documentation \(\#46\) [\#48](https://github.com/guzzle/guzzle-services/pull/48) ([bonndan](https://github.com/bonndan)) + - Fixed the readme version constraint [\#42](https://github.com/guzzle/guzzle-services/pull/42) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - Update .travis.yml [\#41](https://github.com/guzzle/guzzle-services/pull/41) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - Added a branch alias [\#40](https://github.com/guzzle/guzzle-services/pull/40) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - Fixes Response\XmlLocation requires text value [\#38](https://github.com/guzzle/guzzle-services/pull/38) ([magnetik](https://github.com/magnetik)) + - Removing unnecessary \(\) from docblock [\#32](https://github.com/guzzle/guzzle-services/pull/32) ([jamiehannaford](https://github.com/jamiehannaford)) + - Fix JSON response location so that both is supported: arrays nested unde... [\#28](https://github.com/guzzle/guzzle-services/pull/28) ([ukautz](https://github.com/ukautz)) +- Throw Any Exceptions On Process [\#59](https://github.com/guzzle/guzzle-services/pull/59) ([GrahamCampbell](https://github.com/GrahamCampbell)) + +- Allow extension to work recursively over models [\#34](https://github.com/guzzle/guzzle-services/pull/34) ([jamiehannaford](https://github.com/jamiehannaford)) + +- A custom class can be configured for command instances. [\#29](https://github.com/guzzle/guzzle-services/pull/29) ([robinvdvleuten](https://github.com/robinvdvleuten)) + +- \[WIP\] doing some experimentation [\#24](https://github.com/guzzle/guzzle-services/pull/24) ([cordoval](https://github.com/cordoval)) + ## [0.3.0](https://github.com/guzzle/guzzle-services/tree/0.3.0) (2014-06-01) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/0.2.0...0.3.0) **Closed issues:** - Testing Guzzle Services doesn't work [\#19](https://github.com/guzzle/guzzle-services/issues/19) + - Description factory [\#18](https://github.com/guzzle/guzzle-services/issues/18) + - support to load service description from file [\#15](https://github.com/guzzle/guzzle-services/issues/15) + - Update dependency on guzzlehttp/command [\#11](https://github.com/guzzle/guzzle-services/issues/11) **Merged pull requests:** - Add license file [\#22](https://github.com/guzzle/guzzle-services/pull/22) ([siwinski](https://github.com/siwinski)) + - Fix 'Invalid argument supplied for foreach\(\)' [\#21](https://github.com/guzzle/guzzle-services/pull/21) ([Olden](https://github.com/Olden)) + - Fixed string zero \('0'\) values not being filtered in XML. [\#20](https://github.com/guzzle/guzzle-services/pull/20) ([dragonwize](https://github.com/dragonwize)) +- baseUrl can be a string or an uri template [\#16](https://github.com/guzzle/guzzle-services/pull/16) ([robinvdvleuten](https://github.com/robinvdvleuten)) + ## [0.2.0](https://github.com/guzzle/guzzle-services/tree/0.2.0) (2014-03-30) + [Full Changelog](https://github.com/guzzle/guzzle-services/compare/0.1.0...0.2.0) **Closed issues:** - please remove wiki [\#13](https://github.com/guzzle/guzzle-services/issues/13) + - Parameter validation fails for union types [\#12](https://github.com/guzzle/guzzle-services/issues/12) + - question on integration with Guzzle4 [\#8](https://github.com/guzzle/guzzle-services/issues/8) + - typehints for operations property [\#6](https://github.com/guzzle/guzzle-services/issues/6) + - improve exception message [\#5](https://github.com/guzzle/guzzle-services/issues/5) **Merged pull requests:** - Update composer.json [\#14](https://github.com/guzzle/guzzle-services/pull/14) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - Update composer.json [\#9](https://github.com/guzzle/guzzle-services/pull/9) ([GrahamCampbell](https://github.com/GrahamCampbell)) + - some fixes [\#4](https://github.com/guzzle/guzzle-services/pull/4) ([cordoval](https://github.com/cordoval)) + - Fix the CommandException path used in ValidateInput [\#2](https://github.com/guzzle/guzzle-services/pull/2) ([mookle](https://github.com/mookle)) + - Minor improvements [\#1](https://github.com/guzzle/guzzle-services/pull/1) ([GrahamCampbell](https://github.com/GrahamCampbell)) +- Use latest guzzlehttp/command to fix dependencies [\#10](https://github.com/guzzle/guzzle-services/pull/10) ([sbward](https://github.com/sbward)) + +- some collaboration using Gush :\) [\#3](https://github.com/guzzle/guzzle-services/pull/3) ([cordoval](https://github.com/cordoval)) + ## [0.1.0](https://github.com/guzzle/guzzle-services/tree/0.1.0) (2014-03-15) + \* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file From b6e861663baa8bd89a5669fe847f9725890adb92 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Fri, 6 Oct 2017 16:31:25 +0200 Subject: [PATCH 06/13] Update changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5754bcee..f02629dc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,6 @@ # Change Log -## [Unreleased](https://github.com/guzzle/guzzle-services/tree/HEAD) +## [1.1.3](https://github.com/guzzle/guzzle-services/tree/1.1.3) (2017-10-06) [Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.1.2...HEAD) From e7c61ac16b919691b9f13628d2442529abd9ab41 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Tue, 21 Nov 2017 11:56:22 +0100 Subject: [PATCH 07/13] Fix the "weird" equal not operator Closes #154 --- CHANGELOG.md | 4 ++++ src/GuzzleClient.php | 4 ++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index f02629dc..bef9f0bc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Change Log +**Closed issues:** + +- Fix weird "equal equal not" operator [\#154](https://github.com/guzzle/guzzle-services/issues/154) + ## [1.1.3](https://github.com/guzzle/guzzle-services/tree/1.1.3) (2017-10-06) [Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.1.2...HEAD) diff --git a/src/GuzzleClient.php b/src/GuzzleClient.php index f419b54e..fa656a3c 100644 --- a/src/GuzzleClient.php +++ b/src/GuzzleClient.php @@ -99,7 +99,7 @@ public function getDescription() */ private function getSerializer($commandToRequestTransformer) { - return $commandToRequestTransformer ==! null + return $commandToRequestTransformer !== null ? $commandToRequestTransformer : new Serializer($this->description); } @@ -114,7 +114,7 @@ private function getDeserializer($responseToResultTransformer) { $process = (! isset($this->config['process']) || $this->config['process'] === true); - return $responseToResultTransformer ==! null + return $responseToResultTransformer !== null ? $responseToResultTransformer : new Deserializer($this->description, $process); } From d7acd7ab013e61a7e9a9519c3578978c16f82f54 Mon Sep 17 00:00:00 2001 From: Levente Peter Date: Sun, 8 Nov 2020 19:16:32 +0200 Subject: [PATCH 08/13] Guzzle 7 support --- composer.json | 9 ++-- phpunit.xml.dist | 12 +++--- src/Serializer.php | 8 ++-- tests/DescriptionTest.php | 18 +++----- tests/DeserializerTest.php | 32 ++++++-------- tests/GuzzleClientTest.php | 43 ++++++++----------- .../ValidatedDescriptionHandlerTest.php | 15 +++---- tests/OperationTest.php | 11 +++-- tests/ParameterTest.php | 31 ++++++------- .../QuerySerializer/Rfc3986SerializerTest.php | 3 +- tests/RequestLocation/BodyLocationTest.php | 3 +- .../RequestLocation/FormParamLocationTest.php | 5 ++- tests/RequestLocation/HeaderLocationTest.php | 7 +-- tests/RequestLocation/JsonLocationTest.php | 5 ++- .../RequestLocation/MultiPartLocationTest.php | 3 +- tests/RequestLocation/QueryLocationTest.php | 3 +- tests/RequestLocation/XmlLocationTest.php | 13 +++--- tests/ResponseLocation/BodyLocationTest.php | 3 +- tests/ResponseLocation/HeaderLocationTest.php | 3 +- tests/ResponseLocation/JsonLocationTest.php | 3 +- .../ReasonPhraseLocationTest.php | 3 +- .../StatusCodeLocationTest.php | 3 +- tests/ResponseLocation/XmlLocationTest.php | 3 +- tests/SchemaFormatterTest.php | 9 ++-- tests/SchemaValidatorTest.php | 7 +-- tests/SerializerTest.php | 3 +- 26 files changed, 125 insertions(+), 133 deletions(-) diff --git a/composer.json b/composer.json index 645e44b2..96aae3bb 100644 --- a/composer.json +++ b/composer.json @@ -21,12 +21,13 @@ } ], "require": { - "php": ">=5.5", - "guzzlehttp/guzzle": "^6.2", - "guzzlehttp/command": "~1.0" + "php": ">=7.1", + "guzzlehttp/guzzle": "^7.0", + "guzzlehttp/command": "dev-master", + "guzzlehttp/uri-template": "^0.2.0" }, "require-dev": { - "phpunit/phpunit": "~4.0" + "phpunit/phpunit": "~9.0" }, "autoload": { "psr-4": { diff --git a/phpunit.xml.dist b/phpunit.xml.dist index 994e1584..a1860399 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -2,13 +2,13 @@ - + tests - - - src - - + + + ./app + + diff --git a/src/Serializer.php b/src/Serializer.php index 160fbc25..4f1b5aad 100644 --- a/src/Serializer.php +++ b/src/Serializer.php @@ -12,6 +12,8 @@ use GuzzleHttp\Command\Guzzle\RequestLocation\XmlLocation; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Uri; +use GuzzleHttp\Psr7\UriResolver; +use GuzzleHttp\UriTemplate\UriTemplate; use Psr\Http\Message\RequestInterface; /** @@ -154,11 +156,11 @@ private function createCommandWithUri( } // Expand the URI template. - $uri = \GuzzleHttp\uri_template($operation->getUri(), $variables); + $uri = new Uri(UriTemplate::expand($operation->getUri(), $variables)); return new Request( - $operation->getHttpMethod(), - Uri::resolve($this->description->getBaseUri(), $uri) + $operation->getHttpMethod() ?: 'GET', + UriResolver::resolve($this->description->getBaseUri(), $uri) ); } } diff --git a/tests/DescriptionTest.php b/tests/DescriptionTest.php index 9f73cf3d..764dfc0e 100644 --- a/tests/DescriptionTest.php +++ b/tests/DescriptionTest.php @@ -5,15 +5,17 @@ use GuzzleHttp\Command\Guzzle\Operation; use GuzzleHttp\Command\Guzzle\Parameter; use GuzzleHttp\Command\Guzzle\SchemaFormatter; +use InvalidArgumentException; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\Description */ -class DescriptionTest extends \PHPUnit_Framework_TestCase +class DescriptionTest extends TestCase { protected $operations; - public function setup() + public function setup(): void { $this->operations = [ 'test_command' => [ @@ -65,11 +67,9 @@ public function testCanUseResponseClass() $this->assertNotNull($op->getResponseModel()); } - /** - * @expectedException \InvalidArgumentException - */ public function testRetrievingMissingModelThrowsException() { + $this->expectException(InvalidArgumentException::class); $d = new Description([]); $d->getModel('foo'); } @@ -105,20 +105,16 @@ public function testPersistsCustomAttributes() $this->assertNull($d->getData('missing')); } - /** - * @expectedException \InvalidArgumentException - */ public function testThrowsExceptionForMissingOperation() { + $this->expectException(InvalidArgumentException::class); $s = new Description([]); $this->assertNull($s->getOperation('foo')); } - /** - * @expectedException \InvalidArgumentException - */ public function testValidatesOperationTypes() { + $this->expectException(InvalidArgumentException::class); new Description([ 'operations' => ['foo' => new \stdClass()] ]); diff --git a/tests/DeserializerTest.php b/tests/DeserializerTest.php index a44f9802..554b59bd 100644 --- a/tests/DeserializerTest.php +++ b/tests/DeserializerTest.php @@ -3,6 +3,7 @@ use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Command\CommandInterface; +use GuzzleHttp\Command\Exception\CommandException; use GuzzleHttp\Command\Guzzle\Description; use GuzzleHttp\Command\Guzzle\DescriptionInterface; use GuzzleHttp\Command\Guzzle\GuzzleClient; @@ -13,20 +14,21 @@ use GuzzleHttp\Psr7\Response; use GuzzleHttp\Tests\Command\Guzzle\Asset\Exception\CustomCommandException; use GuzzleHttp\Tests\Command\Guzzle\Asset\Exception\OtherCustomCommandException; -use Predis\Response\ResponseInterface; +use PHPUnit\Framework\MockObject\MockBuilder; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\Deserializer */ -class DeserializerTest extends \PHPUnit_Framework_TestCase +class DeserializerTest extends TestCase { - /** @var ServiceClientInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var ServiceClientInterface|MockBuilder */ private $serviceClient; - /** @var CommandInterface|\PHPUnit_Framework_MockObject_MockObject */ + /** @var CommandInterface|MockBuilder */ private $command; - public function setUp() + public function setUp(): void { $this->serviceClient = $this->getMockBuilder(GuzzleClient::class) ->disableOriginalConstructor() @@ -80,11 +82,9 @@ public function testDoNothingIfNoException() $client->foo(['bar' => 'baz']); } - /** - * @expectedException \GuzzleHttp\Tests\Command\Guzzle\Asset\Exception\CustomCommandException - */ public function testCreateExceptionWithCode() { + $this->expectException(CustomCommandException::class); $response = new Response(404); $mock = new MockHandler([$response]); @@ -165,11 +165,9 @@ public function testNotCreateExceptionIfDoesNotMatchCode() $client->foo(['bar' => 'baz']); } - /** - * @expectedException \GuzzleHttp\Tests\Command\Guzzle\Asset\Exception\CustomCommandException - */ public function testCreateExceptionWithExactMatchOfReasonPhrase() { + $this->expectException(CustomCommandException::class); $response = new Response(404, [], null, '1.1', 'Bar'); $mock = new MockHandler([$response]); @@ -209,11 +207,9 @@ public function testCreateExceptionWithExactMatchOfReasonPhrase() $client->foo(['bar' => 'baz']); } - /** - * @expectedException \GuzzleHttp\Tests\Command\Guzzle\Asset\Exception\OtherCustomCommandException - */ public function testFavourMostPreciseMatch() { + $this->expectException(OtherCustomCommandException::class); $response = new Response(404, [], null, '1.1', 'Bar'); $mock = new MockHandler([$response]); @@ -254,12 +250,10 @@ public function testFavourMostPreciseMatch() $client->foo(['bar' => 'baz']); } - /** - * @expectedException \GuzzleHttp\Command\Exception\CommandException - * @expectedExceptionMessage 404 - */ public function testDoesNotAddResultWhenExceptionIsPresent() { + $this->expectExceptionMessage("404"); + $this->expectException(CommandException::class); $description = new Description([ 'operations' => [ 'foo' => [ @@ -381,6 +375,6 @@ public function testReturnsExpectedResult() 'content' => 'OK' ] ]; - $this->assertArraySubset($expected, $result['LoginResponse']); + $this->assertEquals($expected, $result['LoginResponse']); } } diff --git a/tests/GuzzleClientTest.php b/tests/GuzzleClientTest.php index 0e5c9d9c..4355fb3d 100644 --- a/tests/GuzzleClientTest.php +++ b/tests/GuzzleClientTest.php @@ -10,13 +10,14 @@ use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; use Psr\Http\Message\RequestInterface; use Psr\Http\Message\ResponseInterface; /** * @covers \GuzzleHttp\Command\Guzzle\GuzzleClient */ -class GuzzleClientTest extends \PHPUnit_Framework_TestCase +class GuzzleClientTest extends TestCase { public function testExecuteCommandViaMagicMethod() { @@ -179,8 +180,8 @@ public function testExecuteWithMultiPartLocation() $client->doMultiPartLocation(['foo' => 'Foo']); $multiPartRequestBody = (string) $mock->getLastRequest()->getBody(); - $this->assertContains('name="foo"', $multiPartRequestBody); - $this->assertContains('Foo', $multiPartRequestBody); + $this->assertStringContainsString('name="foo"', $multiPartRequestBody); + $this->assertStringContainsString('Foo', $multiPartRequestBody); $client->doMultiPartLocation([ 'foo' => 'Foo', @@ -189,20 +190,20 @@ public function testExecuteWithMultiPartLocation() ]); $multiPartRequestBody = (string) $mock->getLastRequest()->getBody(); - $this->assertContains('name="foo"', $multiPartRequestBody); - $this->assertContains('Foo', $multiPartRequestBody); - $this->assertContains('name="bar"', $multiPartRequestBody); - $this->assertContains('Bar', $multiPartRequestBody); - $this->assertContains('name="baz"', $multiPartRequestBody); - $this->assertContains('Baz', $multiPartRequestBody); + $this->assertStringContainsString('name="foo"', $multiPartRequestBody); + $this->assertStringContainsString('Foo', $multiPartRequestBody); + $this->assertStringContainsString('name="bar"', $multiPartRequestBody); + $this->assertStringContainsString('Bar', $multiPartRequestBody); + $this->assertStringContainsString('name="baz"', $multiPartRequestBody); + $this->assertStringContainsString('Baz', $multiPartRequestBody); $client->doMultiPartLocation([ 'file' => fopen(dirname(__FILE__) . '/Asset/test.html', 'r'), ]); $multiPartRequestBody = (string) $mock->getLastRequest()->getBody(); - $this->assertContains('name="file"', $multiPartRequestBody); - $this->assertContains('filename="test.html"', $multiPartRequestBody); - $this->assertContains('Title', $multiPartRequestBody); + $this->assertStringContainsString('name="file"', $multiPartRequestBody); + $this->assertStringContainsString('filename="test.html"', $multiPartRequestBody); + $this->assertStringContainsString('Title', $multiPartRequestBody); } public function testHasConfig() @@ -342,12 +343,10 @@ public function testValidateDescription() $this->assertEquals(200, $response->getStatusCode()); } - /** - * @expectedException \GuzzleHttp\Command\Exception\CommandException - * @expectedExceptionMessage Validation errors: [baz] is a required string: baz - */ public function testValidateDescriptionFailsDueMissingRequiredParameter() { + $this->expectExceptionMessage("Validation errors: [baz] is a required string: baz"); + $this->expectException(\GuzzleHttp\Command\Exception\CommandException::class); $client = new HttpClient(); $description = new Description( [ @@ -421,12 +420,10 @@ public function testValidateDescriptionFailsDueMissingRequiredParameter() $this->assertEquals(200, $result['statusCode']); } - /** - * @expectedException \GuzzleHttp\Command\Exception\CommandException - * @expectedExceptionMessage Validation errors: [baz] must be of type integer - */ public function testValidateDescriptionFailsDueTypeMismatch() { + $this->expectExceptionMessage("Validation errors: [baz] must be of type integer"); + $this->expectException(\GuzzleHttp\Command\Exception\CommandException::class); $client = new HttpClient(); $description = new Description( [ @@ -635,12 +632,10 @@ public function testMagicMethodExecutesCommands() $this->assertEquals('foo', $guzzle->foo([])); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage No operation found named Foo - */ public function testThrowsWhenOperationNotFoundInDescription() { + $this->expectExceptionMessage("No operation found named Foo"); + $this->expectException(\InvalidArgumentException::class); $client = new HttpClient(); $description = new Description([]); $guzzle = new GuzzleClient( diff --git a/tests/Handler/ValidatedDescriptionHandlerTest.php b/tests/Handler/ValidatedDescriptionHandlerTest.php index f02396c5..c76e36f3 100644 --- a/tests/Handler/ValidatedDescriptionHandlerTest.php +++ b/tests/Handler/ValidatedDescriptionHandlerTest.php @@ -4,19 +4,18 @@ use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Command\Guzzle\Description; use GuzzleHttp\Command\Guzzle\GuzzleClient; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\Handler\ValidatedDescriptionHandler */ -class ValidatedDescriptionHandlerTest extends \PHPUnit_Framework_TestCase +class ValidatedDescriptionHandlerTest extends TestCase { - /** - * @expectedException \GuzzleHttp\Command\Exception\CommandException - * @expectedExceptionMessage Validation errors: [bar] is a required string - */ public function testValidates() { + $this->expectExceptionMessage("Validation errors: [bar] is a required string"); + $this->expectException(\GuzzleHttp\Command\Exception\CommandException::class); $description = new Description([ 'operations' => [ 'foo' => [ @@ -59,12 +58,10 @@ public function testSuccessfulValidationDoesNotThrow() $client->foo([]); } - /** - * @expectedException \GuzzleHttp\Command\Exception\CommandException - * @expectedExceptionMessage Validation errors: [bar] must be of type string - */ public function testValidatesAdditionalParameters() { + $this->expectExceptionMessage("Validation errors: [bar] must be of type string"); + $this->expectException(\GuzzleHttp\Command\Exception\CommandException::class); $description = new Description([ 'operations' => [ 'foo' => [ diff --git a/tests/OperationTest.php b/tests/OperationTest.php index 04313dd7..f8a12c84 100644 --- a/tests/OperationTest.php +++ b/tests/OperationTest.php @@ -1,13 +1,14 @@ assertEquals(['foo' => 'baz', 'bar' => 123], $o->getData()); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMesssage Parameters must be arrays - */ public function testEnsuresParametersAreArrays() { + $this->expectExceptionMessage('Parameters must be arrays'); + $this->expectException(\InvalidArgumentException::class); new Operation(['parameters' => ['foo' => true]]); } diff --git a/tests/ParameterTest.php b/tests/ParameterTest.php index 7bc937f3..80301959 100644 --- a/tests/ParameterTest.php +++ b/tests/ParameterTest.php @@ -1,13 +1,14 @@ 'foo', @@ -39,11 +40,9 @@ public function testCreatesParamFromArray() $this->assertEquals('abc', $p->getName()); } - /** - * @expectedException \InvalidArgumentException - */ public function testValidatesDescription() { + $this->expectException(\InvalidArgumentException::class); new Parameter($this->data, ['description' => 'foo']); } @@ -97,12 +96,10 @@ public function testFiltersValues() $this->assertEquals('FOO', $p->filter('foo')); } - /** - * @expectedException \RuntimeException - * @expectedExceptionMessage No service description - */ public function testRequiresServiceDescriptionForFormatting() { + $this->expectExceptionMessage("No service description"); + $this->expectException(\RuntimeException::class); $d = $this->data; $d['format'] = 'foo'; $p = new Parameter($d); @@ -137,12 +134,10 @@ public function testParsesTypeValues() $this->assertEquals('foo', $p->getType()); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage A [method] value must be specified for each complex filter - */ public function testValidatesComplexFilters() { + $this->expectExceptionMessage("A [method] value must be specified for each complex filter"); + $this->expectException(\InvalidArgumentException::class); $p = new Parameter(['filters' => [['args' => 'foo']]]); } @@ -188,7 +183,7 @@ public function testAddsItems() $this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $p->getItems()); $out = $p->toArray(); $this->assertEquals('array', $out['type']); - $this->assertInternalType('array', $out['items']); + $this->assertIsArray($out['items']); } public function testCanRetrieveKnownPropertiesUsingDataMethod() @@ -332,7 +327,7 @@ public function testHasProperties() $this->assertNull($p->getProperty('wefwe')); $properties = $p->getProperties(); - $this->assertInternalType('array', $properties); + $this->assertIsArray($properties); foreach ($properties as $prop) { $this->assertInstanceOf('GuzzleHttp\\Command\\Guzzle\\Parameter', $prop); } @@ -340,12 +335,10 @@ public function testHasProperties() $this->assertEquals($data, $p->toArray()); } - /** - * @expectedException \InvalidArgumentException - * @expectedExceptionMessage Expected a string. Got: array - */ public function testThrowsWhenNotPassString() { + $this->expectExceptionMessage("Expected a string. Got: array"); + $this->expectException(\InvalidArgumentException::class); $emptyParam = new Parameter(); $this->assertFalse($emptyParam->has([])); $this->assertFalse($emptyParam->has(new \stdClass())); diff --git a/tests/QuerySerializer/Rfc3986SerializerTest.php b/tests/QuerySerializer/Rfc3986SerializerTest.php index 66ec75f2..0f50ab62 100644 --- a/tests/QuerySerializer/Rfc3986SerializerTest.php +++ b/tests/QuerySerializer/Rfc3986SerializerTest.php @@ -2,8 +2,9 @@ namespace GuzzleHttp\Tests\Command\Guzzle\QuerySerializer; use GuzzleHttp\Command\Guzzle\QuerySerializer\Rfc3986Serializer; +use PHPUnit\Framework\TestCase; -class Rfc3986SerializerTest extends \PHPUnit_Framework_TestCase +class Rfc3986SerializerTest extends TestCase { public function queryProvider() { diff --git a/tests/RequestLocation/BodyLocationTest.php b/tests/RequestLocation/BodyLocationTest.php index 2a6418e5..93c38aa9 100644 --- a/tests/RequestLocation/BodyLocationTest.php +++ b/tests/RequestLocation/BodyLocationTest.php @@ -5,11 +5,12 @@ use GuzzleHttp\Command\Guzzle\Parameter; use GuzzleHttp\Command\Guzzle\RequestLocation\BodyLocation; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\BodyLocation */ -class BodyLocationTest extends \PHPUnit_Framework_TestCase +class BodyLocationTest extends TestCase { /** * @group RequestLocation diff --git a/tests/RequestLocation/FormParamLocationTest.php b/tests/RequestLocation/FormParamLocationTest.php index 016ad6b8..34b13498 100644 --- a/tests/RequestLocation/FormParamLocationTest.php +++ b/tests/RequestLocation/FormParamLocationTest.php @@ -7,12 +7,13 @@ use GuzzleHttp\Command\Guzzle\RequestLocation\FormParamLocation; use GuzzleHttp\Command\Guzzle\RequestLocation\PostFieldLocation; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\FormParamLocation * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation */ -class FormParamLocationTest extends \PHPUnit_Framework_TestCase +class FormParamLocationTest extends TestCase { /** * @group RequestLocation @@ -27,7 +28,7 @@ public function testVisitsLocation() $operation = new Operation(); $request = $location->after($command, $request, $operation); $this->assertEquals('foo=bar', $request->getBody()->getContents()); - $this->assertArraySubset([0 => 'application/x-www-form-urlencoded; charset=utf-8'], $request->getHeader('Content-Type')); + $this->assertEquals([0 => 'application/x-www-form-urlencoded; charset=utf-8'], $request->getHeader('Content-Type')); } /** diff --git a/tests/RequestLocation/HeaderLocationTest.php b/tests/RequestLocation/HeaderLocationTest.php index 2ebc2835..ba29f515 100644 --- a/tests/RequestLocation/HeaderLocationTest.php +++ b/tests/RequestLocation/HeaderLocationTest.php @@ -6,12 +6,13 @@ use GuzzleHttp\Command\Guzzle\Parameter; use GuzzleHttp\Command\Guzzle\RequestLocation\HeaderLocation; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\HeaderLocation * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation */ -class HeaderLocationTest extends \PHPUnit_Framework_TestCase +class HeaderLocationTest extends TestCase { /** * @group RequestLocation @@ -26,7 +27,7 @@ public function testVisitsLocation() $header = $request->getHeader('foo'); $this->assertTrue(is_array($header)); - $this->assertArraySubset([0 => 'bar'], $request->getHeader('foo')); + $this->assertEquals([0 => 'bar'], $request->getHeader('foo')); } /** @@ -47,6 +48,6 @@ public function testAddsAdditionalProperties() $header = $request->getHeader('add'); $this->assertTrue(is_array($header)); - $this->assertArraySubset([0 => 'props'], $header); + $this->assertEquals([0 => 'props'], $header); } } diff --git a/tests/RequestLocation/JsonLocationTest.php b/tests/RequestLocation/JsonLocationTest.php index 359b7e29..b8cac3e2 100644 --- a/tests/RequestLocation/JsonLocationTest.php +++ b/tests/RequestLocation/JsonLocationTest.php @@ -6,12 +6,13 @@ use GuzzleHttp\Command\Guzzle\Parameter; use GuzzleHttp\Command\Guzzle\RequestLocation\JsonLocation; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\JsonLocation * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation */ -class JsonLocationTest extends \PHPUnit_Framework_TestCase +class JsonLocationTest extends TestCase { /** * @group RequestLocation @@ -26,7 +27,7 @@ public function testVisitsLocation() $operation = new Operation(); $request = $location->after($command, $request, $operation); $this->assertEquals('{"foo":"bar"}', $request->getBody()->getContents()); - $this->assertArraySubset([0 => 'application/json'], $request->getHeader('Content-Type')); + $this->assertEquals([0 => 'application/json'], $request->getHeader('Content-Type')); } /** diff --git a/tests/RequestLocation/MultiPartLocationTest.php b/tests/RequestLocation/MultiPartLocationTest.php index a2e7faf6..63cce9d1 100644 --- a/tests/RequestLocation/MultiPartLocationTest.php +++ b/tests/RequestLocation/MultiPartLocationTest.php @@ -7,11 +7,12 @@ use GuzzleHttp\Command\Guzzle\RequestLocation\MultiPartLocation; use GuzzleHttp\Command\Guzzle\RequestLocation\PostFileLocation; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\MultiPartLocation */ -class MultiPartLocationTest extends \PHPUnit_Framework_TestCase +class MultiPartLocationTest extends TestCase { /** * @group RequestLocation diff --git a/tests/RequestLocation/QueryLocationTest.php b/tests/RequestLocation/QueryLocationTest.php index 7ccfbd8a..4bf4b25d 100644 --- a/tests/RequestLocation/QueryLocationTest.php +++ b/tests/RequestLocation/QueryLocationTest.php @@ -7,12 +7,13 @@ use GuzzleHttp\Command\Guzzle\RequestLocation\QueryLocation; use GuzzleHttp\Psr7; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\QueryLocation * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\AbstractLocation */ -class QueryLocationTest extends \PHPUnit_Framework_TestCase +class QueryLocationTest extends TestCase { public function queryProvider() { diff --git a/tests/RequestLocation/XmlLocationTest.php b/tests/RequestLocation/XmlLocationTest.php index ce789d4e..26603585 100644 --- a/tests/RequestLocation/XmlLocationTest.php +++ b/tests/RequestLocation/XmlLocationTest.php @@ -13,11 +13,12 @@ use GuzzleHttp\Middleware; use GuzzleHttp\Psr7\Request; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\RequestLocation\XmlLocation */ -class XmlLocationTest extends \PHPUnit_Framework_TestCase +class XmlLocationTest extends TestCase { /** * @group RequestLocation @@ -39,7 +40,7 @@ public function testVisitsLocation() $this->assertEquals('' . "\n" . 'bartest' . "\n", $xml); $header = $request->getHeader('Content-Type'); - $this->assertArraySubset([0 => 'application/xml'], $header); + $this->assertEquals([0 => 'application/xml'], $header); } /** @@ -59,7 +60,7 @@ public function testCreatesBodyForEmptyDocument() . '' . "\n", $xml); $header = $request->getHeader('Content-Type'); - $this->assertArraySubset([0 => 'application/xml'], $header); + $this->assertEquals([0 => 'application/xml'], $header); } /** @@ -84,7 +85,7 @@ public function testAddsAdditionalParameters() $this->assertEquals('' . "\n" . 'barbarboo' . "\n", $xml); $header = $request->getHeader('Content-Type'); - $this->assertArraySubset([0 => 'test'], $header); + $this->assertEquals([0 => 'test'], $header); } /** @@ -512,10 +513,10 @@ public function testSerializesXml(array $operation, array $input, $xml) $request = $transaction['request']; if (empty($input)) { if ($request->hasHeader('Content-Type')) { - $this->assertArraySubset([0 => ''], $request->getHeader('Content-Type')); + $this->assertEquals([0 => ''], $request->getHeader('Content-Type')); } } else { - $this->assertArraySubset([0 => 'application/xml'], $request->getHeader('Content-Type')); + $this->assertEquals([0 => 'application/xml'], $request->getHeader('Content-Type')); } $body = str_replace(["\n", ""], '', (string) $request->getBody()); diff --git a/tests/ResponseLocation/BodyLocationTest.php b/tests/ResponseLocation/BodyLocationTest.php index 36eda588..eb76f296 100644 --- a/tests/ResponseLocation/BodyLocationTest.php +++ b/tests/ResponseLocation/BodyLocationTest.php @@ -5,12 +5,13 @@ use GuzzleHttp\Command\Guzzle\ResponseLocation\BodyLocation; use GuzzleHttp\Command\Result; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\BodyLocation * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation */ -class BodyLocationTest extends \PHPUnit_Framework_TestCase +class BodyLocationTest extends TestCase { /** * @group ResponseLocation diff --git a/tests/ResponseLocation/HeaderLocationTest.php b/tests/ResponseLocation/HeaderLocationTest.php index 763af38a..9677f64a 100644 --- a/tests/ResponseLocation/HeaderLocationTest.php +++ b/tests/ResponseLocation/HeaderLocationTest.php @@ -5,12 +5,13 @@ use GuzzleHttp\Command\Guzzle\ResponseLocation\HeaderLocation; use GuzzleHttp\Command\Result; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\HeaderLocation * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation */ -class HeaderLocationTest extends \PHPUnit_Framework_TestCase +class HeaderLocationTest extends TestCase { /** * @group ResponseLocation diff --git a/tests/ResponseLocation/JsonLocationTest.php b/tests/ResponseLocation/JsonLocationTest.php index 52a44a8d..5dc3d059 100644 --- a/tests/ResponseLocation/JsonLocationTest.php +++ b/tests/ResponseLocation/JsonLocationTest.php @@ -10,12 +10,13 @@ use GuzzleHttp\Command\ResultInterface; use GuzzleHttp\Handler\MockHandler; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\JsonLocation * @covers \GuzzleHttp\Command\Guzzle\Deserializer */ -class JsonLocationTest extends \PHPUnit_Framework_TestCase +class JsonLocationTest extends TestCase { /** diff --git a/tests/ResponseLocation/ReasonPhraseLocationTest.php b/tests/ResponseLocation/ReasonPhraseLocationTest.php index bfe77172..af9b293b 100644 --- a/tests/ResponseLocation/ReasonPhraseLocationTest.php +++ b/tests/ResponseLocation/ReasonPhraseLocationTest.php @@ -5,12 +5,13 @@ use GuzzleHttp\Command\Guzzle\ResponseLocation\ReasonPhraseLocation; use GuzzleHttp\Command\Result; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\ReasonPhraseLocation * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation */ -class ReasonPhraseLocationTest extends \PHPUnit_Framework_TestCase +class ReasonPhraseLocationTest extends TestCase { /** * @group ResponseLocation diff --git a/tests/ResponseLocation/StatusCodeLocationTest.php b/tests/ResponseLocation/StatusCodeLocationTest.php index 1946e62b..c1f2795d 100644 --- a/tests/ResponseLocation/StatusCodeLocationTest.php +++ b/tests/ResponseLocation/StatusCodeLocationTest.php @@ -5,12 +5,13 @@ use GuzzleHttp\Command\Guzzle\ResponseLocation\StatusCodeLocation; use GuzzleHttp\Command\Result; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\StatusCodeLocation * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\AbstractLocation */ -class StatusCodeLocationTest extends \PHPUnit_Framework_TestCase +class StatusCodeLocationTest extends TestCase { /** * @group ResponseLocation diff --git a/tests/ResponseLocation/XmlLocationTest.php b/tests/ResponseLocation/XmlLocationTest.php index 4e398ba9..366ac16f 100644 --- a/tests/ResponseLocation/XmlLocationTest.php +++ b/tests/ResponseLocation/XmlLocationTest.php @@ -5,11 +5,12 @@ use GuzzleHttp\Command\Guzzle\ResponseLocation\XmlLocation; use GuzzleHttp\Command\Result; use GuzzleHttp\Psr7\Response; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\ResponseLocation\XmlLocation */ -class XmlLocationTest extends \PHPUnit_Framework_TestCase +class XmlLocationTest extends TestCase { /** * @group ResponseLocation diff --git a/tests/SchemaFormatterTest.php b/tests/SchemaFormatterTest.php index a8e051ac..a6cb791e 100644 --- a/tests/SchemaFormatterTest.php +++ b/tests/SchemaFormatterTest.php @@ -2,11 +2,12 @@ namespace GuzzleHttp\Tests\Command\Guzzle; use GuzzleHttp\Command\Guzzle\SchemaFormatter; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\SchemaFormatter */ -class SchemaFormatterTest extends \PHPUnit_Framework_TestCase +class SchemaFormatterTest extends TestCase { public function dateTimeProvider() { @@ -42,11 +43,9 @@ public function testFilters($value, $format, $result) $this->assertEquals($result, (new SchemaFormatter)->format($format, $value)); } - /** - * @expectedException \InvalidArgumentException - */ public function testValidatesDateTimeInput() { + $this->expectException(\InvalidArgumentException::class); (new SchemaFormatter)->format('date-time', false); } @@ -55,6 +54,6 @@ public function testEnsuresTimestampsAreIntegers() $t = time(); $result = (new SchemaFormatter)->format('timestamp', $t); $this->assertSame($t, $result); - $this->assertInternalType('int', $result); + $this->assertIsInt($result); } } diff --git a/tests/SchemaValidatorTest.php b/tests/SchemaValidatorTest.php index 6db3d24c..c53062d3 100644 --- a/tests/SchemaValidatorTest.php +++ b/tests/SchemaValidatorTest.php @@ -4,16 +4,17 @@ use GuzzleHttp\Command\Guzzle\Parameter; use GuzzleHttp\Command\Guzzle\SchemaValidator; use GuzzleHttp\Command\ToArrayInterface; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\SchemaValidator */ -class SchemaValidatorTest extends \PHPUnit_Framework_TestCase +class SchemaValidatorTest extends TestCase { /** @var SchemaValidator */ protected $validator; - public function setUp() + public function setUp(): void { $this->validator = new SchemaValidator(); } @@ -65,7 +66,7 @@ public function testCorrectlyConvertsParametersToArrayWhenArraysArePresent() { $param = $this->getComplexParam(); $result = $param->toArray(); - $this->assertInternalType('array', $result['items']); + $this->assertIsArray($result['items']); $this->assertEquals('array', $result['type']); $this->assertInstanceOf('GuzzleHttp\Command\Guzzle\Parameter', $param->getItems()); } diff --git a/tests/SerializerTest.php b/tests/SerializerTest.php index 1d3a5a1e..1b0609fe 100644 --- a/tests/SerializerTest.php +++ b/tests/SerializerTest.php @@ -5,11 +5,12 @@ use GuzzleHttp\Command\Guzzle\Description; use GuzzleHttp\Command\Guzzle\Serializer; use GuzzleHttp\Psr7\Request; +use PHPUnit\Framework\TestCase; /** * @covers \GuzzleHttp\Command\Guzzle\Serializer */ -class SerializerTest extends \PHPUnit_Framework_TestCase +class SerializerTest extends TestCase { public function testAllowsUriTemplates() { From 57759d6ffd2000e61d6e8a057f8e74c7c2a88409 Mon Sep 17 00:00:00 2001 From: Levente Peter Date: Sun, 8 Nov 2020 19:30:16 +0200 Subject: [PATCH 09/13] Minimum php version fix --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 96aae3bb..8611bfbb 100644 --- a/composer.json +++ b/composer.json @@ -21,8 +21,8 @@ } ], "require": { - "php": ">=7.1", - "guzzlehttp/guzzle": "^7.0", + "php": ">=7.3", + "guzzlehttp/guzzle": "^7.0.1", "guzzlehttp/command": "dev-master", "guzzlehttp/uri-template": "^0.2.0" }, From 2543d8e324fb2042003e2102a817c1112abb76c6 Mon Sep 17 00:00:00 2001 From: Levente Peter Date: Sun, 8 Nov 2020 23:26:10 +0200 Subject: [PATCH 10/13] Update .travis.yml --- .travis.yml | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index e439fd54..fc936281 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,17 +2,14 @@ sudo: false language: php php: - - 5.5 - - 5.6 - - 7.0 - - 7.1 + - 7.3 + - 7.4 - hhvm - nightly matrix: fast_finish: true allow_failures: - - php: 7.1 - php: hhvm - php: nightly From 081002b90d9bb34d31bd6556219d0d7092340d74 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Fri, 13 Nov 2020 17:43:40 +0100 Subject: [PATCH 11/13] Remove HHVM from travis file --- .travis.yml | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/.travis.yml b/.travis.yml index fc936281..474a16bf 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,16 +1,17 @@ sudo: false + language: php +dist: trusty + php: - 7.3 - 7.4 - - hhvm - nightly matrix: fast_finish: true allow_failures: - - php: hhvm - php: nightly before_script: From 82cd9d9555a3b07f4ddd23766cb6bc1eab4e15da Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Fri, 13 Nov 2020 17:44:08 +0100 Subject: [PATCH 12/13] Use command 1.1.0 --- composer.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/composer.json b/composer.json index 8611bfbb..9eb533be 100644 --- a/composer.json +++ b/composer.json @@ -23,7 +23,7 @@ "require": { "php": ">=7.3", "guzzlehttp/guzzle": "^7.0.1", - "guzzlehttp/command": "dev-master", + "guzzlehttp/command": "^1.1.0", "guzzlehttp/uri-template": "^0.2.0" }, "require-dev": { From b3b9f3c58794cebdec45320f59ef6136aabb2697 Mon Sep 17 00:00:00 2001 From: Stefano Kowalke Date: Fri, 13 Nov 2020 23:12:52 +0100 Subject: [PATCH 13/13] Update Changelog --- CHANGELOG.md | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index bef9f0bc..48963d54 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,8 +1,16 @@ # Change Log +## [1.2.0](https://github.com/guzzle/guzzle-services/tree/1.2.0) (2020-11-13) + +[Full Changelog](https://github.com/guzzle/guzzle-services/compare/1.2.0...HEAD) + **Closed issues:** -- Fix weird "equal equal not" operator [\#154](https://github.com/guzzle/guzzle-services/issues/154) +- Fix weird "equal equal not" operator [\#154](https://github.com/guzzle/guzzle-services/issues/154) + +**Merged pull requests:** + +- Support Guzzle 7 [\#176](https://github.com/guzzle/guzzle-services/pull/176) ([ptlevi](https://github.com/ptlevi)) ## [1.1.3](https://github.com/guzzle/guzzle-services/tree/1.1.3) (2017-10-06) @@ -352,4 +360,4 @@ -\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)* \ No newline at end of file +\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*