コード例 #1
0
 /**
  * @dataProvider testCaseProvider
  */
 public function testPassesComplianceTest($about, Service $service, $name, array $args, $serialized)
 {
     $ep = 'http://dus-bb-api802.dus.via.de';
     $client = new VwsClient(['service' => 'foo', 'api_provider' => function () use($service) {
         return $service->toArray();
     }, 'credentials' => false, 'client' => new Client(), 'region' => 'sandbox', 'endpoint' => $ep, 'error_parser' => Service::createErrorParser($service->getProtocol()), 'serializer' => Service::createSerializer($service, $ep), 'version' => 'latest']);
     $command = $client->getCommand($name, $args);
     $trans = new CommandTransaction($client, $command);
     /** @var callable $serializer */
     $serializer = $this->readAttribute($client, 'serializer');
     $request = $serializer($trans);
     $this->assertEquals($serialized['uri'], $request->getResource());
     $body = (string) $request->getBody();
     switch ($service->getMetadata('type')) {
         case 'json':
         case 'rest-json':
             // Normalize the JSON data.
             $body = str_replace(':', ': ', $request->getBody());
             $body = str_replace(',', ', ', $body);
             break;
     }
     $this->assertEquals($serialized['body'], $body);
     if (isset($serialized['headers'])) {
         foreach ($serialized['headers'] as $key => $value) {
             $this->assertSame($value, $request->getHeader($key));
         }
     }
 }
コード例 #2
0
 public static function _apply_api_provider($value, array &$args)
 {
     $api = new Service(ApiProvider::resolve($value, 'api', $args['service'], $args['version']), $value);
     $args['api'] = $api;
     $args['error_parser'] = Service::createErrorParser($api->getProtocol());
     $args['serializer'] = Service::createSerializer($api, $args['endpoint']);
 }