You've already forked Php-Template
All checks were successful
🧪✨ Tests Workflow / 📝 ✨ Code Lint (push) Successful in 1m13s
🧪✨ Tests Workflow / 🛡️ 🔒 Library Audit (push) Successful in 1m24s
🧪✨ Tests Workflow / 🛡️ 🔒 License Check (push) Successful in 1m58s
🧪✨ Tests Workflow / 🧪 ✨ Database Migrations (push) Successful in 2m20s
🧪✨ Tests Workflow / 🐙 🔍 Code Sniffer (push) Successful in 2m5s
🧪✨ Tests Workflow / 🧪 ✅ Unit Tests (push) Successful in 1m0s
Reviewed-on: #27 Co-authored-by: Ron Rise <ron@siteworxpro.com> Co-committed-by: Ron Rise <ron@siteworxpro.com>
37 lines
1.0 KiB
PHP
37 lines
1.0 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace Siteworxpro\Tests\CommandBus;
|
|
|
|
use League\Tactician\Exception\CanNotInvokeHandlerException;
|
|
use Siteworxpro\App\CommandBus\AttributeLocator;
|
|
use Siteworxpro\App\CommandBus\Commands\ExampleCommand;
|
|
use Siteworxpro\App\CommandBus\Handlers\ExampleHandler;
|
|
use Siteworxpro\Tests\Unit;
|
|
|
|
class AttributeLocatorTest extends Unit
|
|
{
|
|
private const array HANDLERS = [
|
|
ExampleCommand::class => ExampleHandler::class,
|
|
];
|
|
|
|
public function testResolvesFiles(): void
|
|
{
|
|
$attributeLocator = new AttributeLocator();
|
|
|
|
foreach (self::HANDLERS as $command => $handler) {
|
|
$class = $attributeLocator->getHandlerForCommand($command);
|
|
$this->assertInstanceOf($handler, $class);
|
|
}
|
|
}
|
|
|
|
public function testThrowsOnCannotResolve(): void
|
|
{
|
|
$attributeLocator = new AttributeLocator();
|
|
|
|
$this->expectException(CanNotInvokeHandlerException::class);
|
|
$attributeLocator->getHandlerForCommand('NonExistentCommand');
|
|
}
|
|
}
|