You've already forked Php-Template
All checks were successful
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 2m52s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 3m12s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 3m16s
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 3m7s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 3m11s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m28s
33 lines
864 B
PHP
33 lines
864 B
PHP
<?php
|
|
|
|
namespace Siteworxpro\Tests\CommandBus\Handlers;
|
|
|
|
use Siteworxpro\App\CommandBus\Commands\Command;
|
|
use Siteworxpro\App\CommandBus\Commands\ExampleCommand;
|
|
use Siteworxpro\App\CommandBus\Handlers\ExampleHandler;
|
|
use Siteworxpro\Tests\Unit;
|
|
|
|
class ExampleHandlerTest extends Unit
|
|
{
|
|
public function testExampleCommand(): void
|
|
{
|
|
$command = new ExampleCommand('test payload');
|
|
$this->assertEquals('test payload', $command->getName());
|
|
|
|
$handler = new ExampleHandler();
|
|
$result = $handler($command);
|
|
$this->assertEquals('Hello, test payload!', $result);
|
|
}
|
|
|
|
public function testThrowsException(): void
|
|
{
|
|
$class = new readonly class extends Command
|
|
{
|
|
};
|
|
|
|
$this->expectException(\TypeError::class);
|
|
$handler = new ExampleHandler();
|
|
$handler($class);
|
|
}
|
|
}
|