roukmoute / dto-tester
Add PHPUnit extension for testing DTOs and Transfer Objects
v0.5
2021-03-01 09:34 UTC
Requires
- php: ^7.2
- phpunit/phpunit: ^8.4||^9.1
- roave/better-reflection: ^3.5||^4.8
Requires (Dev)
- friendsofphp/php-cs-fixer: ^2.18
- pedrotroller/php-cs-custom-fixer: ^2.23
- phpspec/phpspec: ^6.0
README
Automatically PHPUnit Test DTO and Transfer Objects.
Original idea: Automatically JUnit Test DTO and Transfer Objects
Installation
These commands requires you to have Composer installed globally.
Open a command console, enter your project directory and execute the following
commands to download the latest stable version:
composer require --dev roukmoute/dto-tester
Usage
All we need to do is extend DtoTester\DtoTest
and create a test instance and
the DtoTest
class will do the rest.
Here it is an example class named FooBar
:
<?php class FooBarTest extends \DtoTester\DtoTest { protected function getInstance() { return new FooBar(); } }
So we now turned what would have been many boring unit tests which didn’t test any real business logic into a simple file with less than 10 lines of code.