PHP Класс Scalr\Tests\Functional\Api\V2\ApiTest

С версии: 5.11 (03.12.2015)
Автор: Andrii Penchuk ([email protected])
Наследование: extends Scalr\Tests\Functional\Api\ApiTestCase
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$accountSpec Scalr\Tests\Functional\Api\V2\SpecSchema\SpecManager Object generated of Account Api specifications
$adapters Scalr\Api\DataType\ApiEntityAdapter[] List of adapters using in test
$checkScope array Object where should check scope
$data array Test data container for testGetEndpoint()
$dbObjectMapping array Mapping api object name and specific which gives an entity this object Key is object name Value is functions name
$defaultAcl Scalr\Acl\Acl Default test Acl
$filterPropertyMap array Map filterable properties key based on object name in Api definitions
$fullAccessAcl Scalr\Tests\Fixtures\Api\V2\Acl\ApiTestAcl
$ignoreCheckRules array List of objects where should ignore check filterable properties
$maxResults false | integer Max response results
$noAccessAcl PHPUnit_Framework_MockObject_MockObject
$paramMap array Mapping params in path definitions and response objects
$pathMap array Map save structure if object need other data structure key based on object name in Api definitions
$propertyAssertMap array Mapping specifics assert for properties Key is property name Value is functions name
$readOnlyAccessAcl Scalr\Tests\Fixtures\Api\V2\Acl\ApiTestAcl
$simpleFilterRules
$testData array Ids of data generated during the test Destructor clean up data by these ids
$testUserType string Default user type
$userSpec Scalr\Tests\Functional\Api\V2\SpecSchema\SpecManager Object generated of User Api specifications

Открытые методы

Метод Описание
__construct ( $name = null, $data = [], $dataName = null )
assertBuiltinAutomation ( array $filterValue, array $property, string $message ) Custom assert BuiltinAutomation property
assertFilterableProperties ( string $url, ListResponse $apiResp, string $saveDataPath = null ) Assert and check unique filterable properties from requested url
assertGetEndpoint ( string $uri, ListResponse $apiResp, array $filters = [], boolean $collect = true, null | integer $maxResults = null ) : array Return list of Objects available in this account or environment
assertTeams ( object $team, object[] $teams, string $message ) Reports an error if specified team is not present in the list of teams of the Farm obtained by filtration
checkAdapterRules ( ObjectEntity $objectEntity, array $rules ) Check adapter rules
dataApiProvider ( ) : array Data provider for testApi()
dataGetEndpointProvider ( ) : array[] Data provider for testGetEndpoint()
getAdapter ( string $class, ApiController $controller = null ) : ApiEntityAdapter Gets API entity adapter
getEnvironmentEntity ( integer $envId ) : Environment Gets Environment entity
getFilter ( string $class = null, string $property = null, array $values = [] ) : FilterRule Makes the filtering rule for the specified properties of an object
getFixturesDirectory ( )
getGlobalVariable ( string $criteria, array $params ) : array Get GV
setUpBeforeClass ( ) Add test environment, test Acl, setups test user, environment and API key
tearDownAfterClass ( ) Removes API key generated for test
testApi ( string $path, string | Exceptio\Exception $type, string $adapter, string $aclType, string $userType, string $method, integer $responseCode, array $params, array $filterable, array $body ) Test for Api endpoints Data provider prepares data for Api request SpecFile get responses definition from api specifications for each endpoint ResponseBodyConstraint compares Api definition with request
testGetEndpoint ( string $path, string $type ) Test for base user and account Api GET endpoints

Защищенные методы

Метод Описание
getDbObject ( string $objectName, string $criteria, string $entityClass, array $params ) : mixed Get db object
getEnvironmentTeam ( string $criteria, array $params ) : TeamEnvs Gets TeamEnvs entity
getFarmRoleScalingMetrics ( string $criteria, array $params = [] ) : FarmRoleScalingMetric Get FarmRoleScalingMetric entity
getScalingMetric ( string $criteria ) : ScalingMetric Get ScalingMetric entity
getScriptVersion ( string $criteria, array $params ) : Scalr\Model\Entity\ScriptVersion Gets ScriptVersion entity
mapApiResponsePk ( string $path, string $objectName ) : string On the based api endpoint and name api object return primary key If pk don't exist in paramMath throw fail
mapPath ( string $path, string $type ) : Generator Generate url with api endpoint and saved data
matchApiUrl ( string $path, array $params = [] ) : string Match API url params
saveUrlData ( string $url, stdClass $object, string $nameEntity ) Save data for x-usedIn endpoints
setTestAcl ( string $acl ) Set mock acl for test
setUp ( )
setUserType ( string $type ) Set user types for test Some endpoints need extra credentials
tearDown ( )

Описание методов

__construct() публичный Метод

См. также: ApiTestCase::setUpBeforeClass()
public __construct ( $name = null, $data = [], $dataName = null )

