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 Sep 3, 2019
1 parent 4ca1d35 commit 30ecde0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
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 @@ -39,6 +41,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
Original file line number Diff line number Diff line change
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 30ecde0

Please sign in to comment.