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},

#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