minte9
LearnRemember



Install PhpUnit

Install PhpUnit with Composer.
 
cd /var/www/tests.local/php/

composer require --dev phpunit/phpunit ^8

./vendor/bin/phpunit --version
Update version
 
composer require --dev phpunit/phpunit ^9
Test file (testNumber.php)
 
require __DIR__ . '/../vendor/autoload.php';

use PHPUnit\Framework\TestCase;

function isEven($n) { return $n%2 == 0; }
function isOdd($n) { return $n%2 != 0; }

final class TestNumber extends TestCase
{
    public function testEven()
    {
        $this->assertEquals(isEven(2), true);
        $this->assertEquals(isEven(3), false);
    }
    public function testOdd()
    {
        $this->assertEquals(isOdd(2), false);
        $this->assertEquals(isOdd(3), true);
    }
}
Run test
 
./vendor/bin/phpunit tests/testNumber.php

# 2 / 2 (100%)



  Last update: 382 days ago