bkubicki / magento2-unit-tests-doubles
Unit tests doubles for Magento 2
Installs: 10 046
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 2
Forks: 1
Open Issues: 0
Requires
- php: ^7.4
- magento/framework: ^100.1|^101.0|^102.0|^103.0
- magento/module-catalog: ^101.0|^102.0|^103.0|^104.0
- magento/module-customer: ^101.0|^102.0|^103.0
- magento/module-quote: ^101.0
Requires (Dev)
- infection/infection: ^0.13.5
- phpmd/phpmd: ^2.7
- phpunit/phpunit: ^8.0.0
- squizlabs/php_codesniffer: ^3.4
This package is auto-updated.
Last update: 2024-10-26 04:10:58 UTC
README
Overview
Library provides useful doubles of different kinds for unit testing of Magento 2.3+. Some of the doubles can be created using dedicated builders, which helps in configuring desired behavior of doubles. By using these doubles you can get rid of over-mocking in unit tests and time spent on writing unit should decrease. It can be achieved because all doubles inherits or implements replaced object or interface, so type consistency is preserved. Examples in here.
Prerequisites
- PHP ^7.4
Installation
To install the extension use the following commands:
composer require bkubicki/magento2-unit-tests-doubles
Tests
Unit
Run command
composer test-unit-coverage
which is an alias for
./vendor/bin/phpunit -c phpunit.xml --testsuite "Unit" --coverage-html coverage/coverage-html --colors=always
Integration
Run command
composer test-integration
which is an alias for
./vendor/bin/phpunit -c phpunit.xml --testsuite "Integration" --colors=always
Mutation tests (using Infection)
-
Infection tests requires xDebug enabled.
-
Run command
composer test-infection
which does the following:
- Run PHPUnit tests and generate coverage in xml:
./vendor/bin/phpunit -c phpunit.xml --testsuite "Unit" --coverage-xml coverage/coverage-xml --log-junit coverage/phpunit.junit.xml
- Run Infection mutation tests for covered code
./vendor/bin/infection --coverage=coverage --only-covered --show-mutations
- Run PHPUnit tests and generate coverage in xml:
-
Find detailed report from mutations in
var/log/dev/infection.log
.
Versioning
We use SemVer for versioning. For the versions available, see the tags on this repository.
Changelog
See changelog here.
Authors
License
This project is licensed under the MIT License - see the LICENSE file for details.