Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Behat tests for CMS page commands #14170

Merged
merged 20 commits into from Sep 4, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 21 additions & 3 deletions classes/PrestaShopAutoload.php
Expand Up @@ -88,7 +88,13 @@ public static function getInstance()
*/
public static function getCacheFileIndex()
{
return _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . (_PS_MODE_DEV_ ? 'dev' : 'prod') . DIRECTORY_SEPARATOR . 'class_index.php';
if (defined('_PS_IN_TEST_')) {
$env = 'test';
} else {
$env = (_PS_MODE_DEV_) ? 'dev' : 'prod';
}

return _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $env . DIRECTORY_SEPARATOR . 'class_index.php';
}

/**
Expand All @@ -98,7 +104,13 @@ public static function getCacheFileIndex()
*/
public static function getNamespacedStubFileIndex()
{
return _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . (_PS_MODE_DEV_ ? 'dev' : 'prod') . DIRECTORY_SEPARATOR . 'namespaced_class_stub.php';
if (defined('_PS_IN_TEST_')) {
$env = 'test';
} else {
$env = (_PS_MODE_DEV_) ? 'dev' : 'prod';
}

return _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $env . DIRECTORY_SEPARATOR . 'namespaced_class_stub.php';
}

/**
Expand All @@ -108,7 +120,13 @@ public static function getNamespacedStubFileIndex()
*/
public static function getStubFileIndex()
{
return _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . (_PS_MODE_DEV_ ? 'dev' : 'prod') . DIRECTORY_SEPARATOR . 'class_stub.php';
if (defined('_PS_IN_TEST_')) {
$env = 'test';
} else {
$env = (_PS_MODE_DEV_) ? 'dev' : 'prod';
}

return _PS_ROOT_DIR_ . DIRECTORY_SEPARATOR . 'var' . DIRECTORY_SEPARATOR . 'cache' . DIRECTORY_SEPARATOR . $env . DIRECTORY_SEPARATOR . 'class_stub.php';
}

/**
Expand Down
6 changes: 5 additions & 1 deletion classes/Tools.php
Expand Up @@ -3423,7 +3423,11 @@ public static function clearSmartyCache()
public static function clearSf2Cache($env = null)
{
if (null === $env) {
$env = _PS_MODE_DEV_ ? 'dev' : 'prod';
if (defined('_PS_IN_TEST_')) {
$env = 'test';
} else {
$env = (_PS_MODE_DEV_) ? 'dev' : 'prod';
}
}

$dir = _PS_ROOT_DIR_ . '/var/cache/' . $env . '/';
Expand Down
8 changes: 7 additions & 1 deletion config/defines.inc.php
Expand Up @@ -69,7 +69,13 @@
define('_PS_BO_ALL_THEMES_DIR_', _PS_ADMIN_DIR_.'/themes/');
}
if (!defined('_PS_CACHE_DIR_')) {
$prestashopCacheDir = _PS_ROOT_DIR_.'/var/cache/'.(_PS_MODE_DEV_ ? 'dev': 'prod'). DIRECTORY_SEPARATOR;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Currently refactoring this one in #14894

if (defined('_PS_IN_TEST_')) {
$env = 'test';
} else {
$env = (_PS_MODE_DEV_) ? 'dev' : 'prod';
}

$prestashopCacheDir = _PS_ROOT_DIR_.'/var/cache/'.$env. DIRECTORY_SEPARATOR;
define('_PS_CACHE_DIR_', $prestashopCacheDir);
}
define('_PS_CONFIG_DIR_', _PS_CORE_DIR_.'/config/');
Expand Down
Expand Up @@ -86,7 +86,7 @@ public function handle(EditCmsPageCommand $command)
private function createCmsFromCommand(EditCmsPageCommand $command)
{
$cms = $this->getCmsPageIfExistsById($command->getCmsPageId()->getValue());
$cmsCategoryId = $command->getCmsPageCategoryId()->getValue();
$cmsCategoryId = null === $command->getCmsPageCategoryId() ?: $command->getCmsPageCategoryId()->getValue();

if (null !== $cmsCategoryId && $this->assertCmsCategoryExists($cmsCategoryId)) {
$cms->id_cms_category = $cmsCategoryId;
Expand Down