/** * {@inheritdoc} * @see ApiFixture::prepareTestData() */ public function prepareTestData() { if (!empty($this->sets[static::TEST_DATA_ROLE])) { $this->prepareData(static::TEST_DATA_ROLE); $this->prepareRole(static::TEST_DATA_ROLE); } if (!empty($this->sets[static::TEST_DATA_ROLE_IMAGE])) { $this->prepareData(static::TEST_DATA_ROLE_IMAGE); $this->prepareRoleImage(static::TEST_DATA_ROLE_IMAGE); } if (!empty($this->sets[static::TEST_DATA_FARM])) { $this->prepareFarm(static::TEST_DATA_FARM); } if (!empty($this->sets[static::TEST_DATA_FARM_ROLE])) { $this->prepareData(static::TEST_DATA_FARM_ROLE); $this->prepareFarmRole(static::TEST_DATA_FARM_ROLE); } if (!empty($this->sets[static::TEST_DATA_ACCOUNT_GV])) { foreach ($this->sets[static::TEST_DATA_ACCOUNT_GV] as &$gvData) { if (empty($gvData['accountId'])) { $gvData['accountId'] = static::$user->getAccountId(); } ApiTest::createEntity(new AccountGlobalVariable(), $gvData); } } $this->prepareData(static::TEST_DATA); $this->prepareData(static::TEST_DATA_PARAMS); }
/** * {@inheritdoc} * @see ApiFixture::prepareTestData() */ public function prepareTestData() { $this->prepareData(static::TEST_DATA_CUSTOM_METRIC); $this->createMetricsEntity(); if (!empty($this->sets[static::TEST_DATA_FARM_ROLE])) { $this->prepareFarmRole(static::TEST_DATA_FARM_ROLE); } if (isset($this->sets[static::FARM_ROLE_SCALING_METRIC_DATA])) { $this->prepareData(static::FARM_ROLE_SCALING_METRIC_DATA); foreach ($this->sets[static::FARM_ROLE_SCALING_METRIC_DATA] as $farmRoleScaling) { ApiTest::createEntity(new Entity\FarmRoleScalingMetric(), $farmRoleScaling); } } $this->prepareData(static::TEST_DATA); }
/** * {@inheritdoc} * @see ApiFixture::prepareTestData() */ public function prepareTestData() { if (isset($this->sets[static::TEST_DATA_ACL_ROLE])) { foreach ($this->sets[static::TEST_DATA_ACL_ROLE] as &$aclRoleData) { $aclRoleData['accountId'] = static::$user->getAccountId(); /* @var $aclRole AclRole */ $aclRole = ApiTest::createEntity(new AclRole(), $aclRoleData); $aclRoleData['accountRoleId'] = $aclRole->accountRoleId; } } if (isset($this->sets[static::TEST_DATA_ACCOUNT_TEAM])) { $this->prepareData(static::TEST_DATA_ACCOUNT_TEAM); $this->prepareAccountTeam(static::TEST_DATA_ACCOUNT_TEAM); } $this->prepareData(static::TEST_DATA); }
/** * {@inheritdoc} * @see ApiFixture::prepareTestData() */ public function prepareTestData() { if (!empty($this->sets[static::TEST_DATA_EVENT_DEFINITIONS])) { foreach ($this->sets[static::TEST_DATA_EVENT_DEFINITIONS] as &$eventDefinitionData) { $eventDefinitionData['envId'] = static::$testEnvId; $eventDefinitionData['accountId'] = static::$user->getAccountId(); /* @var $eventDefinition Entity\EventDefinition */ $eventDefinition = ApiTest::createEntity(new Entity\EventDefinition(), $eventDefinitionData); $eventDefinitionData['id'] = $eventDefinition->id; } } if (!empty($this->sets[static::TEST_DATA_ROLE_CATEGORIES])) { foreach ($this->sets[static::TEST_DATA_ROLE_CATEGORIES] as &$roleCategoryData) { $roleCategoryData['envId'] = static::$testEnvId; $roleCategoryData['accountId'] = static::$user->getAccountId(); /* @var $roleCategory Entity\RoleCategory */ $roleCategory = ApiTest::createEntity(new Entity\RoleCategory(), $roleCategoryData); $roleCategoryData['id'] = $roleCategory->id; } } if (!empty($this->sets[static::TEST_DATA_SCRIPTS])) { $this->prepareScript(static::TEST_DATA_SCRIPTS); } $this->prepareData(static::TEST_DATA_ROLES); if (!empty($this->sets[static::TEST_DATA_ROLES])) { foreach ($this->sets[static::TEST_DATA_ROLES] as &$roleData) { $roleData['envId'] = static::$testEnvId; $roleData['accountId'] = static::$user->getAccountId(); /* @var $role Entity\Role */ $role = ApiTest::createEntity(new Entity\Role(), $roleData); $roleData['id'] = $role->id; } } $this->prepareData(static::TEST_DATA_ROLE_SCRIPTS); if (!empty($this->sets[static::TEST_DATA_ROLE_SCRIPTS])) { foreach ($this->sets[static::TEST_DATA_ROLE_SCRIPTS] as &$roleScriptData) { /* @var $roleScript Entity\RoleScript */ $roleScript = ApiTest::createEntity(new Entity\RoleScript(), $roleScriptData); $roleScriptData['id'] = $roleScript->id; } } $this->prepareData(static::TEST_DATA); }
/** * {@inheritdoc} * @see ApiFixture::prepareTestData() */ public function prepareTestData() { if (!empty($this->sets[static::TEST_DATA_ROLE])) { $this->prepareData(static::TEST_DATA_ROLE); $this->prepareRole(static::TEST_DATA_ROLE); } if (!empty($this->sets[static::TEST_DATA_ROLE_IMAGE])) { $this->prepareData(static::TEST_DATA_ROLE_IMAGE); $this->prepareRoleImage(static::TEST_DATA_ROLE_IMAGE); } if (!empty($this->sets[static::TEST_DATA_FARM])) { $this->prepareFarm(static::TEST_DATA_FARM); } if (!empty($this->sets[static::TEST_DATA_FARM_ROLE])) { $this->prepareData(static::TEST_DATA_FARM_ROLE); $this->prepareFarmRole(static::TEST_DATA_FARM_ROLE); } if (!empty(static::TEST_DATA_SERVERS)) { $this->prepareData(static::TEST_DATA_SERVERS); foreach ($this->sets[static::TEST_DATA_SERVERS] as &$serverData) { $serverData['envId'] = static::$testEnvId; $serverData['accountId'] = static::$user->getAccountId(); $serverData['added'] = new DateTime('now'); /* @var $server Entity\Server() */ $server = new Entity\Server(); $serverData['properties'][Entity\Server::LAUNCHED_BY_EMAIL] = static::$user->getEmail(); foreach ($serverData['properties'] as $name => $value) { $server->properties[$name] = $value; //to delete server properties ApiTest::toDelete(Entity\ServerProperty::class, [$serverData['serverId'], $name]); } unset($serverData['properties']); $server = ApiTest::createEntity($server, $serverData); $serverData['id'] = $server->id; } } $this->prepareData(static::TEST_DATA); }
/** * Creates and save scaling metrics entity to DB */ protected function createMetricsEntity() { if (!empty($this->sets[static::TEST_DATA_CUSTOM_METRIC])) { foreach ($this->sets[static::TEST_DATA_CUSTOM_METRIC] as &$cmData) { $cmData['envId'] = static::$testEnvId; $cmData['accountId'] = static::$user->getAccountId(); /* @var $cm Entity\ScalingMetric */ $cm = ApiTest::createEntity(new Entity\ScalingMetric(), $cmData); $cmData['id'] = $cm->id; } } }
/** * Validates an object * * @param stdClass $element object properties * @param AbstractSpecObject $schema schema this object generated of api specification */ protected function checkObject($element, $schema) { if (isset($schema->sample)) { $this->checkSample($element, $schema->sample); return; } if (isset($schema->discriminator)) { $discriminator = $schema->discriminator; if (!property_exists($element, $discriminator)) { $propName = $schema->getObjectName(); if (isset(static::$ignoreDiscriminatorValues[$propName]) && $discriminator == static::$ignoreDiscriminatorValues[$propName]) { ApiTest::markTestIncomplete(sprintf('%s unexpected discriminator value', $discriminator)); } else { $this->appendError($discriminator, ' unexpected discriminator value'); } return; } $schema = $this->getConcreteTypes($schema, $element->{$discriminator}); if (!$schema) { $this->appendError($element->{$discriminator}, ' unexpected concrete type value'); } unset($schema->discriminator); $this->check($element, $schema); return; } $properties = $schema instanceof ApiEntity ? $schema->getProperties() : (array) $schema; foreach ($element as $p => $value) { if (isset($properties[$p])) { $this->check($value, $properties[$p]); } else { $this->appendError($p, "this property don't exist in Api specifications"); } } return; }
/** * Creates and save Account Team entities with data from fixtures * * @param string $name Account Team data name */ protected function prepareAccountTeam($name) { foreach ($this->sets[$name] as &$accTeamData) { $accTeamData['accountId'] = static::$user->getAccountId(); /* @var $accTeam Account\Team() */ $accTeam = ApiTest::createEntity(new Account\Team(), $accTeamData); $accTeamData['id'] = $accTeam->id; } }
/** * {@inheritdoc} * @see ApiFixture::prepareTestData() */ public function prepareTestData() { if (isset($this->sets[static::TEST_DATA_COST_CENTER])) { $this->prepareCostCenter(static::TEST_DATA_COST_CENTER); } if (isset($this->sets[static::TEST_DATA_ACCOUNT_COST_CENTER])) { $this->prepareData(static::TEST_DATA_ACCOUNT_COST_CENTER); $this->prepareAccountCostCenter(static::TEST_DATA_ACCOUNT_COST_CENTER); } if (isset($this->sets[static::TEST_DATA_ENVIRONMENT])) { $this->prepareData(static::TEST_DATA_ENVIRONMENT_PROPERTY); $this->prepareData(static::TEST_DATA_ENVIRONMENT); foreach ($this->sets[static::TEST_DATA_ENVIRONMENT] as &$envData) { $envData['accountId'] = static::$user->getAccountId(); /* @var $environment Account\Environment() */ $environment = new Account\Environment(); if (isset($envData['properties'])) { foreach ($envData['properties'] as $property => $value) { $environment->setProperty($property, $value); } unset($envData['properties']); } $environment = ApiTest::createEntity($environment, $envData, ['accountId']); $envData['id'] = $environment->id; } } if (isset($this->sets[static::TEST_DATA_ACCOUNT_TEAM])) { $this->prepareAccountTeam(static::TEST_DATA_ACCOUNT_TEAM); } if (isset($this->sets[static::TEST_DATA_ACCOUNT_TEAM_ENV])) { $this->prepareData(static::TEST_DATA_ACCOUNT_TEAM_ENV); foreach ($this->sets[static::TEST_DATA_ACCOUNT_TEAM_ENV] as $teamEnvData) { ApiTest::createEntity(new Account\TeamEnvs(), $teamEnvData); } } if (isset($this->sets[static::TEST_DATA_ACCOUNT_TEAM_USERS])) { $this->prepareData(static::TEST_DATA_ACCOUNT_TEAM_USERS); foreach ($this->sets[static::TEST_DATA_ACCOUNT_TEAM_USERS] as &$teamUserData) { $teamUserData['userId'] = static::$testUserId; ApiTest::createEntity(new Account\TeamUser(), $teamUserData); } } if (isset($this->sets[static::TEST_DATA_FARM])) { $this->prepareFarm(static::TEST_DATA_FARM); } $this->prepareData(static::TEST_DATA); }