PHPackages                             thesgroup/magento2-testing-framework - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Testing &amp; Quality](/categories/testing)
4. /
5. thesgroup/magento2-testing-framework

ActiveLibrary[Testing &amp; Quality](/categories/testing)

thesgroup/magento2-testing-framework
====================================

Testing framework for Magento 2 modules

1.1.36(1y ago)411.9k1[4 issues](https://github.com/sashas777/magento2-testing-framework/issues)GPL-3.0PHPPHP ~8.1.0||~8.2.0||~8.3CI failing

Since May 14Pushed 1y ago3 watchersCompare

[ Source](https://github.com/sashas777/magento2-testing-framework)[ Packagist](https://packagist.org/packages/thesgroup/magento2-testing-framework)[ Docs](https://github.com/sashas777/magento2-testing-framework)[ GitHub Sponsors](https://github.com/sashas777)[ RSS](/packages/thesgroup-magento2-testing-framework/feed)WikiDiscussions master Synced 6d ago

READMEChangelog (10)Dependencies (9)Versions (56)Used By (0)

Magento 2 Testing Framework
===========================

[](#magento-2-testing-framework)

[![Latest Stable Version](https://camo.githubusercontent.com/9ab0ee1d277e7cf633668f3ff111d33f600f0af722591cdbfb08b7c12e98c053/68747470733a2f2f706f7365722e707567782e6f72672f7468657367726f75702f6d6167656e746f322d74657374696e672d6672616d65776f726b2f76)](//packagist.org/packages/thesgroup/magento2-testing-framework) [![Total Downloads](https://camo.githubusercontent.com/7d722359486fa82280600305ab755bb59ac77918874e7587832c9012bc9ec820/68747470733a2f2f706f7365722e707567782e6f72672f7468657367726f75702f6d6167656e746f322d74657374696e672d6672616d65776f726b2f646f776e6c6f616473)](//packagist.org/packages/thesgroup/magento2-testing-framework) [![Latest Unstable Version](https://camo.githubusercontent.com/7d059df0d7d526256b3a26358dedd62f34c0e78bc6b5959dfcc553806fe961d0/68747470733a2f2f706f7365722e707567782e6f72672f7468657367726f75702f6d6167656e746f322d74657374696e672d6672616d65776f726b2f762f756e737461626c65)](//packagist.org/packages/thesgroup/magento2-testing-framework) [![License](https://camo.githubusercontent.com/751b7a8e313ec8618276f64f6ff5f4a64b322a3de557411b9eca31429f3d09f3/68747470733a2f2f706f7365722e707567782e6f72672f7468657367726f75702f6d6167656e746f322d74657374696e672d6672616d65776f726b2f6c6963656e7365)](//packagist.org/packages/thesgroup/magento2-testing-framework)

Magento 2 static/unit testing framework for a single module tests. It can be used for a pipeline or to verify a Magento 2 module.

Installation
------------

[](#installation)

Run the following command on your Magento 2 project:

```
composer require --dev thesgroup/magento2-testing-framework
```

---

Pipeline Examples
-----------------

[](#pipeline-examples)

Assumes $MAGENTO\_USER and $MAGENTO\_PASS set as pipeline variables.

- [Bitbucket pipelines](https://github.com/sashas777/magento2-testing-framework/blob/master/bitbucket-pipelines.yml.sample)
- [Gitlab CI](https://github.com/sashas777/magento2-testing-framework/blob/master/.gitlab-ci.yml.sample)

---

Basic Usage
-----------

[](#basic-usage)

In the most cases you may use basic test suite to run PHP code, JavaScript, PhpUnit tests.

### PHP Code

[](#php-code)

There is an option to run all php tests using one command. It runs following tests:

- PHP Coding Standard Verification
- Code Integrity Tests
- HTML Static Code Analysis
- Less Static Code Analysis
- GraphQL Static Code Analysis

You can run all tests by using the command:

```
vendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard,vendor/phpcompatibility/php-compatibility/PHPCompatibility
vendor/bin/run-all-tests
```

When you need to delete test files you can use the cleanup command:

```
vendor/bin/cleanup
```

### PHPUnit

[](#phpunit)

Run unit tests and check for code coverage threshold.

```
vendor/bin/phpunit-tests
```

After execution following reports generated:

- JUnit log test-reports/junit.xml
- Html test coverage report test-coverage-html/
- Clover test coverage report clover.xml

To set code coverage threshold 80% (The default value 70%):

```
vendor/bin/phpunit-tests 80
```

### Javascript

[](#javascript)

Run ESLint to ensure the quality of your JavaScript code:

```
vendor/bin/js-tests
```

Fix ESLint Locally:

```
npm install eslint --save-dev
npx eslint -c vendor/thesgroup/magento2-testing-framework/static/js/eslint/.eslintrc --ignore-pattern=vendor/** --no-error-on-unmatched-pattern .
```

---

Advanced Usage
--------------

[](#advanced-usage)

### PHP Coding Standard Verification

[](#php-coding-standard-verification)

These testsuite include: PHPCS, PHPMD, PHPCPD, PHPStan Tests and strict types declaration. You can run it exclusively using the following command:

```
vendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard,vendor/phpcompatibility/php-compatibility/PHPCompatibility
vendor/bin/phpunit --testsuite="PHP Coding Standard Verification" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml
```

### Code Integrity Tests

[](#code-integrity-tests)

You can run it exclusively using the following command:

```
vendor/bin/phpunit --testsuite="Code Integrity Tests" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml
```

### HTML Static Code Analysis

[](#html-static-code-analysis)

You can run it exclusively using the following command:

```
vendor/bin/phpunit --testsuite="HTML Static Code Analysis" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml
```

### Less Static Code Analysis

[](#less-static-code-analysis)

You can run it exclusively using the following command:

```
vendor/bin/phpunit --testsuite="Less Static Code Analysis" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml
```

### GraphQL Static Code Analysis

[](#graphql-static-code-analysis)

You can run it exclusively using the following command:

```
vendor/bin/phpunit --testsuite="GraphQL Static Code Analysis" -c vendor/thesgroup/magento2-testing-framework/static/integrity/phpunit.xml
```

PHP Code Beautifier and Fixer (PHPCBF)
--------------------------------------

[](#php-code-beautifier-and-fixer-phpcbf)

To automatically fix as many sniff violations as possible, use the phpcbf command:

```
vendor/bin/phpcs --config-set installed_paths vendor/magento/magento-coding-standard/,vendor/phpcompatibility/php-compatibility/PHPCompatibility
vendor/bin/phpcbf --standard=Magento2 .
```

Ignoring Files and Folders
--------------------------

[](#ignoring-files-and-folders)

Specific files/folders can be added to blacklist at the module folder by adding at new line

#### PHPCS

[](#phpcs)

```
{module_dir}/Test/_files/phpcs/ignorelist/*.txt
```

#### PHPMD

[](#phpmd)

```
{module_dir}/Test/_files/phpmd/ignorelist/*.txt
```

#### PHPCPD

[](#phpcpd)

```
{module_dir}/Test/_files/phpcpd/blacklist/*.txt
```

#### Strict Type Declarations

[](#strict-type-declarations)

```
{module_dir}/Test/_files/blacklist/strict_type.txt
```

#### PHPStan

[](#phpstan)

```
{module_dir}/Test/_files/phpstan/blacklist/*.txt
```

---

Information About Tests
-----------------------

[](#information-about-tests)

Magento Specific Rules
----------------------

[](#magento-specific-rules)

###### AllPurposeAction

[](#allpurposeaction)

Controllers (classes implementing ActionInterface) have to implement marker HttpActionInterface to restrict incoming requests by methods.

###### CookieAndSessionMisuse

[](#cookieandsessionmisuse)

Sessions and cookies must only be used in classes directly responsible for HTML presentation because Web APIs do not rely on cookies and sessions. If you need to get current user use Magento\\Authorization\\Model\\UserContextInterface

###### FinalImplementation

[](#finalimplementation)

Final keyword is prohibited in Magento as this decreases extensibility and customizability. Final classes and method are not compatible with plugins and proxies.

Code Integrity Tests
--------------------

[](#code-integrity-tests-1)

The command above will perform following tests:

- Compiler test. Check compilation of DI definitions and code generation
- Test block names exists
- Test layout declaration and usage of block elements
- Test format of layout files
- Test layout declaration and usage of block elements
- Test declarations of handles in theme layout updates
- Test ACL in the admin area by various assertions.
- Find adminhtml/system.xml files and validate them.
- Find fieldset.xml files and validate them.
- Check interfaces inherited from \\Magento\\Framework\\Api\\ExtensibleDataInterface.
- Find webapi xml files and validate them.
- Find widget.xml files and validate them.
- Scan source code for references to classes and see if they indeed exist.
- A test that enforces validity of composer.json files and any other conventions in Magento components.
- Validates information on the dependency between the modules according to the declarative schema.
- Oberver Implementation. (PAY ATTENTION: Current implementation does not support of virtual types)
- Scan source code for incorrect or undeclared modules dependencies.
- Check Magento modules structure for circular dependencies
- Verify whether all payment methods are declared in appropriate modules
- Tests to find obsolete install/upgrade schema/data scripts.
- Coverage of obsolete nodes in layout
- Static test for phtml template files.
- Less Static Code Analysis
- GraphQL Static Code Analysis
- Scan source code for detects invocations of outdated \_\_() method.
- Scan source code for detects invocations of \_\_() function or Phrase object, analyzes placeholders with arguments and see if they not equal.
- Will check if phrase is empty.
- xsi:noNamespaceSchemaLocation validation.
- XML DOM Validation.

Contribute To The Module
------------------------

[](#contribute-to-the-module)

Feel free to Fork and contribute to this module and create a pull request so we will merge your changes to master branch.

Credits
-------

[](#credits)

Thanks the [the contributors](https://github.com/sashas777/magento2-testing-framework/graphs/contributors)

Related Resources
-----------------

[](#related-resources)

- [Docker Images](https://github.com/sashas777/magento-docker/)
- [Examples for pipeline configuration](https://github.com/sashas777/magento-docker-pipelines)
- [Magento Code Standard](https://github.com/magento/magento-coding-standard)
- [MFTF](https://github.com/magento/magento2-functional-testing-framework)
- [Magento Coding Standard Severity](https://github.com/magento/magento-coding-standard/blob/v5/Magento2/ruleset.xml)
- [PHPStan Output Format](https://phpstan.org/user-guide/output-format)

###  Health Score

39

—

LowBetter than 86% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity24

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity84

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~33 days

Recently: every ~96 days

Total

52

Last Release

516d ago

PHP version history (7 changes)1.0.0PHP ~7.1.0||~7.2.0||~7.3.0

1.0.8PHP ~7.1.0||~7.2.0||~7.3.0||~7.4.0

1.1.0PHP ~7.3.0||~7.4.0

1.1.11PHP ~7.3.0||~7.4.0||~8.1.0

1.1.24PHP ~7.3.0||~7.4.0||~8.1.0||~8.2.0

1.1.30PHP ~8.1.0||~8.2.0

1.1.34PHP ~8.1.0||~8.2.0||~8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/11a4b6d901bcab961bde71c09e3aa3c4981324df1fd3344c3041635dd4199e96?d=identicon)[sashas](/maintainers/sashas)

---

Top Contributors

[![sashas777](https://avatars.githubusercontent.com/u/6912470?v=4)](https://github.com/sashas777 "sashas777 (127 commits)")

---

Tags

composermagento2magento2-testsphpcsphpmdunit-testtestingautomationmagentomagento2-library

### Embed Badge

![Health badge](/badges/thesgroup-magento2-testing-framework/health.svg)

```
[![Health](https://phpackages.com/badges/thesgroup-magento2-testing-framework/health.svg)](https://phpackages.com/packages/thesgroup-magento2-testing-framework)
```

###  Alternatives

[brianium/paratest

Parallel testing for PHP

2.5k118.8M754](/packages/brianium-paratest)[orchestra/testbench

Laravel Testing Helper for Packages Development

2.2k39.1M32.1k](/packages/orchestra-testbench)[magento/magento2-functional-testing-framework

Magento2 Functional Testing Framework

15511.5M30](/packages/magento-magento2-functional-testing-framework)[timacdonald/log-fake

A drop in fake logger for testing with the Laravel framework.

4235.9M56](/packages/timacdonald-log-fake)[typo3/testing-framework

The TYPO3 testing framework provides base classes for unit, functional and acceptance testing.

675.0M775](/packages/typo3-testing-framework)[moodlehq/moodle-plugin-ci

Helps running Moodle plugins analysis checks and tests under various CI environments.

612.6M](/packages/moodlehq-moodle-plugin-ci)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
