/** * {@inheritdoc} * @see TestDataFixtures::prepareTestData() */ public function prepareTestData() { if (!empty($this->sets[static::TEST_DATA_COST_CENTERS])) { foreach ($this->sets[static::TEST_DATA_COST_CENTERS] as &$ccData) { $ccData['accountId'] = self::$user->getAccountId(); $ccData['envId'] = self::$env->id; /* @var $cc CostCentreEntity */ $cc = ApiV2Test::createEntity(new CostCentreEntity(), $ccData, 2); $cc->saveProperty(CostCentrePropertyEntity::NAME_BILLING_CODE, $ccData['billingCode']); $cc->save(); $ccData['id'] = $cc->ccId; ApiV2Test::createEntity(new AccountCostCenterEntity(), ['ccId' => $ccData['id'], 'accountId' => $ccData['accountId']], 1); // to delete Cost Center properties ApiV2Test::toDelete(CostCentrePropertyEntity::class, [$cc->ccId, $cc->getProperty(CostCentrePropertyEntity::NAME_BILLING_CODE)]); } } }
/** * {@inheritdoc} * @see TestDataFixtures::prepareTestData() */ public function prepareTestData() { if (!empty($this->sets[static::TEST_DATA_PROJECTS])) { $ccId = Scalr_Environment::init()->loadById(static::$env->id)->getPlatformConfigValue(Scalr_Environment::SETTING_CC_ID); foreach ($this->sets[static::TEST_DATA_PROJECTS] as &$projectData) { $projectData['envId'] = self::$env->id; $projectData['accountId'] = self::$user->getAccountId(); $projectData['createdById'] = self::$user->id; $projectData['createdByEmail'] = self::$user->email; $projectData['ccId'] = $ccId; /* @var $project ProjectEntity */ $project = ApiV2Test::createEntity(new ProjectEntity(), $projectData); $project->setCostCenter(\Scalr::getContainer()->analytics->ccs->get($projectData['ccId'])); $project->saveProperty(ProjectPropertyEntity::NAME_BILLING_CODE, $projectData['name']); $project->save(); $projectData['projectId'] = $project->projectId; // to Delete project Properties ApiV2Test::toDelete(ProjectPropertyEntity::class, [$project->projectId, $project->getProperty(ProjectPropertyEntity::NAME_BILLING_CODE)]); } } }