Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bartoszkubicki/magento2-unit-tests-doubles
Magento 2 Unit Tests Doubles
https://github.com/bartoszkubicki/magento2-unit-tests-doubles
magento magento2 magento2-extension magento2-module mock mocking overmocking phpunit stub stubbing unit-test unit-testing
Last synced: 3 months ago
JSON representation
Magento 2 Unit Tests Doubles
- Host: GitHub
- URL: https://github.com/bartoszkubicki/magento2-unit-tests-doubles
- Owner: bartoszkubicki
- License: mit
- Created: 2019-09-10T05:30:54.000Z (over 5 years ago)
- Default Branch: master
- Last Pushed: 2021-10-25T21:53:51.000Z (about 3 years ago)
- Last Synced: 2024-10-11T09:20:20.853Z (3 months ago)
- Topics: magento, magento2, magento2-extension, magento2-module, mock, mocking, overmocking, phpunit, stub, stubbing, unit-test, unit-testing
- Language: PHP
- Homepage:
- Size: 145 KB
- Stars: 1
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE.md
Awesome Lists containing this project
README
# BKubicki Magento 2 Unit Tests Doubles
## 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](EXAMPLES.md).## Prerequisites
* PHP ^7.4## Installation ###
To install the extension use the following commands:
```bash
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) ###1. Infection tests requires xDebug enabled.
2. 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
```
3. Find detailed report from mutations in ```var/log/dev/infection.log```.
## VersioningWe use [SemVer](http://semver.org/) for versioning. For the versions available, see the [tags on this repository](https://github.com/bartoszkubicki/magento2-unit-tests-doubles/tags).
## Changelog
See changelog [here](CHANGELOG.md).
## Authors
* [Bartosz Kubicki](https://github.com/bartoszkubicki)
## License
This project is licensed under the MIT License - see the [LICENSE](LICENSE.md) file for details.