Skip to content

Commit

Permalink
Disable object model cache before all domain test suites
Browse files Browse the repository at this point in the history
  • Loading branch information
rokaszygmantas committed Jul 26, 2019
1 parent 1ec5d1a commit 3b9b931
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Expand Up @@ -27,6 +27,8 @@
namespace Tests\Integration\Behaviour\Features\Context\Domain;

use Behat\Behat\Context\Context;
use Behat\Testwork\Hook\Scope\BeforeSuiteScope;
use ObjectModel;
use PrestaShop\PrestaShop\Core\CommandBus\CommandBusInterface;
use RuntimeException;
use Tests\Integration\Behaviour\Features\Context\CommonFeatureContext;
Expand All @@ -38,6 +40,15 @@ abstract class AbstractDomainFeatureContext implements Context
*/
protected $lastException;

/**
* @BeforeSuite
*/
public static function prepare(BeforeSuiteScope $scope)
{
// Disable legacy object model cache to prevent conflicts between scenarios.
ObjectModel::disableCache();
}

/**
* @return CommandBusInterface
*/
Expand Down
Expand Up @@ -30,7 +30,6 @@
use Configuration;
use Currency;
use DateTime;
use ObjectModel;
use PrestaShop\Decimal\Number;
use PrestaShop\PrestaShop\Adapter\CartRule\LegacyDiscountApplicationType;
use PrestaShop\PrestaShop\Core\Domain\CartRule\Command\AddCartRuleCommand;
Expand Down Expand Up @@ -252,15 +251,11 @@ public function saveCartRule(array $properties)
$properties['discount_product_id'] ?? null
);

ObjectModel::disableCache();

SharedStorage::getStorage()->set(
sprintf('cart_rule_object_%s', $properties['name']),
new CartRule($cartRuleId->getValue())
);

ObjectModel::enableCache();

SharedStorage::getStorage()->clear($this->cartRuleStorageProperty);
}

Expand Down

0 comments on commit 3b9b931

Please sign in to comment.