elgentos/testing-suite

There is no license information available for the latest version (0.2.1) of this package.

Elgentos Testing Suite

0.2.1 2023-06-15 13:26 UTC

This package is auto-updated.

Last update: 2024-04-15 15:22:07 UTC


README

This uses youwe/testing-suite, but we can add/change tests/packages/configuration as we like.

Installation

composer require elgentos/testing-suite --dev

Configuration

Add this to your phpstan.neon;

includes:
    - vendor/bitexpert/phpstan-magento/extension.neon

Baselines

When implementing this into an existing project, you might want to consider generating baselines so the tests will pass without having to fix all the files.

Phpstan baseline

Generate the baseline (replace app/design/frontend app/code with your dirs);

vendor/bin/phpstan analyse --level 4 --configuration ./phpstan.neon app/code app/design/frontend --generate-baseline

Then add this to your phpstan.neon;

includes:
  - phpstan-baseline.neon

Phpmd baseline

Generate the baseline (replace app/design/frontend,app/code with your dirs);

vendor/bin/phpmd app/design/frontend,app/code text ./phpmd.xml --generate-baseline

Phpcs baseline

Generate the baseline (replace app/design/frontend app/code with your dirs);

vendor/bin/phpcs app/design/frontend app/code --extensions=php,phtml --report=\\DR\\CodeSnifferBaseline\\Reports\\Baseline --report-file=phpcs.baseline.xml --basepath=.\

Run it

vendor/bin/grumphp run

Gitlab CI/CD

If you are implementing this in an existing project, do the work to make all tests pass (or add the baselines). As soon as all tests pass, make sure to make the static testing job required in our internal Gitlab CI/CD, by adding this to the projects' .gitlab-ci.yml:

static:testingsuite:
  allow_failure: false

Configure Phpstorm

This assumes you're using our Docker environment.

  1. Go to Settings > PHP > Quality Tools
  2. Perform these steps for PHP_CodeSniffer, Mess Detector, PHP CS Fixer and PHPStan:
    1. Click on the ... behind the Configuration dropdown.
    2. Click on the blue + sign.
    3. Choose development_php81:latest, click OK
    4. Click Ok
  3. Go to Settings > Editor > Inspections > PHP > Quality Tools
    1. Disable PHP CS Fixer validation
    2. Enable PHP Mess Detector validation
      1. Under "Custom Rulesets", clear the list and add vendor/youwe/coding-standard-magento2/src/YouweMagento2/
      2. Click Apply
    3. Enable PHP_CodeSniffer validation
      1. Under "Coding standard", choose "YouweMagento2"
      2. Click Apply
    4. Enable PHPStan validation
      1. Make sure the Configuration file and the Autoload file paths are empty
      2. Make sure you have the phpstan.neon file in your project root
      3. Click Apply
    5. Disable Psalm validation