getResponse() public method

Get Response definitions with Api endpoint
public getResponse ( string $path, string $method, integer $httpCode ) : DetailsResponse | ListResponse
$path string Api endpoint
$method string HTTP method
$httpCode integer HTTP code
return Scalr\Tests\Functional\Api\V2\SpecSchema\DataTypes\DetailsResponse | Scalr\Tests\Functional\Api\V2\SpecSchema\DataTypes\ListResponse
Example #1
0
 /**
  * Test for user Api endpoints
  * Data provider prepares data for Api request
  * UserSpec get responses definition from user specifications for each endpoint
  * ResponseBodyConstraint compares Api definition with request
  *
  * @param string $path Api endpoint
  * @param string $method HTTP method
  * @param int    $responseCode HTTP code
  * @param array  $params Array of path  parameters
  * @param array  $filterable Array of GET  parameters
  * @param array  $body Array of POST parameters
  * @param string $entityClass Entity class name
  * @test
  */
 public function testApiV2User($path = null, $method = null, $responseCode = null, $params = null, $filterable = null, $body = null, $entityClass = null)
 {
     $this->markTestSkipped('Fixtures don\'t implemented yet');
     $method = strtoupper($method);
     $params['envId'] = self::$testEnvId;
     $requestUrl = '/api/' . static::$apiVersion . '/user' . $this->matchApiUrl($path, $params);
     $response = $this->request($requestUrl, $method, $filterable, $body);
     $apiResp = static::$userSpec->getResponse($path, $method, $responseCode);
     // delete created object
     if (Request::METHOD_POST === $method && isset($response->getBody()->data)) {
         self::toDelete($entityClass, $response->getBody()->data->id);
     }
     if (Request::METHOD_GET === $method && 200 == $response) {
         $objects = $this->assertGetEndpoint($requestUrl, $apiResp);
         foreach ($objects as $object) {
             foreach ($filterable as $property) {
                 $filterValue = $object->{$property};
                 $this->assertGetEndpoint($requestUrl, $apiResp, [$property => $filterValue]);
             }
         }
     } else {
         $this->assertEquals($responseCode, $response->status, $this->printResponseError($response));
         $this->assertThat($response->getBody(), new ResponseBodyConstraint($apiResp));
     }
 }