[ 'foo' => [ 'uri' => 'http://httpbin.org', 'httpMethod' => 'GET', 'responseModel' => 'j', 'parameters' => [ 'bar' => [ 'type' => 'string', 'required' => true ] ] ] ] ]); $client = new GuzzleClient(new HttpClient(), $description); $client->foo([]); } public function testSuccessfulValidationDoesNotThrow() { $description = new Description([ 'operations' => [ 'foo' => [ 'uri' => 'http://httpbin.org', 'httpMethod' => 'GET', 'responseModel' => 'j', 'parameters' => [] ] ], 'models' => [ 'j' => [ 'type' => 'object' ] ] ]); $client = new GuzzleClient(new HttpClient(), $description); $client->foo([]); } /** * @expectedException \GuzzleHttp\Command\Exception\CommandException * @expectedExceptionMessage Validation errors: [bar] must be of type string */ public function testValidatesAdditionalParameters() { $description = new Description([ 'operations' => [ 'foo' => [ 'uri' => 'http://httpbin.org', 'httpMethod' => 'GET', 'responseModel' => 'j', 'additionalParameters' => [ 'type' => 'string' ] ] ], 'models' => [ 'j' => [ 'type' => 'object' ] ] ]); $client = new GuzzleClient(new HttpClient(), $description); $client->foo(['bar' => new \stdClass()]); } public function testFilterBeforeValidate() { $description = new Description([ 'operations' => [ 'foo' => [ 'uri' => 'http://httpbin.org', 'httpMethod' => 'GET', 'parameters' => [ 'bar' => [ 'location' => 'uri', 'type' => 'string', 'format' => 'date-time', 'required' => true ] ] ] ] ]); $client = new GuzzleClient(new HttpClient(), $description); $client->foo(['bar' => new \DateTimeImmutable()]); // Should not throw any exception } }