From b39218b663645cf38b1efddb7ab77cdb73f53ada Mon Sep 17 00:00:00 2001 From: Christopher Gammie Date: Fri, 8 May 2026 11:22:26 +0100 Subject: [PATCH 1/2] refactor: enforce final and make extendable classes abstract --- pint.json | 1 + src/Application/ApplicationException.php | 3 ++- .../Bus/AbortOnFailureException.php | 21 +++++++++++++++-- src/Application/Bus/CommandQueuer.php | 2 +- .../DeferredDispatcher.php | 2 +- .../DomainEventDispatching/Dispatcher.php | 2 +- .../UnitOfWorkAwareDispatcher.php | 2 +- src/Bus/BusException.php | 2 +- src/Bus/CommandDispatcher.php | 2 +- src/Bus/InboundEventDispatcher.php | 2 +- src/Bus/QueryDispatcher.php | 2 +- .../Application/ApplicationException.php | 19 +++++++++++++++ .../InfrastructureException.php | 19 +++++++++++++++ .../Toolkit/Result/FailedResultException.php | 23 +++++++++++++++++++ .../InfrastructureException.php | 3 ++- .../OutboundEventBus/ClosurePublisher.php | 2 +- .../OutboundEventBus/ComponentPublisher.php | 2 +- src/Infrastructure/Queue/ClosureQueue.php | 2 +- src/Infrastructure/Queue/ComponentQueue.php | 2 +- src/Testing/FakeDomainEventDispatcher.php | 2 +- src/Testing/FakeOutboundEventPublisher.php | 2 +- src/Testing/FakeQueue.php | 2 +- src/Toolkit/ContractException.php | 2 +- src/Toolkit/Result/ContextualResult.php | 2 +- src/Toolkit/Result/FailedResultException.php | 3 ++- .../MathDomainEventDispatcherTest.php | 2 +- tests/Integration/Bus/MathCommandBusTest.php | 2 +- tests/Integration/Bus/MathEventBusTest.php | 2 +- tests/Integration/Bus/MathQueryBusTest.php | 2 +- .../MathEventPublisherTest.php | 2 +- .../TestClosurePublisherTest.php | 2 +- .../Infrastructure/Queue/MathQueueTest.php | 2 +- .../Queue/TestClosureQueueTest.php | 2 +- .../Application/ApplicationExceptionTest.php | 2 +- .../Application/Bus/CommandDispatcherTest.php | 6 ++--- .../Bus/CommandHandlerContainerTest.php | 6 ++--- .../Application/Bus/CommandHandlerTest.php | 2 +- .../Application/Bus/CommandQueuerTest.php | 2 +- .../Middleware/ExecuteInUnitOfWorkTest.php | 2 +- .../Middleware/FlushDeferredEventsTest.php | 2 +- .../Bus/Middleware/LogMessageDispatchTest.php | 2 +- .../Middleware/SetupBeforeDispatchTest.php | 2 +- .../Middleware/TearDownAfterDispatchTest.php | 2 +- .../Bus/Middleware/ValidateMessageTest.php | 2 +- .../Application/Bus/QueryDispatcherTest.php | 6 ++--- .../Bus/QueryHandlerContainerTest.php | 6 ++--- .../Unit/Application/Bus/QueryHandlerTest.php | 2 +- tests/Unit/Application/Bus/TestCommand.php | 2 +- .../Application/Bus/TestCommandHandler.php | 2 +- tests/Unit/Application/Bus/TestQuery.php | 2 +- .../Unit/Application/Bus/TestQueryHandler.php | 2 +- tests/Unit/Application/Bus/ValidatorTest.php | 2 +- .../DeferredDispatcherTest.php | 14 +++++------ .../DomainEventDispatching/DispatcherTest.php | 15 +++++++----- .../ListenerContainerTest.php | 6 ++--- .../Middleware/LogDomainEventDispatchTest.php | 2 +- .../TestDomainEvent.php | 2 +- .../TestImmediateDomainEvent.php | 2 +- .../DomainEventDispatching/TestListener.php | 2 +- .../TestListenerAfterCommit.php | 2 +- .../TestListenerBeforeCommit.php | 2 +- .../UnitOfWorkAwareDispatcherTest.php | 8 +++---- .../EventHandlerContainerTest.php | 12 +++++----- .../InboundEventBus/EventHandlerTest.php | 2 +- .../InboundEventDispatcherTest.php | 6 ++--- .../Middleware/SetupBeforeEventTest.php | 2 +- .../Middleware/TearDownAfterEventTest.php | 2 +- .../SwallowInboundEventTest.php | 2 +- .../InboundEventBus/TestEventHandler.php | 2 +- .../InboundEventBus/TestInboundEvent.php | 2 +- .../UnitOfWork/UnitOfWorkManagerTest.php | 2 +- tests/Unit/Bus/PsrPipeContainerTest.php | 2 +- tests/Unit/Domain/EntityTest.php | 2 +- .../Domain/EntityWithNullableGuidTest.php | 2 +- tests/Unit/Domain/IdentifierOrEntityTest.php | 2 +- .../Unit/Domain/TestEntityWithNullableId.php | 2 +- .../PsrLogExceptionReporterTest.php | 2 +- .../InfrastructureExceptionTest.php | 2 +- .../OutboundEventBus/ClosurePublisherTest.php | 10 ++++---- .../ComponentPublisherTest.php | 16 ++++++------- .../PublisherHandlerContainerTest.php | 10 ++++---- .../OutboundEventBus/PublisherHandlerTest.php | 4 ++-- .../OutboundEventBus/TestOutboundEvent.php | 2 +- .../OutboundEventBus/TestPublisher.php | 2 +- .../Infrastructure/Queue/ClosureQueueTest.php | 6 ++--- .../Queue/ComponentQueueTest.php | 6 ++--- .../Queue/EnqueuerContainerTest.php | 6 ++--- .../Infrastructure/Queue/EnqueuerTest.php | 2 +- .../Infrastructure/Queue/TestEnqueuer.php | 2 +- .../Testing/FakeDomainEventDispatcherTest.php | 17 ++++---------- .../Testing/FakeExceptionReporterTest.php | 2 +- .../FakeOutboundEventPublisherTest.php | 17 ++++---------- tests/Unit/Testing/FakeQueueTest.php | 18 ++++----------- tests/Unit/Testing/FakeUnitOfWorkTest.php | 2 +- tests/Unit/Toolkit/ContractsTest.php | 2 +- tests/Unit/Toolkit/EnumStringTest.php | 2 +- tests/Unit/Toolkit/EnumValueTest.php | 2 +- tests/Unit/Toolkit/Identifiers/GuidTest.php | 2 +- .../Toolkit/Identifiers/GuidTypeMapTest.php | 2 +- .../Toolkit/Identifiers/IntegerIdTest.php | 2 +- .../Identifiers/PossiblyNumericIdTest.php | 2 +- .../Unit/Toolkit/Identifiers/StringIdTest.php | 2 +- .../Toolkit/Identifiers/UuidFactoryTest.php | 2 +- tests/Unit/Toolkit/Identifiers/UuidTest.php | 2 +- tests/Unit/Toolkit/Identifiers/UuidV4Test.php | 2 +- tests/Unit/Toolkit/Identifiers/UuidV7Test.php | 2 +- .../Unit/Toolkit/Iterables/IsLazyListTest.php | 2 +- .../Toolkit/Iterables/IsNonEmptyListTest.php | 2 +- tests/Unit/Toolkit/ModuleBasenameTest.php | 2 +- .../Pipeline/AccumulationProcessorTest.php | 2 +- .../Pipeline/InterruptibleProcessorTest.php | 2 +- tests/Unit/Toolkit/Pipeline/LazyPipeTest.php | 2 +- .../Pipeline/MiddlewareProcessorTest.php | 2 +- .../Toolkit/Pipeline/PipeContainerTest.php | 2 +- .../Toolkit/Pipeline/PipelineBuilderTest.php | 2 +- tests/Unit/Toolkit/Pipeline/PipelineTest.php | 2 +- .../Toolkit/Pipeline/SimpleProcessorTest.php | 2 +- tests/Unit/Toolkit/Result/ErrorTest.php | 2 +- .../Result/FailedResultExceptionTest.php | 2 +- .../Toolkit/Result/KeyedSetOfErrorsTest.php | 2 +- .../Unit/Toolkit/Result/ListOfErrorsTest.php | 2 +- tests/Unit/Toolkit/Result/MetaTest.php | 2 +- tests/Unit/Toolkit/Result/ResultTest.php | 2 +- 123 files changed, 270 insertions(+), 207 deletions(-) create mode 100644 src/Contracts/Application/ApplicationException.php create mode 100644 src/Contracts/Infrastructure/InfrastructureException.php create mode 100644 src/Contracts/Toolkit/Result/FailedResultException.php diff --git a/pint.json b/pint.json index dd76040..19b8559 100644 --- a/pint.json +++ b/pint.json @@ -7,6 +7,7 @@ "binary_operator_spaces": true, "clean_namespace": true, "declare_strict_types": true, + "final_class": true, "list_syntax": true, "new_expression_parentheses": true, "no_empty_phpdoc": true, diff --git a/src/Application/ApplicationException.php b/src/Application/ApplicationException.php index 0883717..73b4908 100644 --- a/src/Application/ApplicationException.php +++ b/src/Application/ApplicationException.php @@ -12,8 +12,9 @@ namespace CloudCreativity\Modules\Application; +use CloudCreativity\Modules\Contracts\Application\ApplicationException as IApplicationException; use RuntimeException; -class ApplicationException extends RuntimeException +final class ApplicationException extends RuntimeException implements IApplicationException { } diff --git a/src/Application/Bus/AbortOnFailureException.php b/src/Application/Bus/AbortOnFailureException.php index 9e8d89d..3d8b62a 100644 --- a/src/Application/Bus/AbortOnFailureException.php +++ b/src/Application/Bus/AbortOnFailureException.php @@ -12,8 +12,25 @@ namespace CloudCreativity\Modules\Application\Bus; -use CloudCreativity\Modules\Toolkit\Result\FailedResultException; +use CloudCreativity\Modules\Contracts\Toolkit\Result\FailedResultException; +use CloudCreativity\Modules\Contracts\Toolkit\Result\Result; +use RuntimeException; -final class AbortOnFailureException extends FailedResultException +/** + * @internal + */ +final class AbortOnFailureException extends RuntimeException implements FailedResultException { + /** + * @param Result $result + */ + public function __construct(private readonly Result $result) + { + parent::__construct(); + } + + public function getResult(): Result + { + return $this->result; + } } diff --git a/src/Application/Bus/CommandQueuer.php b/src/Application/Bus/CommandQueuer.php index 243e890..9736f70 100644 --- a/src/Application/Bus/CommandQueuer.php +++ b/src/Application/Bus/CommandQueuer.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Contracts\Bus\CommandQueuer as ICommandQueuer; use CloudCreativity\Modules\Contracts\Messaging\Command; -class CommandQueuer implements ICommandQueuer +final class CommandQueuer implements ICommandQueuer { public function __construct(private readonly Queue $queue) { diff --git a/src/Application/DomainEventDispatching/DeferredDispatcher.php b/src/Application/DomainEventDispatching/DeferredDispatcher.php index bdc2cba..11886f8 100644 --- a/src/Application/DomainEventDispatching/DeferredDispatcher.php +++ b/src/Application/DomainEventDispatching/DeferredDispatcher.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Contracts\Domain\Events\DomainEvent; use CloudCreativity\Modules\Contracts\Domain\Events\OccursImmediately; -class DeferredDispatcher extends Dispatcher implements IDeferredDispatcher +abstract class DeferredDispatcher extends Dispatcher implements IDeferredDispatcher { /** * @var array diff --git a/src/Application/DomainEventDispatching/Dispatcher.php b/src/Application/DomainEventDispatching/Dispatcher.php index f74ce6f..fa568ca 100644 --- a/src/Application/DomainEventDispatching/Dispatcher.php +++ b/src/Application/DomainEventDispatching/Dispatcher.php @@ -26,7 +26,7 @@ use Psr\Container\ContainerInterface; use ReflectionClass; -class Dispatcher implements DomainEventDispatcher +abstract class Dispatcher implements DomainEventDispatcher { private readonly IListenerContainer $listeners; diff --git a/src/Application/DomainEventDispatching/UnitOfWorkAwareDispatcher.php b/src/Application/DomainEventDispatching/UnitOfWorkAwareDispatcher.php index 93a18ed..7dcf6bd 100644 --- a/src/Application/DomainEventDispatching/UnitOfWorkAwareDispatcher.php +++ b/src/Application/DomainEventDispatching/UnitOfWorkAwareDispatcher.php @@ -20,7 +20,7 @@ use Psr\Container\ContainerInterface; use Psr\Log\LoggerInterface; -class UnitOfWorkAwareDispatcher extends Dispatcher +abstract class UnitOfWorkAwareDispatcher extends Dispatcher { public function __construct( private readonly UnitOfWorkManager $unitOfWorkManager, diff --git a/src/Bus/BusException.php b/src/Bus/BusException.php index b991db6..9e60777 100644 --- a/src/Bus/BusException.php +++ b/src/Bus/BusException.php @@ -14,6 +14,6 @@ use RuntimeException; -class BusException extends RuntimeException +final class BusException extends RuntimeException { } diff --git a/src/Bus/CommandDispatcher.php b/src/Bus/CommandDispatcher.php index 76a698d..4c2fe6a 100644 --- a/src/Bus/CommandDispatcher.php +++ b/src/Bus/CommandDispatcher.php @@ -23,7 +23,7 @@ use Psr\Container\ContainerInterface; use ReflectionClass; -class CommandDispatcher implements ICommandDispatcher +abstract class CommandDispatcher implements ICommandDispatcher { private readonly ICommandHandlerContainer $handlers; diff --git a/src/Bus/InboundEventDispatcher.php b/src/Bus/InboundEventDispatcher.php index d0861df..fc95922 100644 --- a/src/Bus/InboundEventDispatcher.php +++ b/src/Bus/InboundEventDispatcher.php @@ -21,7 +21,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\Through; use Psr\Container\ContainerInterface; -class InboundEventDispatcher implements IInboundEventDispatcher +abstract class InboundEventDispatcher implements IInboundEventDispatcher { private readonly IEventHandlerContainer $handlers; diff --git a/src/Bus/QueryDispatcher.php b/src/Bus/QueryDispatcher.php index 5ee1b95..aa9084c 100644 --- a/src/Bus/QueryDispatcher.php +++ b/src/Bus/QueryDispatcher.php @@ -23,7 +23,7 @@ use Psr\Container\ContainerInterface; use ReflectionClass; -class QueryDispatcher implements IQueryDispatcher +abstract class QueryDispatcher implements IQueryDispatcher { private readonly IQueryHandlerContainer $handlers; diff --git a/src/Contracts/Application/ApplicationException.php b/src/Contracts/Application/ApplicationException.php new file mode 100644 index 0000000..ad2ebb1 --- /dev/null +++ b/src/Contracts/Application/ApplicationException.php @@ -0,0 +1,19 @@ + + */ + public function getResult(): Result; +} diff --git a/src/Infrastructure/InfrastructureException.php b/src/Infrastructure/InfrastructureException.php index a184fbd..b7b0c3e 100644 --- a/src/Infrastructure/InfrastructureException.php +++ b/src/Infrastructure/InfrastructureException.php @@ -12,8 +12,9 @@ namespace CloudCreativity\Modules\Infrastructure; +use CloudCreativity\Modules\Contracts\Infrastructure\InfrastructureException as IInfrastructureException; use RuntimeException; -class InfrastructureException extends RuntimeException +final class InfrastructureException extends RuntimeException implements IInfrastructureException { } diff --git a/src/Infrastructure/OutboundEventBus/ClosurePublisher.php b/src/Infrastructure/OutboundEventBus/ClosurePublisher.php index f731b12..a06456f 100644 --- a/src/Infrastructure/OutboundEventBus/ClosurePublisher.php +++ b/src/Infrastructure/OutboundEventBus/ClosurePublisher.php @@ -23,7 +23,7 @@ use Psr\Container\ContainerInterface; use ReflectionClass; -class ClosurePublisher implements OutboundEventPublisher +abstract class ClosurePublisher implements OutboundEventPublisher { private readonly ?IPipeContainer $middleware; diff --git a/src/Infrastructure/OutboundEventBus/ComponentPublisher.php b/src/Infrastructure/OutboundEventBus/ComponentPublisher.php index 2bda8ac..8fda100 100644 --- a/src/Infrastructure/OutboundEventBus/ComponentPublisher.php +++ b/src/Infrastructure/OutboundEventBus/ComponentPublisher.php @@ -23,7 +23,7 @@ use Psr\Container\ContainerInterface; use ReflectionClass; -class ComponentPublisher implements OutboundEventPublisher +abstract class ComponentPublisher implements OutboundEventPublisher { private readonly IPublisherHandlerContainer $handlers; diff --git a/src/Infrastructure/Queue/ClosureQueue.php b/src/Infrastructure/Queue/ClosureQueue.php index d48dee0..5d02f94 100644 --- a/src/Infrastructure/Queue/ClosureQueue.php +++ b/src/Infrastructure/Queue/ClosureQueue.php @@ -23,7 +23,7 @@ use Psr\Container\ContainerInterface; use ReflectionClass; -class ClosureQueue implements Queue +abstract class ClosureQueue implements Queue { private readonly ?IPipeContainer $middleware; diff --git a/src/Infrastructure/Queue/ComponentQueue.php b/src/Infrastructure/Queue/ComponentQueue.php index 0dbe681..c565ffa 100644 --- a/src/Infrastructure/Queue/ComponentQueue.php +++ b/src/Infrastructure/Queue/ComponentQueue.php @@ -23,7 +23,7 @@ use Psr\Container\ContainerInterface; use ReflectionClass; -class ComponentQueue implements Queue +abstract class ComponentQueue implements Queue { private readonly IEnqueuerContainer $enqueuers; diff --git a/src/Testing/FakeDomainEventDispatcher.php b/src/Testing/FakeDomainEventDispatcher.php index a7ffef5..63e57a6 100644 --- a/src/Testing/FakeDomainEventDispatcher.php +++ b/src/Testing/FakeDomainEventDispatcher.php @@ -24,7 +24,7 @@ * @implements ArrayAccess * @implements IteratorAggregate */ -class FakeDomainEventDispatcher implements DomainEventDispatcher, Countable, ArrayAccess, IteratorAggregate +abstract class FakeDomainEventDispatcher implements DomainEventDispatcher, Countable, ArrayAccess, IteratorAggregate { /** * @var list diff --git a/src/Testing/FakeOutboundEventPublisher.php b/src/Testing/FakeOutboundEventPublisher.php index b411565..b2e7430 100644 --- a/src/Testing/FakeOutboundEventPublisher.php +++ b/src/Testing/FakeOutboundEventPublisher.php @@ -24,7 +24,7 @@ * @implements ArrayAccess * @implements IteratorAggregate */ -class FakeOutboundEventPublisher implements OutboundEventPublisher, Countable, ArrayAccess, IteratorAggregate +abstract class FakeOutboundEventPublisher implements OutboundEventPublisher, Countable, ArrayAccess, IteratorAggregate { /** * @var list diff --git a/src/Testing/FakeQueue.php b/src/Testing/FakeQueue.php index 95316f3..610d870 100644 --- a/src/Testing/FakeQueue.php +++ b/src/Testing/FakeQueue.php @@ -24,7 +24,7 @@ * @implements ArrayAccess * @implements IteratorAggregate */ -class FakeQueue implements Queue, Countable, ArrayAccess, IteratorAggregate +abstract class FakeQueue implements Queue, Countable, ArrayAccess, IteratorAggregate { /** * @var list diff --git a/src/Toolkit/ContractException.php b/src/Toolkit/ContractException.php index 6cf2691..812473a 100644 --- a/src/Toolkit/ContractException.php +++ b/src/Toolkit/ContractException.php @@ -14,6 +14,6 @@ use LogicException; -class ContractException extends LogicException +final class ContractException extends LogicException { } diff --git a/src/Toolkit/Result/ContextualResult.php b/src/Toolkit/Result/ContextualResult.php index 7f0707f..b4d1144 100644 --- a/src/Toolkit/Result/ContextualResult.php +++ b/src/Toolkit/Result/ContextualResult.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Contracts\Toolkit\Result\Error; use CloudCreativity\Modules\Contracts\Toolkit\Result\Result; -readonly class ContextualResult implements Contextual +final readonly class ContextualResult implements Contextual { /** * @param Result $result diff --git a/src/Toolkit/Result/FailedResultException.php b/src/Toolkit/Result/FailedResultException.php index 96851bb..75b0fa0 100644 --- a/src/Toolkit/Result/FailedResultException.php +++ b/src/Toolkit/Result/FailedResultException.php @@ -12,13 +12,14 @@ namespace CloudCreativity\Modules\Toolkit\Result; +use CloudCreativity\Modules\Contracts\Toolkit\Result\FailedResultException as IFailedResultException; use CloudCreativity\Modules\Contracts\Toolkit\Result\Result; use RuntimeException; use Throwable; use function CloudCreativity\Modules\Toolkit\enum_string; -class FailedResultException extends RuntimeException +final class FailedResultException extends RuntimeException implements IFailedResultException { /** * @param Result $result diff --git a/tests/Integration/Application/DomainEventDispatching/MathDomainEventDispatcherTest.php b/tests/Integration/Application/DomainEventDispatching/MathDomainEventDispatcherTest.php index 03681b1..6328a07 100644 --- a/tests/Integration/Application/DomainEventDispatching/MathDomainEventDispatcherTest.php +++ b/tests/Integration/Application/DomainEventDispatching/MathDomainEventDispatcherTest.php @@ -17,7 +17,7 @@ use CloudCreativity\Modules\Testing\FakeContainer; use PHPUnit\Framework\TestCase; -class MathDomainEventDispatcherTest extends TestCase +final class MathDomainEventDispatcherTest extends TestCase { public function test(): void { diff --git a/tests/Integration/Bus/MathCommandBusTest.php b/tests/Integration/Bus/MathCommandBusTest.php index 805b2bd..54e2dd4 100644 --- a/tests/Integration/Bus/MathCommandBusTest.php +++ b/tests/Integration/Bus/MathCommandBusTest.php @@ -18,7 +18,7 @@ use CloudCreativity\Modules\Testing\FakeContainer; use PHPUnit\Framework\TestCase; -class MathCommandBusTest extends TestCase +final class MathCommandBusTest extends TestCase { public function test(): void { diff --git a/tests/Integration/Bus/MathEventBusTest.php b/tests/Integration/Bus/MathEventBusTest.php index 40e53f7..b22873e 100644 --- a/tests/Integration/Bus/MathEventBusTest.php +++ b/tests/Integration/Bus/MathEventBusTest.php @@ -18,7 +18,7 @@ use CloudCreativity\Modules\Testing\FakeContainer; use PHPUnit\Framework\TestCase; -class MathEventBusTest extends TestCase +final class MathEventBusTest extends TestCase { public function test(): void { diff --git a/tests/Integration/Bus/MathQueryBusTest.php b/tests/Integration/Bus/MathQueryBusTest.php index d07e027..6c8589d 100644 --- a/tests/Integration/Bus/MathQueryBusTest.php +++ b/tests/Integration/Bus/MathQueryBusTest.php @@ -17,7 +17,7 @@ use CloudCreativity\Modules\Testing\FakeContainer; use PHPUnit\Framework\TestCase; -class MathQueryBusTest extends TestCase +final class MathQueryBusTest extends TestCase { public function test(): void { diff --git a/tests/Integration/Infrastructure/OutboundEventBus/MathEventPublisherTest.php b/tests/Integration/Infrastructure/OutboundEventBus/MathEventPublisherTest.php index 4879346..62c30dd 100644 --- a/tests/Integration/Infrastructure/OutboundEventBus/MathEventPublisherTest.php +++ b/tests/Integration/Infrastructure/OutboundEventBus/MathEventPublisherTest.php @@ -19,7 +19,7 @@ use CloudCreativity\Modules\Tests\Integration\Bus\NumbersSubtracted; use PHPUnit\Framework\TestCase; -class MathEventPublisherTest extends TestCase +final class MathEventPublisherTest extends TestCase { public function test(): void { diff --git a/tests/Integration/Infrastructure/OutboundEventBus/TestClosurePublisherTest.php b/tests/Integration/Infrastructure/OutboundEventBus/TestClosurePublisherTest.php index c363dc0..9774956 100644 --- a/tests/Integration/Infrastructure/OutboundEventBus/TestClosurePublisherTest.php +++ b/tests/Integration/Infrastructure/OutboundEventBus/TestClosurePublisherTest.php @@ -17,7 +17,7 @@ use CloudCreativity\Modules\Tests\Integration\Bus\NumbersAdded; use PHPUnit\Framework\TestCase; -class TestClosurePublisherTest extends TestCase +final class TestClosurePublisherTest extends TestCase { public function test(): void { diff --git a/tests/Integration/Infrastructure/Queue/MathQueueTest.php b/tests/Integration/Infrastructure/Queue/MathQueueTest.php index a8d8b3d..03b237f 100644 --- a/tests/Integration/Infrastructure/Queue/MathQueueTest.php +++ b/tests/Integration/Infrastructure/Queue/MathQueueTest.php @@ -19,7 +19,7 @@ use CloudCreativity\Modules\Tests\Integration\Bus\MultiplyCommand; use PHPUnit\Framework\TestCase; -class MathQueueTest extends TestCase +final class MathQueueTest extends TestCase { public function test(): void { diff --git a/tests/Integration/Infrastructure/Queue/TestClosureQueueTest.php b/tests/Integration/Infrastructure/Queue/TestClosureQueueTest.php index 21daf3e..aba5dc8 100644 --- a/tests/Integration/Infrastructure/Queue/TestClosureQueueTest.php +++ b/tests/Integration/Infrastructure/Queue/TestClosureQueueTest.php @@ -17,7 +17,7 @@ use CloudCreativity\Modules\Tests\Integration\Bus\AddCommand; use PHPUnit\Framework\TestCase; -class TestClosureQueueTest extends TestCase +final class TestClosureQueueTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Application/ApplicationExceptionTest.php b/tests/Unit/Application/ApplicationExceptionTest.php index 40814cd..f02d759 100644 --- a/tests/Unit/Application/ApplicationExceptionTest.php +++ b/tests/Unit/Application/ApplicationExceptionTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class ApplicationExceptionTest extends TestCase +final class ApplicationExceptionTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Application/Bus/CommandDispatcherTest.php b/tests/Unit/Application/Bus/CommandDispatcherTest.php index 4b6920a..42942aa 100644 --- a/tests/Unit/Application/Bus/CommandDispatcherTest.php +++ b/tests/Unit/Application/Bus/CommandDispatcherTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class CommandDispatcherTest extends TestCase +final class CommandDispatcherTest extends TestCase { private CommandHandlerContainer&MockObject $handlers; @@ -38,10 +38,10 @@ protected function setUp(): void { parent::setUp(); - $this->dispatcher = new CommandDispatcher( + $this->dispatcher = new class ( handlers: $this->handlers = $this->createMock(CommandHandlerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends CommandDispatcher {}; } protected function tearDown(): void diff --git a/tests/Unit/Application/Bus/CommandHandlerContainerTest.php b/tests/Unit/Application/Bus/CommandHandlerContainerTest.php index efa1019..eaf35e6 100644 --- a/tests/Unit/Application/Bus/CommandHandlerContainerTest.php +++ b/tests/Unit/Application/Bus/CommandHandlerContainerTest.php @@ -19,11 +19,11 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -class CommandHandlerContainerTest extends TestCase +final class CommandHandlerContainerTest extends TestCase { public function testItResolvesUsingClosureBindings(): void { - $a = new TestCommandHandler(); + $a = new class () extends TestCommandHandler {}; $b = $this->createStub(TestCommandHandler::class); $command1 = new class () implements Command {}; @@ -45,7 +45,7 @@ public function testItResolvesUsingClosureBindings(): void public function testItResolvesViaPsrContainer(): void { - $a = new TestCommandHandler(); + $a = new class () extends TestCommandHandler {}; $b = $this->createStub(TestCommandHandler::class); $command1 = new class () implements Command {}; diff --git a/tests/Unit/Application/Bus/CommandHandlerTest.php b/tests/Unit/Application/Bus/CommandHandlerTest.php index cd28309..ee8fc2c 100644 --- a/tests/Unit/Application/Bus/CommandHandlerTest.php +++ b/tests/Unit/Application/Bus/CommandHandlerTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Result\Result; use PHPUnit\Framework\TestCase; -class CommandHandlerTest extends TestCase +final class CommandHandlerTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Application/Bus/CommandQueuerTest.php b/tests/Unit/Application/Bus/CommandQueuerTest.php index 06ee712..da5fdc3 100644 --- a/tests/Unit/Application/Bus/CommandQueuerTest.php +++ b/tests/Unit/Application/Bus/CommandQueuerTest.php @@ -17,7 +17,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class CommandQueuerTest extends TestCase +final class CommandQueuerTest extends TestCase { private MockObject&Queue $queue; diff --git a/tests/Unit/Application/Bus/Middleware/ExecuteInUnitOfWorkTest.php b/tests/Unit/Application/Bus/Middleware/ExecuteInUnitOfWorkTest.php index 6d15798..e090764 100644 --- a/tests/Unit/Application/Bus/Middleware/ExecuteInUnitOfWorkTest.php +++ b/tests/Unit/Application/Bus/Middleware/ExecuteInUnitOfWorkTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\TestCase; use Throwable; -class ExecuteInUnitOfWorkTest extends TestCase +final class ExecuteInUnitOfWorkTest extends TestCase { /** * @var array diff --git a/tests/Unit/Application/Bus/Middleware/FlushDeferredEventsTest.php b/tests/Unit/Application/Bus/Middleware/FlushDeferredEventsTest.php index 481bd1d..1512ad5 100644 --- a/tests/Unit/Application/Bus/Middleware/FlushDeferredEventsTest.php +++ b/tests/Unit/Application/Bus/Middleware/FlushDeferredEventsTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class FlushDeferredEventsTest extends TestCase +final class FlushDeferredEventsTest extends TestCase { private DeferredDispatcher&MockObject $dispatcher; diff --git a/tests/Unit/Application/Bus/Middleware/LogMessageDispatchTest.php b/tests/Unit/Application/Bus/Middleware/LogMessageDispatchTest.php index db57cd1..89d4ffa 100644 --- a/tests/Unit/Application/Bus/Middleware/LogMessageDispatchTest.php +++ b/tests/Unit/Application/Bus/Middleware/LogMessageDispatchTest.php @@ -24,7 +24,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; -class LogMessageDispatchTest extends TestCase +final class LogMessageDispatchTest extends TestCase { private LoggerInterface&Stub $logger; diff --git a/tests/Unit/Application/Bus/Middleware/SetupBeforeDispatchTest.php b/tests/Unit/Application/Bus/Middleware/SetupBeforeDispatchTest.php index 25a1f02..50c3fea 100644 --- a/tests/Unit/Application/Bus/Middleware/SetupBeforeDispatchTest.php +++ b/tests/Unit/Application/Bus/Middleware/SetupBeforeDispatchTest.php @@ -20,7 +20,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class SetupBeforeDispatchTest extends TestCase +final class SetupBeforeDispatchTest extends TestCase { /** * @var array diff --git a/tests/Unit/Application/Bus/Middleware/TearDownAfterDispatchTest.php b/tests/Unit/Application/Bus/Middleware/TearDownAfterDispatchTest.php index d8d5d0b..00dbab7 100644 --- a/tests/Unit/Application/Bus/Middleware/TearDownAfterDispatchTest.php +++ b/tests/Unit/Application/Bus/Middleware/TearDownAfterDispatchTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class TearDownAfterDispatchTest extends TestCase +final class TearDownAfterDispatchTest extends TestCase { public function testItInvokesCallbackAfterSuccess(): void { diff --git a/tests/Unit/Application/Bus/Middleware/ValidateMessageTest.php b/tests/Unit/Application/Bus/Middleware/ValidateMessageTest.php index 2a0ac6d..20602b3 100644 --- a/tests/Unit/Application/Bus/Middleware/ValidateMessageTest.php +++ b/tests/Unit/Application/Bus/Middleware/ValidateMessageTest.php @@ -24,7 +24,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ValidateMessageTest extends TestCase +final class ValidateMessageTest extends TestCase { /** * @var MockObject&Validator diff --git a/tests/Unit/Application/Bus/QueryDispatcherTest.php b/tests/Unit/Application/Bus/QueryDispatcherTest.php index 7a6595f..1801b7a 100644 --- a/tests/Unit/Application/Bus/QueryDispatcherTest.php +++ b/tests/Unit/Application/Bus/QueryDispatcherTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class QueryDispatcherTest extends TestCase +final class QueryDispatcherTest extends TestCase { /** * @var MockObject&QueryHandlerContainer @@ -44,10 +44,10 @@ protected function setUp(): void { parent::setUp(); - $this->dispatcher = new QueryDispatcher( + $this->dispatcher = new class ( handlers: $this->handlers = $this->createMock(QueryHandlerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends QueryDispatcher {}; } protected function tearDown(): void diff --git a/tests/Unit/Application/Bus/QueryHandlerContainerTest.php b/tests/Unit/Application/Bus/QueryHandlerContainerTest.php index 24c83e8..9f7388d 100644 --- a/tests/Unit/Application/Bus/QueryHandlerContainerTest.php +++ b/tests/Unit/Application/Bus/QueryHandlerContainerTest.php @@ -19,11 +19,11 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -class QueryHandlerContainerTest extends TestCase +final class QueryHandlerContainerTest extends TestCase { public function testItResolvesClosureBindings(): void { - $a = new TestQueryHandler(); + $a = new class () extends TestQueryHandler {}; $b = $this->createStub(TestQueryHandler::class); $query1 = new class () implements Query {}; @@ -45,7 +45,7 @@ public function testItResolvesClosureBindings(): void public function testItResolvesViaPsrContainer(): void { - $a = new TestQueryHandler(); + $a = new class () extends TestQueryHandler {}; $b = $this->createStub(TestQueryHandler::class); $query1 = new class () implements Query {}; diff --git a/tests/Unit/Application/Bus/QueryHandlerTest.php b/tests/Unit/Application/Bus/QueryHandlerTest.php index d7fdb82..01b5c74 100644 --- a/tests/Unit/Application/Bus/QueryHandlerTest.php +++ b/tests/Unit/Application/Bus/QueryHandlerTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Result\Result; use PHPUnit\Framework\TestCase; -class QueryHandlerTest extends TestCase +final class QueryHandlerTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Application/Bus/TestCommand.php b/tests/Unit/Application/Bus/TestCommand.php index e778cdf..0e040f4 100644 --- a/tests/Unit/Application/Bus/TestCommand.php +++ b/tests/Unit/Application/Bus/TestCommand.php @@ -14,7 +14,7 @@ use CloudCreativity\Modules\Contracts\Messaging\Command; -class TestCommand implements Command +final class TestCommand implements Command { public function __construct(public bool $fail = false) { diff --git a/tests/Unit/Application/Bus/TestCommandHandler.php b/tests/Unit/Application/Bus/TestCommandHandler.php index f5bc76c..671860f 100644 --- a/tests/Unit/Application/Bus/TestCommandHandler.php +++ b/tests/Unit/Application/Bus/TestCommandHandler.php @@ -17,7 +17,7 @@ use CloudCreativity\Modules\Toolkit\Identifiers\Uuid; use CloudCreativity\Modules\Toolkit\Result\Result; -class TestCommandHandler implements DispatchThroughMiddleware +abstract class TestCommandHandler implements DispatchThroughMiddleware { /** * Execute the command. diff --git a/tests/Unit/Application/Bus/TestQuery.php b/tests/Unit/Application/Bus/TestQuery.php index 4bd7666..abd7a97 100644 --- a/tests/Unit/Application/Bus/TestQuery.php +++ b/tests/Unit/Application/Bus/TestQuery.php @@ -14,6 +14,6 @@ use CloudCreativity\Modules\Contracts\Messaging\Query; -class TestQuery implements Query +final class TestQuery implements Query { } diff --git a/tests/Unit/Application/Bus/TestQueryHandler.php b/tests/Unit/Application/Bus/TestQueryHandler.php index 8a7e98e..9442a7e 100644 --- a/tests/Unit/Application/Bus/TestQueryHandler.php +++ b/tests/Unit/Application/Bus/TestQueryHandler.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Contracts\Bus\DispatchThroughMiddleware; use CloudCreativity\Modules\Toolkit\Result\Result; -class TestQueryHandler implements DispatchThroughMiddleware +abstract class TestQueryHandler implements DispatchThroughMiddleware { /** * Execute the query. diff --git a/tests/Unit/Application/Bus/ValidatorTest.php b/tests/Unit/Application/Bus/ValidatorTest.php index c6ae6ab..f6beba2 100644 --- a/tests/Unit/Application/Bus/ValidatorTest.php +++ b/tests/Unit/Application/Bus/ValidatorTest.php @@ -23,7 +23,7 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -class ValidatorTest extends TestCase +final class ValidatorTest extends TestCase { /** * @return array> diff --git a/tests/Unit/Application/DomainEventDispatching/DeferredDispatcherTest.php b/tests/Unit/Application/DomainEventDispatching/DeferredDispatcherTest.php index ca71e21..6a107c7 100644 --- a/tests/Unit/Application/DomainEventDispatching/DeferredDispatcherTest.php +++ b/tests/Unit/Application/DomainEventDispatching/DeferredDispatcherTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class DeferredDispatcherTest extends TestCase +final class DeferredDispatcherTest extends TestCase { private ListenerContainer&MockObject $listeners; @@ -36,10 +36,10 @@ protected function setUp(): void { parent::setUp(); - $this->dispatcher = new DeferredDispatcher( + $this->dispatcher = new class ( listeners: $this->listeners = $this->createMock(ListenerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends DeferredDispatcher {}; } public function testItDispatchesImmediately(): void @@ -108,7 +108,7 @@ public function testItDispatchesImmediately(): void public function testItFlushesDeferredEvents(): void { $sequence = []; - $event1 = new TestDomainEvent(); + $event1 = new class () extends TestDomainEvent {}; $event2 = $this->createMock(DomainEvent::class); $listener1 = $this->createMock(TestListener::class); @@ -179,7 +179,7 @@ public function testItFlushesDeferredEvents(): void public function testItFlushesDeferredEventsIncludingEventsDispatchedByListeners(): void { $sequence = []; - $event1 = new TestDomainEvent(); + $event1 = new class () extends TestDomainEvent {}; $event2 = $this->createMock(DomainEvent::class); $listener1 = $this->createMock(TestListener::class); @@ -235,7 +235,7 @@ public function testItFlushesDeferredEventsIncludingEventsDispatchedByListeners( public function testItForgetsDeferredEvents(): void { $sequence = []; - $deferred = new TestDomainEvent(); + $deferred = new class () extends TestDomainEvent {}; $immediate = new TestImmediateDomainEvent(); $listener1 = $this->createMock(TestListener::class); @@ -296,7 +296,7 @@ public function testItForgetsDeferredEvents(): void public function testItForgetsDeferredEventsAfterException(): void { $sequence = []; - $event1 = new TestDomainEvent(); + $event1 = new class () extends TestDomainEvent {}; $event2 = $this->createMock(DomainEvent::class); $expected = new \LogicException('Boom!'); diff --git a/tests/Unit/Application/DomainEventDispatching/DispatcherTest.php b/tests/Unit/Application/DomainEventDispatching/DispatcherTest.php index 212aa00..968473f 100644 --- a/tests/Unit/Application/DomainEventDispatching/DispatcherTest.php +++ b/tests/Unit/Application/DomainEventDispatching/DispatcherTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class DispatcherTest extends TestCase +final class DispatcherTest extends TestCase { private ListenerContainer&MockObject $listeners; @@ -33,17 +33,18 @@ protected function setUp(): void { parent::setUp(); - $this->dispatcher = new Dispatcher( + $this->dispatcher = new class ( listeners: $this->listeners = $this->createMock(ListenerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends Dispatcher {}; } public function testItDispatchesImmediately(): void { $sequence = []; $event1 = new TestImmediateDomainEvent(); - $event2 = new TestDomainEvent(); + $event2 = new class () extends TestDomainEvent {}; + ; $listener1 = $this->createMock(TestListener::class); $listener2 = $this->createMock(TestListener::class); @@ -110,8 +111,10 @@ public function testNoListeners(): void public function testItDispatchesThroughMiddleware(): void { - $event1 = new TestDomainEvent(); - $event2 = new TestDomainEvent(); + $event1 = new class () extends TestDomainEvent {}; + ; + $event2 = new class () extends TestDomainEvent {}; + ; $event3 = new TestImmediateDomainEvent(); $a = function ($actual, Closure $next) use ($event1, $event2): DomainEvent { diff --git a/tests/Unit/Application/DomainEventDispatching/ListenerContainerTest.php b/tests/Unit/Application/DomainEventDispatching/ListenerContainerTest.php index a5e85ee..fc1cfa3 100644 --- a/tests/Unit/Application/DomainEventDispatching/ListenerContainerTest.php +++ b/tests/Unit/Application/DomainEventDispatching/ListenerContainerTest.php @@ -15,14 +15,14 @@ use CloudCreativity\Modules\Application\DomainEventDispatching\ListenerContainer; use PHPUnit\Framework\TestCase; -class ListenerContainerTest extends TestCase +final class ListenerContainerTest extends TestCase { public function testItCreatesListener(): void { $container = new ListenerContainer(); - $listener = new TestListener(); + $listener = new class () extends TestListener {}; - $container->bind('bar', fn () => new TestListener()); + $container->bind('bar', fn () => new class () extends TestListener {}); $container->bind('foo', fn () => $listener); $this->assertSame($listener, $container->get('foo')); diff --git a/tests/Unit/Application/DomainEventDispatching/Middleware/LogDomainEventDispatchTest.php b/tests/Unit/Application/DomainEventDispatching/Middleware/LogDomainEventDispatchTest.php index e327c14..c0ffa34 100644 --- a/tests/Unit/Application/DomainEventDispatching/Middleware/LogDomainEventDispatchTest.php +++ b/tests/Unit/Application/DomainEventDispatching/Middleware/LogDomainEventDispatchTest.php @@ -21,7 +21,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; -class LogDomainEventDispatchTest extends TestCase +final class LogDomainEventDispatchTest extends TestCase { /** * @var LoggerInterface&MockObject diff --git a/tests/Unit/Application/DomainEventDispatching/TestDomainEvent.php b/tests/Unit/Application/DomainEventDispatching/TestDomainEvent.php index 260c524..6018e12 100644 --- a/tests/Unit/Application/DomainEventDispatching/TestDomainEvent.php +++ b/tests/Unit/Application/DomainEventDispatching/TestDomainEvent.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Contracts\Domain\Events\DomainEvent; use DateTimeImmutable; -class TestDomainEvent implements DomainEvent +abstract class TestDomainEvent implements DomainEvent { public function getOccurredAt(): DateTimeImmutable { diff --git a/tests/Unit/Application/DomainEventDispatching/TestImmediateDomainEvent.php b/tests/Unit/Application/DomainEventDispatching/TestImmediateDomainEvent.php index 31ea3b3..fb860e5 100644 --- a/tests/Unit/Application/DomainEventDispatching/TestImmediateDomainEvent.php +++ b/tests/Unit/Application/DomainEventDispatching/TestImmediateDomainEvent.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Contracts\Domain\Events\OccursImmediately; use DateTimeImmutable; -class TestImmediateDomainEvent implements DomainEvent, OccursImmediately +final class TestImmediateDomainEvent implements DomainEvent, OccursImmediately { public function getOccurredAt(): DateTimeImmutable { diff --git a/tests/Unit/Application/DomainEventDispatching/TestListener.php b/tests/Unit/Application/DomainEventDispatching/TestListener.php index fc53e48..27d27ee 100644 --- a/tests/Unit/Application/DomainEventDispatching/TestListener.php +++ b/tests/Unit/Application/DomainEventDispatching/TestListener.php @@ -14,7 +14,7 @@ use CloudCreativity\Modules\Contracts\Domain\Events\DomainEvent; -class TestListener +abstract class TestListener { /** * Handle the event. diff --git a/tests/Unit/Application/DomainEventDispatching/TestListenerAfterCommit.php b/tests/Unit/Application/DomainEventDispatching/TestListenerAfterCommit.php index c7717e1..daaf7d9 100644 --- a/tests/Unit/Application/DomainEventDispatching/TestListenerAfterCommit.php +++ b/tests/Unit/Application/DomainEventDispatching/TestListenerAfterCommit.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Contracts\Application\UnitOfWork\DispatchAfterCommit; use CloudCreativity\Modules\Contracts\Domain\Events\DomainEvent; -class TestListenerAfterCommit implements DispatchAfterCommit +abstract class TestListenerAfterCommit implements DispatchAfterCommit { /** * Handle the event. diff --git a/tests/Unit/Application/DomainEventDispatching/TestListenerBeforeCommit.php b/tests/Unit/Application/DomainEventDispatching/TestListenerBeforeCommit.php index ecae6e3..5c7073d 100644 --- a/tests/Unit/Application/DomainEventDispatching/TestListenerBeforeCommit.php +++ b/tests/Unit/Application/DomainEventDispatching/TestListenerBeforeCommit.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Contracts\Application\UnitOfWork\DispatchBeforeCommit; use CloudCreativity\Modules\Contracts\Domain\Events\DomainEvent; -class TestListenerBeforeCommit implements DispatchBeforeCommit +abstract class TestListenerBeforeCommit implements DispatchBeforeCommit { /** * Handle the event. diff --git a/tests/Unit/Application/DomainEventDispatching/UnitOfWorkAwareDispatcherTest.php b/tests/Unit/Application/DomainEventDispatching/UnitOfWorkAwareDispatcherTest.php index b303cde..0b7a6cd 100644 --- a/tests/Unit/Application/DomainEventDispatching/UnitOfWorkAwareDispatcherTest.php +++ b/tests/Unit/Application/DomainEventDispatching/UnitOfWorkAwareDispatcherTest.php @@ -25,7 +25,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class UnitOfWorkAwareDispatcherTest extends TestCase +final class UnitOfWorkAwareDispatcherTest extends TestCase { private ListenerContainer&MockObject $listeners; @@ -42,11 +42,11 @@ protected function setUp(): void { parent::setUp(); - $this->dispatcher = new UnitOfWorkAwareDispatcher( + $this->dispatcher = new class ( unitOfWorkManager: $this->unitOfWorkManager = $this->createMock(UnitOfWorkManager::class), listeners: $this->listeners = $this->createMock(ListenerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends UnitOfWorkAwareDispatcher {}; } public function testItDispatchesImmediately(): void @@ -179,7 +179,7 @@ public function testItDoesNotDispatchImmediately(): void #[Depends('testItDoesNotDispatchImmediately')] public function testItDispatchesEventInBeforeCommitCallback(): void { - $event = new TestDomainEvent(); + $event = new class () extends TestDomainEvent {}; $listener1 = $this->createMock(TestListener::class); $listener2 = $this->createMock(TestListener::class); diff --git a/tests/Unit/Application/InboundEventBus/EventHandlerContainerTest.php b/tests/Unit/Application/InboundEventBus/EventHandlerContainerTest.php index 1971d13..9b321d5 100644 --- a/tests/Unit/Application/InboundEventBus/EventHandlerContainerTest.php +++ b/tests/Unit/Application/InboundEventBus/EventHandlerContainerTest.php @@ -19,11 +19,11 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -class EventHandlerContainerTest extends TestCase +final class EventHandlerContainerTest extends TestCase { public function testItHasHandlerBindings(): void { - $a = new TestEventHandler(); + $a = new class () extends TestEventHandler {}; $b = $this->createStub(TestEventHandler::class); $container = new EventHandlerContainer(); @@ -36,7 +36,7 @@ public function testItHasHandlerBindings(): void public function testItUsesPsrContainer(): void { - $a = new TestEventHandler(); + $a = new class () extends TestEventHandler {}; $b = $this->createStub(TestEventHandler::class); $psrContainer = $this->createMock(ContainerInterface::class); @@ -59,7 +59,7 @@ public function testItUsesPsrContainer(): void public function testItHasBoundDefaultHandler(): void { - $a = new TestEventHandler(); + $a = new class () extends TestEventHandler {}; $b = $this->createStub(TestEventHandler::class); $container = new EventHandlerContainer(default: fn () => $b); @@ -71,7 +71,7 @@ public function testItHasBoundDefaultHandler(): void public function testItHasDefaultHandlerInPsrContainer(): void { - $a = new TestEventHandler(); + $a = new class () extends TestEventHandler {}; $b = $this->createStub(TestEventHandler::class); $psrContainer = $this->createMock(ContainerInterface::class); @@ -92,7 +92,7 @@ public function testItHasDefaultHandlerInPsrContainer(): void public function testItDoesNotHaveHandler(): void { $container = new EventHandlerContainer(); - $container->bind(TestInboundEvent::class, fn () => new TestEventHandler()); + $container->bind(TestInboundEvent::class, fn () => new class () extends TestEventHandler {}); $this->expectException(BusException::class); $this->expectExceptionMessage( diff --git a/tests/Unit/Application/InboundEventBus/EventHandlerTest.php b/tests/Unit/Application/InboundEventBus/EventHandlerTest.php index 3de0d4a..0aa8750 100644 --- a/tests/Unit/Application/InboundEventBus/EventHandlerTest.php +++ b/tests/Unit/Application/InboundEventBus/EventHandlerTest.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Bus\EventHandler; use PHPUnit\Framework\TestCase; -class EventHandlerTest extends TestCase +final class EventHandlerTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Application/InboundEventBus/InboundEventDispatcherTest.php b/tests/Unit/Application/InboundEventBus/InboundEventDispatcherTest.php index 1331479..537eb34 100644 --- a/tests/Unit/Application/InboundEventBus/InboundEventDispatcherTest.php +++ b/tests/Unit/Application/InboundEventBus/InboundEventDispatcherTest.php @@ -20,7 +20,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class InboundEventDispatcherTest extends TestCase +final class InboundEventDispatcherTest extends TestCase { private EventHandlerContainer&MockObject $handlers; @@ -37,10 +37,10 @@ protected function setUp(): void { parent::setUp(); - $this->dispatcher = new InboundEventDispatcher( + $this->dispatcher = new class ( handlers: $this->handlers = $this->createMock(EventHandlerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends InboundEventDispatcher {}; } protected function tearDown(): void diff --git a/tests/Unit/Application/InboundEventBus/Middleware/SetupBeforeEventTest.php b/tests/Unit/Application/InboundEventBus/Middleware/SetupBeforeEventTest.php index f9bf231..149d8bd 100644 --- a/tests/Unit/Application/InboundEventBus/Middleware/SetupBeforeEventTest.php +++ b/tests/Unit/Application/InboundEventBus/Middleware/SetupBeforeEventTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class SetupBeforeEventTest extends TestCase +final class SetupBeforeEventTest extends TestCase { /** * @var array diff --git a/tests/Unit/Application/InboundEventBus/Middleware/TearDownAfterEventTest.php b/tests/Unit/Application/InboundEventBus/Middleware/TearDownAfterEventTest.php index 1a55f55..9cbf072 100644 --- a/tests/Unit/Application/InboundEventBus/Middleware/TearDownAfterEventTest.php +++ b/tests/Unit/Application/InboundEventBus/Middleware/TearDownAfterEventTest.php @@ -17,7 +17,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class TearDownAfterEventTest extends TestCase +final class TearDownAfterEventTest extends TestCase { public function testItInvokesCallbackAfterSuccess(): void { diff --git a/tests/Unit/Application/InboundEventBus/SwallowInboundEventTest.php b/tests/Unit/Application/InboundEventBus/SwallowInboundEventTest.php index bb12bde..9a49822 100644 --- a/tests/Unit/Application/InboundEventBus/SwallowInboundEventTest.php +++ b/tests/Unit/Application/InboundEventBus/SwallowInboundEventTest.php @@ -18,7 +18,7 @@ use Psr\Log\LoggerInterface; use Psr\Log\LogLevel; -class SwallowInboundEventTest extends TestCase +final class SwallowInboundEventTest extends TestCase { public function testItDoesNothing(): void { diff --git a/tests/Unit/Application/InboundEventBus/TestEventHandler.php b/tests/Unit/Application/InboundEventBus/TestEventHandler.php index 0bbbc84..2b8ee41 100644 --- a/tests/Unit/Application/InboundEventBus/TestEventHandler.php +++ b/tests/Unit/Application/InboundEventBus/TestEventHandler.php @@ -14,7 +14,7 @@ use CloudCreativity\Modules\Contracts\Bus\DispatchThroughMiddleware; -class TestEventHandler implements DispatchThroughMiddleware +abstract class TestEventHandler implements DispatchThroughMiddleware { public function handle(TestInboundEvent $command): void { diff --git a/tests/Unit/Application/InboundEventBus/TestInboundEvent.php b/tests/Unit/Application/InboundEventBus/TestInboundEvent.php index ba18ecf..73385de 100644 --- a/tests/Unit/Application/InboundEventBus/TestInboundEvent.php +++ b/tests/Unit/Application/InboundEventBus/TestInboundEvent.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Identifiers\UuidV4; use DateTimeImmutable; -class TestInboundEvent implements IntegrationEvent +final class TestInboundEvent implements IntegrationEvent { public function getUuid(): UuidV4 { diff --git a/tests/Unit/Application/UnitOfWork/UnitOfWorkManagerTest.php b/tests/Unit/Application/UnitOfWork/UnitOfWorkManagerTest.php index 401a46b..7def504 100644 --- a/tests/Unit/Application/UnitOfWork/UnitOfWorkManagerTest.php +++ b/tests/Unit/Application/UnitOfWork/UnitOfWorkManagerTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class UnitOfWorkManagerTest extends TestCase +final class UnitOfWorkManagerTest extends TestCase { private MockObject&UnitOfWork $unitOfWork; diff --git a/tests/Unit/Bus/PsrPipeContainerTest.php b/tests/Unit/Bus/PsrPipeContainerTest.php index 89cc210..a7508e8 100644 --- a/tests/Unit/Bus/PsrPipeContainerTest.php +++ b/tests/Unit/Bus/PsrPipeContainerTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -class PsrPipeContainerTest extends TestCase +final class PsrPipeContainerTest extends TestCase { public function testItResolvesBoundPipes(): void { diff --git a/tests/Unit/Domain/EntityTest.php b/tests/Unit/Domain/EntityTest.php index fed5fde..68ee901 100644 --- a/tests/Unit/Domain/EntityTest.php +++ b/tests/Unit/Domain/EntityTest.php @@ -19,7 +19,7 @@ use CloudCreativity\Modules\Toolkit\Identifiers\IntegerId; use PHPUnit\Framework\TestCase; -class EntityTest extends TestCase +final class EntityTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Domain/EntityWithNullableGuidTest.php b/tests/Unit/Domain/EntityWithNullableGuidTest.php index 83eea10..63af723 100644 --- a/tests/Unit/Domain/EntityWithNullableGuidTest.php +++ b/tests/Unit/Domain/EntityWithNullableGuidTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; -class EntityWithNullableGuidTest extends TestCase +final class EntityWithNullableGuidTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Domain/IdentifierOrEntityTest.php b/tests/Unit/Domain/IdentifierOrEntityTest.php index bea82c3..1ca1159 100644 --- a/tests/Unit/Domain/IdentifierOrEntityTest.php +++ b/tests/Unit/Domain/IdentifierOrEntityTest.php @@ -17,7 +17,7 @@ use CloudCreativity\Modules\Toolkit\Identifiers\Guid; use PHPUnit\Framework\TestCase; -class IdentifierOrEntityTest extends TestCase +final class IdentifierOrEntityTest extends TestCase { public function testItIsAGuid(): void { diff --git a/tests/Unit/Domain/TestEntityWithNullableId.php b/tests/Unit/Domain/TestEntityWithNullableId.php index 870112a..5678546 100644 --- a/tests/Unit/Domain/TestEntityWithNullableId.php +++ b/tests/Unit/Domain/TestEntityWithNullableId.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Contracts\Toolkit\Identifiers\Identifier; use CloudCreativity\Modules\Domain\IsEntityWithNullableId; -class TestEntityWithNullableId implements Entity +final class TestEntityWithNullableId implements Entity { use IsEntityWithNullableId; diff --git a/tests/Unit/Infrastructure/ExceptionReporter/PsrLogExceptionReporterTest.php b/tests/Unit/Infrastructure/ExceptionReporter/PsrLogExceptionReporterTest.php index 9fc7968..9a038cb 100644 --- a/tests/Unit/Infrastructure/ExceptionReporter/PsrLogExceptionReporterTest.php +++ b/tests/Unit/Infrastructure/ExceptionReporter/PsrLogExceptionReporterTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\TestCase; use Psr\Log\LoggerInterface; -class PsrLogExceptionReporterTest extends TestCase +final class PsrLogExceptionReporterTest extends TestCase { private LoggerInterface&MockObject $logger; diff --git a/tests/Unit/Infrastructure/InfrastructureExceptionTest.php b/tests/Unit/Infrastructure/InfrastructureExceptionTest.php index 7cf9e5f..0509300 100644 --- a/tests/Unit/Infrastructure/InfrastructureExceptionTest.php +++ b/tests/Unit/Infrastructure/InfrastructureExceptionTest.php @@ -16,7 +16,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class InfrastructureExceptionTest extends TestCase +final class InfrastructureExceptionTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Infrastructure/OutboundEventBus/ClosurePublisherTest.php b/tests/Unit/Infrastructure/OutboundEventBus/ClosurePublisherTest.php index 177751f..c61d0a2 100644 --- a/tests/Unit/Infrastructure/OutboundEventBus/ClosurePublisherTest.php +++ b/tests/Unit/Infrastructure/OutboundEventBus/ClosurePublisherTest.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -class ClosurePublisherTest extends TestCase +final class ClosurePublisherTest extends TestCase { /** * @var array @@ -119,7 +119,7 @@ public function testWithMiddlewareViaPsrContainer(): void public function testWithAlternativeHandlers(): void { - $expected = new TestOutboundEvent(); + $expected = new class () extends TestOutboundEvent {}; $stub = $this->createStub(IntegrationEvent::class); $actual = null; @@ -130,7 +130,7 @@ public function testWithAlternativeHandlers(): void }); $publisher->bind( - TestOutboundEvent::class, + $expected::class, function (TestOutboundEvent $in) use (&$actual) { $actual = $in; }, @@ -144,11 +144,11 @@ function (TestOutboundEvent $in) use (&$actual) { private function createPublisher(ContainerInterface|IPipeContainer|null $middleware = null): ClosurePublisher { - return new ClosurePublisher( + return new class ( function (IntegrationEvent $event): void { $this->actual[] = $event; }, $middleware, - ); + ) extends ClosurePublisher {}; } } diff --git a/tests/Unit/Infrastructure/OutboundEventBus/ComponentPublisherTest.php b/tests/Unit/Infrastructure/OutboundEventBus/ComponentPublisherTest.php index 951cda0..bd1082b 100644 --- a/tests/Unit/Infrastructure/OutboundEventBus/ComponentPublisherTest.php +++ b/tests/Unit/Infrastructure/OutboundEventBus/ComponentPublisherTest.php @@ -20,7 +20,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ComponentPublisherTest extends TestCase +final class ComponentPublisherTest extends TestCase { /** * @var MockObject&PublisherHandlerContainer @@ -40,10 +40,10 @@ protected function setUp(): void { parent::setUp(); - $this->publisher = new ComponentPublisher( + $this->publisher = new class ( handlers: $this->handlers = $this->createMock(PublisherHandlerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends ComponentPublisher {}; } protected function tearDown(): void @@ -54,7 +54,7 @@ protected function tearDown(): void public function testPublish(): void { - $event = new TestOutboundEvent(); + $event = new class () extends TestOutboundEvent {}; $this->handlers ->expects($this->once()) @@ -72,9 +72,9 @@ public function testPublish(): void public function testPublishWithMiddleware(): void { - $event1 = new TestOutboundEvent(); - $event2 = new TestOutboundEvent(); - $event3 = new TestOutboundEvent(); + $event1 = new class () extends TestOutboundEvent {}; + $event2 = new class () extends TestOutboundEvent {}; + $event3 = new class () extends TestOutboundEvent {}; $middleware1 = function ($actual, Closure $next) use ($event1, $event2): void { $this->assertSame($event1, $actual); @@ -106,7 +106,7 @@ public function testPublishWithMiddleware(): void $this->handlers ->expects($this->once()) ->method('get') - ->with($event1::class) + ->with($event3::class) ->willReturnCallback(function () use ($handler) { $this->assertSame(['before1', 'before2'], $this->sequence); return $handler; diff --git a/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerContainerTest.php b/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerContainerTest.php index fe2e1f3..67de852 100644 --- a/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerContainerTest.php +++ b/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerContainerTest.php @@ -18,11 +18,11 @@ use Psr\Container\ContainerInterface; use RuntimeException; -class PublisherHandlerContainerTest extends TestCase +final class PublisherHandlerContainerTest extends TestCase { public function testItPublishesViaBindingsWithoutDefaultHandler(): void { - $a = new TestPublisher(); + $a = new class () extends TestPublisher {}; $b = $this->createStub(TestPublisher::class); $event1 = new class () extends TestOutboundEvent {}; @@ -44,7 +44,7 @@ public function testItPublishesViaBindingsWithoutDefaultHandler(): void public function testItPublishesViaBindingsWithDefaultHandler(): void { - $a = new TestPublisher(); + $a = new class () extends TestPublisher {}; $b = $this->createStub(TestPublisher::class); $event1 = new class () extends TestOutboundEvent {}; @@ -61,7 +61,7 @@ public function testItPublishesViaBindingsWithDefaultHandler(): void public function testItPublishesViaPsrContainerWithoutDefaultHandler(): void { - $a = new TestPublisher(); + $a = new class () extends TestPublisher {}; $b = $this->createStub(TestPublisher::class); $event1 = new class () extends TestOutboundEvent {}; @@ -93,7 +93,7 @@ public function testItPublishesViaPsrContainerWithoutDefaultHandler(): void public function testItPublishesViaPsrContainerWithDefaultHandler(): void { - $a = new TestPublisher(); + $a = new class () extends TestPublisher {}; $b = $this->createStub(TestPublisher::class); $event1 = new class () extends TestOutboundEvent {}; diff --git a/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerTest.php b/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerTest.php index 9596c86..2d20587 100644 --- a/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerTest.php +++ b/tests/Unit/Infrastructure/OutboundEventBus/PublisherHandlerTest.php @@ -16,11 +16,11 @@ use CloudCreativity\Modules\Infrastructure\OutboundEventBus\PublisherHandler; use PHPUnit\Framework\TestCase; -class PublisherHandlerTest extends TestCase +final class PublisherHandlerTest extends TestCase { public function test(): void { - $event = new TestOutboundEvent(); + $event = new class () extends TestOutboundEvent {}; $innerHandler = $this->createMock(TestPublisher::class); $innerHandler diff --git a/tests/Unit/Infrastructure/OutboundEventBus/TestOutboundEvent.php b/tests/Unit/Infrastructure/OutboundEventBus/TestOutboundEvent.php index 8ec0322..470561e 100644 --- a/tests/Unit/Infrastructure/OutboundEventBus/TestOutboundEvent.php +++ b/tests/Unit/Infrastructure/OutboundEventBus/TestOutboundEvent.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Identifiers\UuidV4; use DateTimeImmutable; -class TestOutboundEvent implements IntegrationEvent +abstract class TestOutboundEvent implements IntegrationEvent { public readonly UuidV4 $uuid; diff --git a/tests/Unit/Infrastructure/OutboundEventBus/TestPublisher.php b/tests/Unit/Infrastructure/OutboundEventBus/TestPublisher.php index ebb57bc..90cca39 100644 --- a/tests/Unit/Infrastructure/OutboundEventBus/TestPublisher.php +++ b/tests/Unit/Infrastructure/OutboundEventBus/TestPublisher.php @@ -12,7 +12,7 @@ namespace CloudCreativity\Modules\Tests\Unit\Infrastructure\OutboundEventBus; -class TestPublisher +abstract class TestPublisher { /** * Publish the integration event. diff --git a/tests/Unit/Infrastructure/Queue/ClosureQueueTest.php b/tests/Unit/Infrastructure/Queue/ClosureQueueTest.php index 12de5c2..45d2a2b 100644 --- a/tests/Unit/Infrastructure/Queue/ClosureQueueTest.php +++ b/tests/Unit/Infrastructure/Queue/ClosureQueueTest.php @@ -19,7 +19,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ClosureQueueTest extends TestCase +final class ClosureQueueTest extends TestCase { private MockObject&PipeContainer $middleware; @@ -34,12 +34,12 @@ protected function setUp(): void { parent::setUp(); - $this->queue = new ClosureQueue( + $this->queue = new class ( function (Command $command): void { $this->actual[] = $command; }, $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends ClosureQueue {}; } protected function tearDown(): void diff --git a/tests/Unit/Infrastructure/Queue/ComponentQueueTest.php b/tests/Unit/Infrastructure/Queue/ComponentQueueTest.php index 2682135..88be922 100644 --- a/tests/Unit/Infrastructure/Queue/ComponentQueueTest.php +++ b/tests/Unit/Infrastructure/Queue/ComponentQueueTest.php @@ -20,7 +20,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class ComponentQueueTest extends TestCase +final class ComponentQueueTest extends TestCase { private EnqueuerContainer&MockObject $enqueuers; @@ -37,10 +37,10 @@ protected function setUp(): void { parent::setUp(); - $this->queue = new ComponentQueue( + $this->queue = new class ( enqueuers: $this->enqueuers = $this->createMock(EnqueuerContainer::class), middleware: $this->middleware = $this->createMock(PipeContainer::class), - ); + ) extends ComponentQueue {}; } protected function tearDown(): void diff --git a/tests/Unit/Infrastructure/Queue/EnqueuerContainerTest.php b/tests/Unit/Infrastructure/Queue/EnqueuerContainerTest.php index a478f17..0533395 100644 --- a/tests/Unit/Infrastructure/Queue/EnqueuerContainerTest.php +++ b/tests/Unit/Infrastructure/Queue/EnqueuerContainerTest.php @@ -19,14 +19,14 @@ use PHPUnit\Framework\TestCase; use Psr\Container\ContainerInterface; -class EnqueuerContainerTest extends TestCase +final class EnqueuerContainerTest extends TestCase { public function testItUsesBindings(): void { $command1 = new class () implements Command {}; $command2 = new class () implements Command {}; - $a = new TestEnqueuer(); + $a = new class () extends TestEnqueuer {}; $b = $this->createStub(TestEnqueuer::class); $default = $this->createStub(TestEnqueuer::class); @@ -44,7 +44,7 @@ public function testItUsesPsrContainer(): void $command1 = new class () implements Command {}; $command2 = new class () implements Command {}; - $a = new TestEnqueuer(); + $a = new class () extends TestEnqueuer {}; $b = $this->createStub(TestEnqueuer::class); $default = $this->createStub(TestEnqueuer::class); diff --git a/tests/Unit/Infrastructure/Queue/EnqueuerTest.php b/tests/Unit/Infrastructure/Queue/EnqueuerTest.php index 7c18dd9..c7f2422 100644 --- a/tests/Unit/Infrastructure/Queue/EnqueuerTest.php +++ b/tests/Unit/Infrastructure/Queue/EnqueuerTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Infrastructure\Queue\Enqueuer; use PHPUnit\Framework\TestCase; -class EnqueuerTest extends TestCase +final class EnqueuerTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Infrastructure/Queue/TestEnqueuer.php b/tests/Unit/Infrastructure/Queue/TestEnqueuer.php index 8a1b845..aa9beef 100644 --- a/tests/Unit/Infrastructure/Queue/TestEnqueuer.php +++ b/tests/Unit/Infrastructure/Queue/TestEnqueuer.php @@ -14,7 +14,7 @@ use CloudCreativity\Modules\Contracts\Messaging\Command; -class TestEnqueuer +abstract class TestEnqueuer { public function push(Command $command): void { diff --git a/tests/Unit/Testing/FakeDomainEventDispatcherTest.php b/tests/Unit/Testing/FakeDomainEventDispatcherTest.php index 67ed90a..46752b6 100644 --- a/tests/Unit/Testing/FakeDomainEventDispatcherTest.php +++ b/tests/Unit/Testing/FakeDomainEventDispatcherTest.php @@ -18,11 +18,11 @@ use LogicException; use PHPUnit\Framework\TestCase; -class FakeDomainEventDispatcherTest extends TestCase +final class FakeDomainEventDispatcherTest extends TestCase { public function testItPublishesEvents(): void { - $dispatcher = new FakeDomainEventDispatcher(); + $dispatcher = new class () extends FakeDomainEventDispatcher {}; $event1 = $this->createMock(DomainEvent::class); $event2 = $this->createMock(DomainEvent::class); @@ -42,7 +42,7 @@ public function testItPublishesEvents(): void public function testItReturnsSoleEvent(): void { - $dispatcher = new FakeDomainEventDispatcher(); + $dispatcher = new class () extends FakeDomainEventDispatcher {}; $event = $this->createMock(DomainEvent::class); $dispatcher->dispatch($event); @@ -52,7 +52,7 @@ public function testItReturnsSoleEvent(): void public function testItThrowsExceptionIfNoEvents(): void { - $dispatcher = new FakeDomainEventDispatcher(); + $dispatcher = new class () extends FakeDomainEventDispatcher {}; $this->expectException(LogicException::class); $this->expectExceptionMessage('Expected one event to be dispatched but there are 0 events.'); @@ -62,7 +62,7 @@ public function testItThrowsExceptionIfNoEvents(): void public function testItThrowsExceptionIfMultipleEvents(): void { - $dispatcher = new FakeDomainEventDispatcher(); + $dispatcher = new class () extends FakeDomainEventDispatcher {}; $event1 = $this->createMock(DomainEvent::class); $event2 = $this->createMock(DomainEvent::class); @@ -74,11 +74,4 @@ public function testItThrowsExceptionIfMultipleEvents(): void $dispatcher->sole(); } - - public function testItCanBeExtended(): void - { - $dispatcher = new class () extends FakeDomainEventDispatcher {}; - $dispatcher->dispatch($this->createMock(DomainEvent::class)); - $this->assertCount(1, $dispatcher->events); - } } diff --git a/tests/Unit/Testing/FakeExceptionReporterTest.php b/tests/Unit/Testing/FakeExceptionReporterTest.php index 3848d88..5f872f0 100644 --- a/tests/Unit/Testing/FakeExceptionReporterTest.php +++ b/tests/Unit/Testing/FakeExceptionReporterTest.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class FakeExceptionReporterTest extends TestCase +final class FakeExceptionReporterTest extends TestCase { public function testItReportsExceptions(): void { diff --git a/tests/Unit/Testing/FakeOutboundEventPublisherTest.php b/tests/Unit/Testing/FakeOutboundEventPublisherTest.php index e30b3c4..6c2def8 100644 --- a/tests/Unit/Testing/FakeOutboundEventPublisherTest.php +++ b/tests/Unit/Testing/FakeOutboundEventPublisherTest.php @@ -18,11 +18,11 @@ use LogicException; use PHPUnit\Framework\TestCase; -class FakeOutboundEventPublisherTest extends TestCase +final class FakeOutboundEventPublisherTest extends TestCase { public function testItPublishesEvents(): void { - $publisher = new FakeOutboundEventPublisher(); + $publisher = new class () extends FakeOutboundEventPublisher {}; $event1 = $this->createMock(IntegrationEvent::class); $event2 = $this->createMock(IntegrationEvent::class); @@ -40,7 +40,7 @@ public function testItPublishesEvents(): void public function testItReturnsSoleEvent(): void { - $publisher = new FakeOutboundEventPublisher(); + $publisher = new class () extends FakeOutboundEventPublisher {}; $event = $this->createMock(IntegrationEvent::class); $publisher->publish($event); @@ -50,7 +50,7 @@ public function testItReturnsSoleEvent(): void public function testItThrowsExceptionIfNoEvents(): void { - $publisher = new FakeOutboundEventPublisher(); + $publisher = new class () extends FakeOutboundEventPublisher {}; $this->expectException(LogicException::class); $this->expectExceptionMessage('Expected one event to be published but there are 0 events.'); @@ -60,7 +60,7 @@ public function testItThrowsExceptionIfNoEvents(): void public function testItThrowsExceptionIfMultipleEvents(): void { - $publisher = new FakeOutboundEventPublisher(); + $publisher = new class () extends FakeOutboundEventPublisher {}; $event1 = $this->createMock(IntegrationEvent::class); $event2 = $this->createMock(IntegrationEvent::class); @@ -72,11 +72,4 @@ public function testItThrowsExceptionIfMultipleEvents(): void $publisher->sole(); } - - public function testItCanBeExtended(): void - { - $publisher = new class () extends FakeOutboundEventPublisher {}; - $publisher->publish($this->createMock(IntegrationEvent::class)); - $this->assertCount(1, $publisher->events); - } } diff --git a/tests/Unit/Testing/FakeQueueTest.php b/tests/Unit/Testing/FakeQueueTest.php index 7d0356d..65ebd49 100644 --- a/tests/Unit/Testing/FakeQueueTest.php +++ b/tests/Unit/Testing/FakeQueueTest.php @@ -18,11 +18,11 @@ use LogicException; use PHPUnit\Framework\TestCase; -class FakeQueueTest extends TestCase +final class FakeQueueTest extends TestCase { public function testItQueuesCommands(): void { - $queue = new FakeQueue(); + $queue = new class () extends FakeQueue {}; $queue->push($command1 = $this->createMock(Command::class)); $queue->push($command2 = $this->createMock(Command::class)); @@ -36,7 +36,7 @@ public function testItQueuesCommands(): void public function testItHasSoleCommand(): void { - $queue = new FakeQueue(); + $queue = new class () extends FakeQueue {}; $queue->push($command = $this->createMock(Command::class)); $this->assertSame($command, $queue->sole()); @@ -47,7 +47,7 @@ public function testItFailsWhenThereIsNoSoleCommand(): void $this->expectExceptionMessage('Expected one command in the queue but there are 0 commands.'); $this->expectException(LogicException::class); - $queue = new FakeQueue(); + $queue = new class () extends FakeQueue {}; $queue->sole(); } @@ -56,17 +56,9 @@ public function testItFailsWhenThereIsMoreThanOneSoleCommand(): void $this->expectExceptionMessage('Expected one command in the queue but there are 2 commands.'); $this->expectException(LogicException::class); - $queue = new FakeQueue(); + $queue = new class () extends FakeQueue {}; $queue->push($this->createMock(Command::class)); $queue->push($this->createMock(Command::class)); $queue->sole(); } - - public function testItCanBeExtended(): void - { - $queue = new class () extends FakeQueue {}; - - $queue->push($command = $this->createMock(Command::class)); - $this->assertSame([$command], $queue->commands); - } } diff --git a/tests/Unit/Testing/FakeUnitOfWorkTest.php b/tests/Unit/Testing/FakeUnitOfWorkTest.php index e09c1ce..fbd11fe 100644 --- a/tests/Unit/Testing/FakeUnitOfWorkTest.php +++ b/tests/Unit/Testing/FakeUnitOfWorkTest.php @@ -17,7 +17,7 @@ use PHPUnit\Framework\TestCase; use RuntimeException; -class FakeUnitOfWorkTest extends TestCase +final class FakeUnitOfWorkTest extends TestCase { public function testItIsSuccessfulOnFirstAttempt(): void { diff --git a/tests/Unit/Toolkit/ContractsTest.php b/tests/Unit/Toolkit/ContractsTest.php index 9b35aad..2849b65 100644 --- a/tests/Unit/Toolkit/ContractsTest.php +++ b/tests/Unit/Toolkit/ContractsTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Contracts; use PHPUnit\Framework\TestCase; -class ContractsTest extends TestCase +final class ContractsTest extends TestCase { public function testItDoesNotThrowWhenPreconditionIsTrue(): void { diff --git a/tests/Unit/Toolkit/EnumStringTest.php b/tests/Unit/Toolkit/EnumStringTest.php index e0406ad..911ddc1 100644 --- a/tests/Unit/Toolkit/EnumStringTest.php +++ b/tests/Unit/Toolkit/EnumStringTest.php @@ -21,7 +21,7 @@ use function CloudCreativity\Modules\Toolkit\enum_string; -class EnumStringTest extends TestCase +final class EnumStringTest extends TestCase { /** * @return array diff --git a/tests/Unit/Toolkit/EnumValueTest.php b/tests/Unit/Toolkit/EnumValueTest.php index 137ce19..d4776b2 100644 --- a/tests/Unit/Toolkit/EnumValueTest.php +++ b/tests/Unit/Toolkit/EnumValueTest.php @@ -21,7 +21,7 @@ use function CloudCreativity\Modules\Toolkit\enum_value; -class EnumValueTest extends TestCase +final class EnumValueTest extends TestCase { /** * @return array diff --git a/tests/Unit/Toolkit/Identifiers/GuidTest.php b/tests/Unit/Toolkit/Identifiers/GuidTest.php index 51bec62..3fdc963 100644 --- a/tests/Unit/Toolkit/Identifiers/GuidTest.php +++ b/tests/Unit/Toolkit/Identifiers/GuidTest.php @@ -28,7 +28,7 @@ use Ramsey\Uuid\UuidInterface; use UnitEnum; -class GuidTest extends TestCase +final class GuidTest extends TestCase { /** * @return array> diff --git a/tests/Unit/Toolkit/Identifiers/GuidTypeMapTest.php b/tests/Unit/Toolkit/Identifiers/GuidTypeMapTest.php index b4cf6e2..f417769 100644 --- a/tests/Unit/Toolkit/Identifiers/GuidTypeMapTest.php +++ b/tests/Unit/Toolkit/Identifiers/GuidTypeMapTest.php @@ -22,7 +22,7 @@ use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; -class GuidTypeMapTest extends TestCase +final class GuidTypeMapTest extends TestCase { public function testItReturnsExpectedType(): GuidTypeMap { diff --git a/tests/Unit/Toolkit/Identifiers/IntegerIdTest.php b/tests/Unit/Toolkit/Identifiers/IntegerIdTest.php index fc1ea81..45f9581 100644 --- a/tests/Unit/Toolkit/Identifiers/IntegerIdTest.php +++ b/tests/Unit/Toolkit/Identifiers/IntegerIdTest.php @@ -22,7 +22,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -class IntegerIdTest extends TestCase +final class IntegerIdTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Identifiers/PossiblyNumericIdTest.php b/tests/Unit/Toolkit/Identifiers/PossiblyNumericIdTest.php index c7cde74..4e96faa 100644 --- a/tests/Unit/Toolkit/Identifiers/PossiblyNumericIdTest.php +++ b/tests/Unit/Toolkit/Identifiers/PossiblyNumericIdTest.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -class PossiblyNumericIdTest extends TestCase +final class PossiblyNumericIdTest extends TestCase { /** * @return array> diff --git a/tests/Unit/Toolkit/Identifiers/StringIdTest.php b/tests/Unit/Toolkit/Identifiers/StringIdTest.php index 3ceb99e..8e4f453 100644 --- a/tests/Unit/Toolkit/Identifiers/StringIdTest.php +++ b/tests/Unit/Toolkit/Identifiers/StringIdTest.php @@ -21,7 +21,7 @@ use PHPUnit\Framework\Attributes\DataProvider; use PHPUnit\Framework\TestCase; -class StringIdTest extends TestCase +final class StringIdTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Identifiers/UuidFactoryTest.php b/tests/Unit/Toolkit/Identifiers/UuidFactoryTest.php index 59e09ad..83e6dbb 100644 --- a/tests/Unit/Toolkit/Identifiers/UuidFactoryTest.php +++ b/tests/Unit/Toolkit/Identifiers/UuidFactoryTest.php @@ -27,7 +27,7 @@ use Ramsey\Uuid\UuidFactory as BaseUuidFactory; use Ramsey\Uuid\UuidFactoryInterface as BaseUuidFactoryInterface; -class UuidFactoryTest extends TestCase +final class UuidFactoryTest extends TestCase { private BaseUuidFactory&MockObject $baseFactory; diff --git a/tests/Unit/Toolkit/Identifiers/UuidTest.php b/tests/Unit/Toolkit/Identifiers/UuidTest.php index e07cd57..935bc39 100644 --- a/tests/Unit/Toolkit/Identifiers/UuidTest.php +++ b/tests/Unit/Toolkit/Identifiers/UuidTest.php @@ -23,7 +23,7 @@ use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid as RamseyUuid; -class UuidTest extends TestCase +final class UuidTest extends TestCase { protected function tearDown(): void { diff --git a/tests/Unit/Toolkit/Identifiers/UuidV4Test.php b/tests/Unit/Toolkit/Identifiers/UuidV4Test.php index 1007de1..bf6d60c 100644 --- a/tests/Unit/Toolkit/Identifiers/UuidV4Test.php +++ b/tests/Unit/Toolkit/Identifiers/UuidV4Test.php @@ -24,7 +24,7 @@ use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid as RamseyUuid; -class UuidV4Test extends TestCase +final class UuidV4Test extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Identifiers/UuidV7Test.php b/tests/Unit/Toolkit/Identifiers/UuidV7Test.php index 4626076..d0d6a52 100644 --- a/tests/Unit/Toolkit/Identifiers/UuidV7Test.php +++ b/tests/Unit/Toolkit/Identifiers/UuidV7Test.php @@ -24,7 +24,7 @@ use PHPUnit\Framework\TestCase; use Ramsey\Uuid\Uuid as RamseyUuid; -class UuidV7Test extends TestCase +final class UuidV7Test extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Iterables/IsLazyListTest.php b/tests/Unit/Toolkit/Iterables/IsLazyListTest.php index 7befbbb..0d32e93 100644 --- a/tests/Unit/Toolkit/Iterables/IsLazyListTest.php +++ b/tests/Unit/Toolkit/Iterables/IsLazyListTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Iterables\IsLazyList; use PHPUnit\Framework\TestCase; -class IsLazyListTest extends TestCase +final class IsLazyListTest extends TestCase { public function testItIteratesOverList(): void { diff --git a/tests/Unit/Toolkit/Iterables/IsNonEmptyListTest.php b/tests/Unit/Toolkit/Iterables/IsNonEmptyListTest.php index aa89c04..95fb30e 100644 --- a/tests/Unit/Toolkit/Iterables/IsNonEmptyListTest.php +++ b/tests/Unit/Toolkit/Iterables/IsNonEmptyListTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Iterables\IsNonEmptyList; use PHPUnit\Framework\TestCase; -class IsNonEmptyListTest extends TestCase +final class IsNonEmptyListTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/ModuleBasenameTest.php b/tests/Unit/Toolkit/ModuleBasenameTest.php index e9a4871..6ea0a70 100644 --- a/tests/Unit/Toolkit/ModuleBasenameTest.php +++ b/tests/Unit/Toolkit/ModuleBasenameTest.php @@ -17,7 +17,7 @@ use PHPUnit\Framework\Attributes\Depends; use PHPUnit\Framework\TestCase; -class ModuleBasenameTest extends TestCase +final class ModuleBasenameTest extends TestCase { /** * @return array> diff --git a/tests/Unit/Toolkit/Pipeline/AccumulationProcessorTest.php b/tests/Unit/Toolkit/Pipeline/AccumulationProcessorTest.php index 41d9a52..c010e1b 100644 --- a/tests/Unit/Toolkit/Pipeline/AccumulationProcessorTest.php +++ b/tests/Unit/Toolkit/Pipeline/AccumulationProcessorTest.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\AccumulationProcessor; use PHPUnit\Framework\TestCase; -class AccumulationProcessorTest extends TestCase +final class AccumulationProcessorTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Pipeline/InterruptibleProcessorTest.php b/tests/Unit/Toolkit/Pipeline/InterruptibleProcessorTest.php index 8421818..7d8763d 100644 --- a/tests/Unit/Toolkit/Pipeline/InterruptibleProcessorTest.php +++ b/tests/Unit/Toolkit/Pipeline/InterruptibleProcessorTest.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\InterruptibleProcessor; use PHPUnit\Framework\TestCase; -class InterruptibleProcessorTest extends TestCase +final class InterruptibleProcessorTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Pipeline/LazyPipeTest.php b/tests/Unit/Toolkit/Pipeline/LazyPipeTest.php index 85ca546..09df5a7 100644 --- a/tests/Unit/Toolkit/Pipeline/LazyPipeTest.php +++ b/tests/Unit/Toolkit/Pipeline/LazyPipeTest.php @@ -18,7 +18,7 @@ use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; -class LazyPipeTest extends TestCase +final class LazyPipeTest extends TestCase { /** * @var MockObject&PipeContainer diff --git a/tests/Unit/Toolkit/Pipeline/MiddlewareProcessorTest.php b/tests/Unit/Toolkit/Pipeline/MiddlewareProcessorTest.php index 3d96ea7..44fa9df 100644 --- a/tests/Unit/Toolkit/Pipeline/MiddlewareProcessorTest.php +++ b/tests/Unit/Toolkit/Pipeline/MiddlewareProcessorTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\MiddlewareProcessor; use PHPUnit\Framework\TestCase; -class MiddlewareProcessorTest extends TestCase +final class MiddlewareProcessorTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Pipeline/PipeContainerTest.php b/tests/Unit/Toolkit/Pipeline/PipeContainerTest.php index 2ff58ec..75832ac 100644 --- a/tests/Unit/Toolkit/Pipeline/PipeContainerTest.php +++ b/tests/Unit/Toolkit/Pipeline/PipeContainerTest.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\PipeContainer; use PHPUnit\Framework\TestCase; -class PipeContainerTest extends TestCase +final class PipeContainerTest extends TestCase { public function testItResolvesBoundPipes(): void { diff --git a/tests/Unit/Toolkit/Pipeline/PipelineBuilderTest.php b/tests/Unit/Toolkit/Pipeline/PipelineBuilderTest.php index f46845e..0498f58 100644 --- a/tests/Unit/Toolkit/Pipeline/PipelineBuilderTest.php +++ b/tests/Unit/Toolkit/Pipeline/PipelineBuilderTest.php @@ -19,7 +19,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\PipelineBuilder; use PHPUnit\Framework\TestCase; -class PipelineBuilderTest extends TestCase +final class PipelineBuilderTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Pipeline/PipelineTest.php b/tests/Unit/Toolkit/Pipeline/PipelineTest.php index f0e1550..f725dc9 100644 --- a/tests/Unit/Toolkit/Pipeline/PipelineTest.php +++ b/tests/Unit/Toolkit/Pipeline/PipelineTest.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\Pipeline; use PHPUnit\Framework\TestCase; -class PipelineTest extends TestCase +final class PipelineTest extends TestCase { public function testProcess(): void { diff --git a/tests/Unit/Toolkit/Pipeline/SimpleProcessorTest.php b/tests/Unit/Toolkit/Pipeline/SimpleProcessorTest.php index dc02fab..207ef86 100644 --- a/tests/Unit/Toolkit/Pipeline/SimpleProcessorTest.php +++ b/tests/Unit/Toolkit/Pipeline/SimpleProcessorTest.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Toolkit\Pipeline\SimpleProcessor; use PHPUnit\Framework\TestCase; -class SimpleProcessorTest extends TestCase +final class SimpleProcessorTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Result/ErrorTest.php b/tests/Unit/Toolkit/Result/ErrorTest.php index 1974f11..0502cc5 100644 --- a/tests/Unit/Toolkit/Result/ErrorTest.php +++ b/tests/Unit/Toolkit/Result/ErrorTest.php @@ -19,7 +19,7 @@ use CloudCreativity\Modules\Toolkit\Result\Error; use PHPUnit\Framework\TestCase; -class ErrorTest extends TestCase +final class ErrorTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Result/FailedResultExceptionTest.php b/tests/Unit/Toolkit/Result/FailedResultExceptionTest.php index 8e03049..5094e27 100644 --- a/tests/Unit/Toolkit/Result/FailedResultExceptionTest.php +++ b/tests/Unit/Toolkit/Result/FailedResultExceptionTest.php @@ -17,7 +17,7 @@ use CloudCreativity\Modules\Toolkit\Result\Result; use PHPUnit\Framework\TestCase; -class FailedResultExceptionTest extends TestCase +final class FailedResultExceptionTest extends TestCase { public function testItFailsWithMessage(): void { diff --git a/tests/Unit/Toolkit/Result/KeyedSetOfErrorsTest.php b/tests/Unit/Toolkit/Result/KeyedSetOfErrorsTest.php index 53aeafa..ed514e2 100644 --- a/tests/Unit/Toolkit/Result/KeyedSetOfErrorsTest.php +++ b/tests/Unit/Toolkit/Result/KeyedSetOfErrorsTest.php @@ -18,7 +18,7 @@ use CloudCreativity\Modules\Toolkit\Result\ListOfErrors; use PHPUnit\Framework\TestCase; -class KeyedSetOfErrorsTest extends TestCase +final class KeyedSetOfErrorsTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Result/ListOfErrorsTest.php b/tests/Unit/Toolkit/Result/ListOfErrorsTest.php index 1911911..cd98e28 100644 --- a/tests/Unit/Toolkit/Result/ListOfErrorsTest.php +++ b/tests/Unit/Toolkit/Result/ListOfErrorsTest.php @@ -21,7 +21,7 @@ use CloudCreativity\Modules\Toolkit\Result\ListOfErrors; use PHPUnit\Framework\TestCase; -class ListOfErrorsTest extends TestCase +final class ListOfErrorsTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Result/MetaTest.php b/tests/Unit/Toolkit/Result/MetaTest.php index b0e8535..4560506 100644 --- a/tests/Unit/Toolkit/Result/MetaTest.php +++ b/tests/Unit/Toolkit/Result/MetaTest.php @@ -15,7 +15,7 @@ use CloudCreativity\Modules\Toolkit\Result\Meta; use PHPUnit\Framework\TestCase; -class MetaTest extends TestCase +final class MetaTest extends TestCase { public function test(): void { diff --git a/tests/Unit/Toolkit/Result/ResultTest.php b/tests/Unit/Toolkit/Result/ResultTest.php index 97e4216..e91f6fd 100644 --- a/tests/Unit/Toolkit/Result/ResultTest.php +++ b/tests/Unit/Toolkit/Result/ResultTest.php @@ -27,7 +27,7 @@ use function CloudCreativity\Modules\Toolkit\enum_string; -class ResultTest extends TestCase +final class ResultTest extends TestCase { public function testOk(): void { From 9ac6a0d8f45fa8e6ba239fae97a9545c1ee3283a Mon Sep 17 00:00:00 2001 From: Christopher Gammie Date: Fri, 8 May 2026 11:33:09 +0100 Subject: [PATCH 2/2] refactor: add more exception interfaces and fix command queuer --- src/Application/Bus/CommandQueuer.php | 2 +- src/Bus/BusException.php | 3 ++- src/Contracts/Bus/BusException.php | 19 +++++++++++++++++++ src/Contracts/Toolkit/ContractException.php | 19 +++++++++++++++++++ src/Toolkit/ContractException.php | 3 ++- .../Application/Bus/CommandQueuerTest.php | 4 ++-- 6 files changed, 45 insertions(+), 5 deletions(-) create mode 100644 src/Contracts/Bus/BusException.php create mode 100644 src/Contracts/Toolkit/ContractException.php diff --git a/src/Application/Bus/CommandQueuer.php b/src/Application/Bus/CommandQueuer.php index 9736f70..61b80f9 100644 --- a/src/Application/Bus/CommandQueuer.php +++ b/src/Application/Bus/CommandQueuer.php @@ -16,7 +16,7 @@ use CloudCreativity\Modules\Contracts\Bus\CommandQueuer as ICommandQueuer; use CloudCreativity\Modules\Contracts\Messaging\Command; -final class CommandQueuer implements ICommandQueuer +abstract class CommandQueuer implements ICommandQueuer { public function __construct(private readonly Queue $queue) { diff --git a/src/Bus/BusException.php b/src/Bus/BusException.php index 9e60777..f1a5881 100644 --- a/src/Bus/BusException.php +++ b/src/Bus/BusException.php @@ -12,8 +12,9 @@ namespace CloudCreativity\Modules\Bus; +use CloudCreativity\Modules\Contracts\Bus\BusException as IBusException; use RuntimeException; -final class BusException extends RuntimeException +final class BusException extends RuntimeException implements IBusException { } diff --git a/src/Contracts/Bus/BusException.php b/src/Contracts/Bus/BusException.php new file mode 100644 index 0000000..181d53a --- /dev/null +++ b/src/Contracts/Bus/BusException.php @@ -0,0 +1,19 @@ +queuer = new CommandQueuer( + $this->queuer = new class ( $this->queue = $this->createMock(Queue::class), - ); + ) extends CommandQueuer {}; } protected function tearDown(): void