Installation


#Requirements

  1. PHP 8.2+
  2. PHP Gd extension
  3. PrestaShop 1.7, 8 or 9
  4. It's all !

#PrestaShop version

PrestaShop versions 1.7, 8 and 9 are supported by the library.

#Install the library

Copied!
1composer require prestaflow/php-library

#Composer scripts

Into your composer.json, add theses scripts :

Copied!
1"scripts": {
2 "prestaflow:default": "./vendor/prestaflow/php-library/bin/prestaflow run",
3 "prestaflow:json": "@prestaflow:default --output=JSON"
4},

While using JSON output, you can save the results into a file (prestaflow/results.json).

Copied!
1"scripts": {
2 "prestaflow:default": "./vendor/prestaflow/php-library/bin/prestaflow run",
3 "prestaflow:json": "@prestaflow:default --output=JSON",
4 "prestaflow:json:file": "@prestaflow:json --file"
5},

#Alternatively, Task.yml

You also can use the Task.yml to add your own tasks.

Copied!
1tasks:
2 
3 prestaflow:
4 desc: "Tous les tests E2E PrestaFlow"
5 cmds:
6 - cd prestaflow && /opt/homebrew/opt/php@8.4/bin/php vendor/prestaflow/php-library/bin/prestaflow run Tests
7 
8 prestaflow:fo:
9 desc: "Tests FrontOffice uniquement"
10 cmds:
11 - cd prestaflow && /opt/homebrew/opt/php@8.4/bin/php vendor/prestaflow/php-library/bin/prestaflow run Tests/FrontOffice
12 
13 prestaflow:modules:
14 desc: "Tests modules custom uniquement"
15 cmds:
16 - cd prestaflow && /opt/homebrew/opt/php@8.4/bin/php vendor/prestaflow/php-library/bin/prestaflow run Tests/Modules

To run a task, you will use this :

Copied!
1task prestaflow
2task prestaflow:fo
3task prestaflow:modules

#Run

Copied!
1composer prestaflow:default
2composer prestaflow:default -- --output="compact"

As now, if you doesn't have a <Tests> folder, you will have an error ouput.

If you have a <Tests> folder but without PrestaFlow's suites, it will show a success message.

You can also specify a different folder if needed.

Copied!
1composer prestaflow:default ./FolderName

#JSON output

Also, you can get the JSON output if wanted.

Copied!
1composer prestaflow:json
2composer prestaflow:default -- -o "json"
3composer prestaflow:default -- --output="json"
Copied!
1composer prestaflow:json:file

#Working with drafts

Tests can be written at each key stage of a project.

To allow you to implement these without making the output cumbersome, you can define a test as a draft.

This gives you the option to test only drafts or, conversely, ignore them during execution.

Copied!
1public $draft = true | false;
Copied!
1composer prestaflow:default -- --draft
2composer prestaflow:default -- --no-draft

#Working with groups

Within a set of tests, it is sometimes possible to group some of them to refer to the test typology.

You can define one or more groups (using an array).

By default, a test that does not belong to any group will be included in the "All" group.

Copied!
1public $groups = 'tutorial';
2public $groups = ['scenarios', 'en'];
Copied!
1composer prestaflow:default -- --group=tutorial --group=other-group