/**
  * @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));
         }
     }
 }
 public function testReturnsApiData()
 {
     $s = new Service(['metadata' => ['serviceFullName' => 'foo', 'endpointPrefix' => 'bar', 'apiVersion' => 'baz', 'protocol' => 'yak']], function () {
         return [];
     });
     $this->assertEquals('foo', $s->getServiceFullName());
     $this->assertEquals('bar', $s->getEndpointPrefix());
     $this->assertEquals('baz', $s->getApiVersion());
     $this->assertEquals('yak', $s->getProtocol());
 }
 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']);
 }