Scenario
On this page
A scenario is a set of steps.
Creating scenarios allow you to use them in one line instead of duplicate each steps that it contains.
#Creating scenario
You need to extends the Scenario class and add the steps() method.
1use PrestaFlow\Library\Scenarios\Scenario;2 3class AddProductToCart extends Scenario4{5 public function steps($testSuite)6 {7 return $testSuite;8 }9}
You can now write your steps as you will do inside a test suite.
1public function steps($testSuite) 2{ 3 $testSuite->importPage('FrontOffice\Category'); 4 $testSuite->importPage('FrontOffice\Product'); 5 6 extract($testSuite->pages); 7 8 $testSuite 9 ->it('go to category page', function () use ($frontOfficeCategoryPage) {10 $frontOfficeCategoryPage->goToPage('category', (int) $this->getParam('categoryId'));11 12 Expect::that($frontOfficeCategoryPage->getListingTitle())->contains($this->getParam('categoryTitle'));13 })14 ->it('go to product page', function () use ($frontOfficeCategoryPage, $frontOfficeProductPage) {15 $frontOfficeCategoryPage->goToProduct((int) $this->getParam('productIndex'));16 17 Expect::that($frontOfficeProductPage->getTitle())->contains($this->getParam('productTitle'));18 })19 ->it('add to cart', function () use ($frontOfficeProductPage) {20 $textResult = $frontOfficeProductPage->addToCart((int) $this->getParam('cartQuantity'));21 22 Expect::that($textResult)->contains($frontOfficeProductPage->message('addedToCart'));23 });24 25 return $testSuite;26}
#Use
1->scenario(ModuleCustom::class)
#Parameters
A scenario is a make to re-use steps.
As each steps could be taking one or more parameters distinctly, you can add a array of parameters.
#Declare parameters
1public $params = [2 'categoryId' => 3,3 'categoryTitle' => 'Vêtements',4 'productIndex' => 1,5 'productTitle' => 'T-shirt imprimé colibri',6 'cartQuantity' => 1,7];
You will define the key as a parameter and you can attach it a default value.
#Pass parameters in test suite
1->scenario(ModuleCustom::class, [2 'locale' => 'en',3 'useIsoCode' => true,4])
#Composing several scenarios in one suite
A suite can chain scenarios. State is shared between them via store() /
retrieve() on the suite, so a scenario can consume what a previous one produced
(for example, an order reference).
1$this2->describe('Create an order then manage its lifecycle in the BackOffice')3->scenario(\PrestaFlow\Library\Scenarios\CheckoutOrder::class)4->scenario(\PrestaFlow\Library\Scenarios\ManageOrder::class);
#Ready-to-use scenarios
Since v1.5.0, the library ships a set of end-to-end scenarios you can drop into a suite as-is or subclass to customise. Each of them is validated live against a PrestaShop 9 shop.
#CheckoutOrder
Logs in a customer on the FrontOffice, adds a product to the cart, goes through the full checkout tunnel, then verifies the order exists in the BackOffice.
Parameters
1public $params = [2 'locale' => 'fr',3 'customerEmail' => 'pub@prestashop.com',4 'customerPassword' => 'PrestaFlow2026!',5 'productUrl' => '1-1-hummingbird-printed-t-shirt.html',6 'cartQuantity' => 1,7];
Usage
1$this2->describe('Place an order end-to-end and verify it in the BackOffice')3->scenario(\PrestaFlow\Library\Scenarios\CheckoutOrder::class);
The scenario stores the order reference in the suite (store('orderReference')),
so a following scenario in the same suite can retrieve it.
#GuestCheckout
Same tunnel, but as a pure guest — the scenario fills the personal-information step (email + name), enters a new shipping address, and reaches the FrontOffice confirmation.
Parameters
1public $params = [ 2 'locale' => 'fr', 3 'productUrl' => '1-1-hummingbird-printed-t-shirt.html', 4 'cartQuantity' => 1, 5 'guestEmail' => 'pf-guest@example.com', 6 'firstName' => 'PrestaFlow', 7 'lastName' => 'Guest', 8 'addressStreet' => '16 Main street', 9 'addressCity' => 'Paris',10 'addressPostcode' => '75002',11 'addressCountry' => 'France',12 'addressPhone' => '0102030405',13];
#ManageOrder
Opens an order in the BackOffice, changes its status, adds an internal note and
sets a tracking number — each action verified. Reads the order reference stored
by a preceding CheckoutOrder (or accepts an explicit orderReference param).
Parameters
1public $params = [2 'locale' => 'fr',3 'orderStatus' => 'Payment accepted',4 'internalNote' => 'PrestaFlow internal note',5 'trackingNumber' => 'PF-TRACK-0001',6 'orderReference' => null, // defaults to retrieve('orderReference')7];
The orderStatus value must match the label as shown in the BackOffice status
dropdown (the BackOffice admin language, which may differ from the FrontOffice
locale).
#EditProduct
Self-cleaning scenario: creates a product, opens it from the list, changes its price, verifies the new price is persisted, then deletes the product.
Parameters
1public $params = [2 'productName' => 'PF Edit Test',3 'initialPrice' => 9.99,4 'newPrice' => 19.99,5 'quantity' => 10,6];
#CreateProductAndVerify
BackOffice product creation followed by a FrontOffice visibility check, then a delete. Reads the product's canonical FrontOffice URL from the BackOffice edit page (Preview link) so the check is independent of the shop's URL rewriting.
Parameters
1public $params = [2 'productName' => 'PrestaFlow Scenario Product',3 'productPrice' => 9.99,4 'productQuantity' => 10,5];
#AddProductToCart
The historical FrontOffice scenario: browse to a category, open a product, add it to the cart, assert the modal message.
1public $params = [2 'categoryId' => 3,3 'categoryTitle' => 'Vêtements',4 'productIndex' => 1,5 'productTitle' => 'T-shirt imprimé colibri',6 'cartQuantity' => 1,7];