Echo uses PHPUnit 12 for testing.
# All tests
./bin/phpunit
# Single test file
./bin/phpunit tests/Http/KernelTest.php
# Single test method
./bin/phpunit --filter testMethodName
# Via composer (inside container)
docker-compose exec -it php composer test- Bootstrap:
tests/bootstrap.php(setsAPP_ENV=testing) - Base class:
Tests\TestCase - Config:
phpunit.xml
Tests are organized by domain:
tests/
Admin/ # Admin module tests
Audit/ # Audit system tests
Database/ # Model and QueryBuilder tests
Http/ # Kernel, middleware, request tests
Routing/ # Router and route cache tests
Session/ # Session handling tests
TestCase.php # Base test class
bootstrap.php # Test bootstrap
namespace Tests\Database;
use Tests\TestCase;
class UserModelTest extends TestCase
{
public function testCanCreateUser(): void
{
$user = User::create([
'email' => 'test@example.com',
'first_name' => 'Test',
]);
$this->assertNotNull($user->id);
$this->assertEquals('test@example.com', $user->email);
}
}