- PHP 7.1 (https://php.net/downloads.php)
- Composer (https://getcomposer.org/)
- PHPUnit 7.1 (https://phpunit.de/)
For command line use, please setup properly for global environment.
Install phpunit for project
composer install
Project/
|-- src/ (php source code)
|-- tests/ (Testing files)
|-- composer.json (Composer configuration file)
|-- phpunit.xml (PHPUnit configuration file)
Run all testing files in tests/ folder
vendor/bin/phpunit testsRun testing settings in phpunit.xml configuration
vendor/bin/phpunit- Class with
Testfor naming convention. - Test Class MUST extends
PHPUnit\Framework\TestCase - Method name starts with
testor with annotation/** @test */ - Name file with suffix
Test.php.
Example: ExampleTest.php
<?php
use PHPUnit\Framework\TestCase;
class ExampleTest extends TestCase
{
/** @test */
public function test_feature()
{
// arrange
// act
// assert
}
}- PHPUnit Assertions (https://phpunit.de/manual/current/en/appendixes.assertions.html)
- PHPUnit Configration (http://phpunit.readthedocs.io/en/7.1/configuration.html)
- Visit PHPUnit Manual for more information.