Fix build service test - mock environment store

This commit is contained in:
Stepan Strelets 2017-03-26 01:02:27 +03:00 committed by Dmitry Khomutov
commit 1cef8260e9
No known key found for this signature in database
GPG key ID: 7EB36C9576F9ECB9
2 changed files with 49 additions and 6 deletions

View file

@ -771,6 +771,16 @@ class Project extends Model
return $icon;
}
/**
* @return EnvironmentStore
*/
protected function getEnvironmentStore()
{
/** @var EnvironmentStore $store */
$store = Factory::getStore('Environment', 'PHPCensor');
return $store;
}
/**
* Get Environments
*
@ -788,8 +798,7 @@ class Project extends Model
$rtn = $this->cache->get($cacheKey, null);
if (empty($rtn)) {
/** @var EnvironmentStore $store */
$store = Factory::getStore('Environment', 'PHPCensor');
$store = $this->getEnvironmentStore();
$rtn = $store->getByProjectId($key);
$this->cache->set($cacheKey, $rtn);
}
@ -843,7 +852,7 @@ class Project extends Model
$environments_names = !empty($environments_config) ? array_keys($environments_config) : [];
$current_environments = $this->getEnvironmentsObjects();
$store = Factory::getStore('Environment', 'PHPCensor');
$store = $this->getEnvironmentStore();
foreach ($current_environments['items'] as $environment) {
/** @var Environment $environment */
$key = array_search($environment->getName(), $environments_names);