You've already forked php-auth
generated from siteworxpro/Php-Template
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);
|
|
}
|
|
}
|