- Php
- Features
- Autoload
- Class Reflection
- Magic Methods
- Exceptions
- Late Static Binding
- Type Hinting
- SPL
- PHPUNIT ♣
- PHAR
- Composer
- Guzzle
- Carbon
- Faker
- Math
- Requests
- Design Patterns
- Singleton Pattern
- Observer Pattern
- Strategy Pattern
- Registry
- Symfony
- Routes
- Annotations
- Flex
- Controllers
- Doctrine
- Templating
- Versions
- Php7.4
- Php8.0
- Security
- Filter Input
- Remote Code Injection
- Sql Injection
- Session Fixation
- File Uploads
- Cross Site Scripting
- Spoofed Forms
- CSRF
- Session Hijacking
- Modern Php
- Composer
- Slim Framework
- Autoloader
- Package
- Releases
- Generators
- Dependency Injection
- Middleware
- Create Framework
- App
- Http Foundation
- Front Controller
- Routing
- Render Controller
- Resolver
- SoC
- Frameworks
- Symfony V5
- Laravel V8
- Laminas V3
- Codeigniter V4
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: 62 days ago