assertBuiltinAutomation() публичный Метод

Custom assert BuiltinAutomation property
public assertBuiltinAutomation ( array $filterValue, array $property, string $message )
$filterValue array Filter value property
$property array Object property
$message string Assert message

assertFilterableProperties() публичный Метод

Assert and check unique filterable properties from requested url
public assertFilterableProperties ( string $url, ListResponse $apiResp, string $saveDataPath = null )
$url string Request uri
$apiResp Scalr\Tests\Functional\Api\V2\SpecSchema\DataTypes\ListResponse Schema current object generated of api specification
$saveDataPath string Save url for child endpoints

assertGetEndpoint() публичный Метод

Return list of Objects available in this account or environment
public assertGetEndpoint ( string $uri, ListResponse $apiResp, array $filters = [], boolean $collect = true, null | integer $maxResults = null ) : array
$uri string Request uri
$apiResp Scalr\Tests\Functional\Api\V2\SpecSchema\DataTypes\ListResponse schema current object generated of api specification
$filters array optional Filterable properties
$collect boolean optional Collect response data
$maxResults null | integer optional max list results
Результат array

assertTeams() публичный Метод

Reports an error if specified team is not present in the list of teams of the Farm obtained by filtration
public assertTeams ( object $team, object[] $teams, string $message )
$team object Filter value
$teams object[] Filtering property of the object obtained by filtration
$message string optional Message in case of error

checkAdapterRules() публичный Метод

Check adapter rules
public checkAdapterRules ( ObjectEntity $objectEntity, array $rules )
$objectEntity Scalr\Tests\Functional\Api\V2\SpecSchema\DataTypes\ObjectEntity api object entity generated form specs
$rules array list of rules

dataApiProvider() публичный Метод

Data provider for testApi()
public dataApiProvider ( ) : array
Результат array

dataGetEndpointProvider() публичный Метод

Data provider for testGetEndpoint()
public dataGetEndpointProvider ( ) : array[]
Результат array[]

getAdapter() публичный Метод

Gets API entity adapter
public getAdapter ( string $class, ApiController $controller = null ) : ApiEntityAdapter
$class string Adapter class
$controller Scalr\Api\Rest\Controller\ApiController optional API Controller
Результат Scalr\Api\DataType\ApiEntityAdapter

getDbObject() защищенный Метод

Get db object
protected getDbObject ( string $objectName, string $criteria, string $entityClass, array $params ) : mixed
$objectName string api object name
$criteria string search criteria
$entityClass string
$params array array params
Результат mixed

getEnvironmentEntity() публичный Метод

Gets Environment entity
public getEnvironmentEntity ( integer $envId ) : Environment
$envId integer environment identifier
Результат Scalr\Model\Entity\Account\Environment

getEnvironmentTeam() защищенный Метод

Gets TeamEnvs entity
protected getEnvironmentTeam ( string $criteria, array $params ) : TeamEnvs
$criteria string search criteria
$params array query params
Результат Scalr\Model\Entity\Account\TeamEnvs

getFarmRoleScalingMetrics() защищенный Метод

Get FarmRoleScalingMetric entity
protected getFarmRoleScalingMetrics ( string $criteria, array $params = [] ) : FarmRoleScalingMetric
$criteria string search criteria
$params array optional query params
Результат Scalr\Model\Entity\FarmRoleScalingMetric

getFilter() публичный Метод

Makes the filtering rule for the specified properties of an object
public getFilter ( string $class = null, string $property = null, array $values = [] ) : FilterRule
$class string optional The object name
$property string optional The property name
$values array optional The array of filter values
Результат Scalr\Tests\Functional\Api\V2\Iterator\FilterRule

getFixturesDirectory() публичный Метод

См. также: TestCase::getFixturesDirectory()

getGlobalVariable() публичный Метод

Get GV
public getGlobalVariable ( string $criteria, array $params ) : array
$criteria string search criteria
$params array query params
Результат array

getScalingMetric() защищенный Метод

Get ScalingMetric entity
protected getScalingMetric ( string $criteria ) : ScalingMetric
$criteria string search criteria
Результат Scalr\Model\Entity\ScalingMetric

getScriptVersion() защищенный Метод

Gets ScriptVersion entity
protected getScriptVersion ( string $criteria, array $params ) : Scalr\Model\Entity\ScriptVersion
$criteria string search criteria
$params array query params
Результат Scalr\Model\Entity\ScriptVersion

mapApiResponsePk() защищенный Метод

On the based api endpoint and name api object return primary key If pk don't exist in paramMath throw fail
protected mapApiResponsePk ( string $path, string $objectName ) : string
$path string Api endpoint
$objectName string Name object entity from specification
Результат string

mapPath() защищенный Метод

Generate url with api endpoint and saved data
protected mapPath ( string $path, string $type ) : Generator
$path string api endpoint
$type string api specifications type
Результат Generator

matchApiUrl() защищенный Метод

