From 1449c68d6ccc347baddfbcbfa002ed03c57cfb60 Mon Sep 17 00:00:00 2001 From: Jonathan Lelievre Date: Tue, 24 Oct 2023 23:44:50 +0200 Subject: [PATCH] Force legacy controller in context for customer behat tests --- .../Context/CustomerManagerFeatureContext.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/tests/Integration/Behaviour/Features/Context/CustomerManagerFeatureContext.php b/tests/Integration/Behaviour/Features/Context/CustomerManagerFeatureContext.php index cbe5ce18444f2..229af5b7effbc 100644 --- a/tests/Integration/Behaviour/Features/Context/CustomerManagerFeatureContext.php +++ b/tests/Integration/Behaviour/Features/Context/CustomerManagerFeatureContext.php @@ -26,7 +26,9 @@ namespace Tests\Integration\Behaviour\Features\Context; +use AdminController; use Behat\Gherkin\Node\TableNode; +use Context; use Customer; use Exception; use PHPUnit\Framework\Assert; @@ -70,6 +72,18 @@ class CustomerManagerFeatureContext extends AbstractPrestaShopFeatureContext */ protected $customerRegistry = []; + /** + * @BeforeFeature + */ + public static function prepareBeforeFeature() + { + // The Customer legacy object update method only updates groups when a controller is set in the context, + // so until the handlers are no longer based on legacy ObjectModel we need to set it manually + if (!Context::getContext()->controller) { + Context::getContext()->controller = new AdminController(); + } + } + /** * @When /^I create a customer "(.+)" with following properties:$/ */