Match API url params
protected matchApiUrl ( string $path, array $params = [] ) : string
$path string Api endpoint
$params array path parameters
Результат string

saveUrlData() защищенный Метод

Save data for x-usedIn endpoints
protected saveUrlData ( string $url, stdClass $object, string $nameEntity )
$url string api url
$object stdClass api object
$nameEntity string name api entity

setTestAcl() защищенный Метод

Set mock acl for test
protected setTestAcl ( string $acl )
$acl string Acl type for tests

setUp() защищенный Метод

См. также: ApiTestCase::setUp()
protected setUp ( )

setUpBeforeClass() публичный статический Метод

Add test environment, test Acl, setups test user, environment and API key
public static setUpBeforeClass ( )

setUserType() защищенный Метод

Set user types for test Some endpoints need extra credentials
protected setUserType ( string $type )
$type string User type

tearDown() защищенный Метод

См. также: ApiTestCase::tearDown()
protected tearDown ( )

tearDownAfterClass() публичный статический Метод

Removes API key generated for test
public static tearDownAfterClass ( )

testApi() публичный Метод

Test for Api endpoints Data provider prepares data for Api request SpecFile get responses definition from api specifications for each endpoint ResponseBodyConstraint compares Api definition with request
public testApi ( string $path, string | Exceptio\Exception $type, string $adapter, string $aclType, string $userType, string $method, integer $responseCode, array $params, array $filterable, array $body )
$path string Api endpoint
$type string | Exceptio\Exception Api specifications type
$adapter string Adapter name
$aclType string Acl type for test
$userType string UserType for test
$method string HTTP method
$responseCode integer HTTP code
$params array Array of path parameters
$filterable array Array of GET parameters
$body array Array of POST parameters

testGetEndpoint() публичный Метод

Test for base user and account Api GET endpoints
public testGetEndpoint ( string $path, string $type )
$path string path from api specifications
$type string api specifications type

Описание свойств

$accountSpec защищенное статическое свойство

Object generated of Account Api specifications
protected static SpecManager,Scalr\Tests\Functional\Api\V2\SpecSchema $accountSpec
Результат Scalr\Tests\Functional\Api\V2\SpecSchema\SpecManager

$adapters защищенное статическое свойство

List of adapters using in test
protected static ApiEntityAdapter[],Scalr\Api\DataType $adapters
Результат Scalr\Api\DataType\ApiEntityAdapter[]

$checkScope защищенное свойство

Object where should check scope
protected array $checkScope
Результат array

$data защищенное статическое свойство

Test data container for testGetEndpoint()
protected static array $data
Результат array

$dbObjectMapping защищенное свойство

Mapping api object name and specific which gives an entity this object Key is object name Value is functions name
protected array $dbObjectMapping
Результат array

$defaultAcl защищенное статическое свойство

Default test Acl
protected static Acl,Scalr\Acl $defaultAcl
Результат Scalr\Acl\Acl

$filterPropertyMap защищенное свойство

Map filterable properties key based on object name in Api definitions
protected array $filterPropertyMap
Результат array

$fullAccessAcl защищенное статическое свойство

protected static ApiTestAcl,Scalr\Tests\Fixtures\Api\V2\Acl $fullAccessAcl
Результат Scalr\Tests\Fixtures\Api\V2\Acl\ApiTestAcl

$ignoreCheckRules защищенное свойство

List of objects where should ignore check filterable properties
protected array $ignoreCheckRules
Результат array

$maxResults защищенное статическое свойство

Max response results
protected static false|int $maxResults
Результат false | integer

$noAccessAcl защищенное статическое свойство

protected static PHPUnit_Framework_MockObject_MockObject $noAccessAcl
Результат PHPUnit_Framework_MockObject_MockObject

$paramMap защищенное свойство

Mapping params in path definitions and response objects
protected array $paramMap
Результат array

$pathMap защищенное свойство

Map save structure if object need other data structure key based on object name in Api definitions
protected array $pathMap
Результат array

$propertyAssertMap защищенное свойство

Mapping specifics assert for properties Key is property name Value is functions name
protected array $propertyAssertMap
Результат array

$readOnlyAccessAcl защищенное статическое свойство

protected static ApiTestAcl,Scalr\Tests\Fixtures\Api\V2\Acl $readOnlyAccessAcl
Результат Scalr\Tests\Fixtures\Api\V2\Acl\ApiTestAcl

$simpleFilterRules защищенное свойство

protected $simpleFilterRules

$testData защищенное статическое свойство

Ids of data generated during the test Destructor clean up data by these ids
protected static array $testData
Результат array

$testUserType защищенное статическое свойство

Default user type
protected static string $testUserType
Результат string

$userSpec защищенное статическое свойство

Object generated of User Api specifications
protected static SpecManager,Scalr\Tests\Functional\Api\V2\SpecSchema $userSpec
Результат Scalr\Tests\Functional\Api\V2\SpecSchema\SpecManager