From 6c5017fc0c03c13d88bbe7159c58a317d5c2713e Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Mon, 10 Feb 2025 14:11:58 +0100 Subject: [PATCH 1/9] wrong (empty) directive --- tests/Messaging/MessageDataAssertionTest.php | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/Messaging/MessageDataAssertionTest.php b/tests/Messaging/MessageDataAssertionTest.php index a927aa0..4eb755b 100644 --- a/tests/Messaging/MessageDataAssertionTest.php +++ b/tests/Messaging/MessageDataAssertionTest.php @@ -39,7 +39,6 @@ public function it_asserts_message_data_returned_by_the_no_op_message_converter( /** * @test - * @dataProvider * @dataProvider provideMessageDataWithMissingKey */ public function it_throws_exception_if_message_data_is_invalid($messageData, $errorMessage) From 35aecf8894d4516e0bf176db3c8b918678d15249 Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Mon, 10 Feb 2025 14:29:03 +0100 Subject: [PATCH 2/9] static data provider --- tests/Messaging/MessageDataAssertionTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Messaging/MessageDataAssertionTest.php b/tests/Messaging/MessageDataAssertionTest.php index 4eb755b..28f8f70 100644 --- a/tests/Messaging/MessageDataAssertionTest.php +++ b/tests/Messaging/MessageDataAssertionTest.php @@ -49,7 +49,7 @@ public function it_throws_exception_if_message_data_is_invalid($messageData, $er MessageDataAssertion::assert($messageData); } - public function provideMessageDataWithMissingKey() + public static function provideMessageDataWithMissingKey() { $uuid = Uuid::uuid4()->toString(); $payload = ['foo' => ['bar' => ['baz' => 100]]]; From 365dfbe83c55f415a767df7b95297380294deb3a Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Wed, 12 Feb 2025 13:19:34 +0100 Subject: [PATCH 3/9] fix test warn --- tests/Event/ProophActionEventEmitterTest.php | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/tests/Event/ProophActionEventEmitterTest.php b/tests/Event/ProophActionEventEmitterTest.php index 3b95331..2b10495 100644 --- a/tests/Event/ProophActionEventEmitterTest.php +++ b/tests/Event/ProophActionEventEmitterTest.php @@ -249,8 +249,10 @@ public function it_returns_false_when_unattached_listener_handler_gets_detached( /** * @test */ - public function it_dispatches_until_whith_no_listeners_attached(): void + public function it_dispatches_until_with_no_listeners_attached(): void { + $this->expectNotToPerformAssertions(); + $actionEventMock = $this->createMock(ActionEvent::class); $this->proophActionEventEmitter->dispatchUntil($actionEventMock, fn () => true); @@ -261,6 +263,8 @@ public function it_dispatches_until_whith_no_listeners_attached(): void */ public function it_attaches_to_known_event_names(): void { + $this->expectNotToPerformAssertions(); + $proophActionEventEmitter = new ProophActionEventEmitter(['foo']); $proophActionEventEmitter->attachListener('foo', function (): void { }); From b56ae2f35c7de2cd5a5ee9abb20c80fedab11f03 Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Wed, 12 Feb 2025 13:53:57 +0100 Subject: [PATCH 4/9] bumped php & phpunit --- composer.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/composer.json b/composer.json index 1ee2d7b..e04ff3b 100644 --- a/composer.json +++ b/composer.json @@ -21,13 +21,13 @@ "minimum-stability": "dev", "prefer-stable": true, "require": { - "php": "^7.4 || ^8.0", + "php": "^8.2", "ramsey/uuid": "4.1.2 || ^4.3", "beberlei/assert": "^2.7.1 || ^3.0" }, "require-dev": { "php-coveralls/php-coveralls": "^2.2", - "phpunit/phpunit": "^9.5.5", + "phpunit/phpunit": "^11.0", "prooph/bookdown-template": "^0.2.3", "prooph/php-cs-fixer-config": "^0.5" }, From 85a7cdbd6d643b0b3f0334f8a255608b13727e4f Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Wed, 12 Feb 2025 13:54:06 +0100 Subject: [PATCH 5/9] migrated phpunit conf --- phpunit.xml.dist | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/phpunit.xml.dist b/phpunit.xml.dist index d7438b6..76f01ec 100644 --- a/phpunit.xml.dist +++ b/phpunit.xml.dist @@ -1,12 +1,11 @@ - - - - ./src - - - - - ./tests/ - + + + ./tests/ + + + + ./src + + From 48bf6a7fec7174c651c6517d943cd6d08683ecdb Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Wed, 12 Feb 2025 13:55:22 +0100 Subject: [PATCH 6/9] ignore phpunit cache dir --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index f454591..6aee044 100644 --- a/.gitignore +++ b/.gitignore @@ -8,4 +8,5 @@ nbproject composer.lock .phpunit.result.cache +.phpunit.cache .phpcs-cache From 16e0ae2cbca25aacc221655a0a765863259e4956 Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Wed, 12 Feb 2025 14:00:52 +0100 Subject: [PATCH 7/9] migrate to attributes --- tests/Event/DefaultActionEventTest.php | 45 +++++------------ tests/Event/ProophActionEventEmitterTest.php | 53 ++++++-------------- tests/Messaging/CommandTest.php | 41 ++++----------- tests/Messaging/DomainEventTest.php | 29 +++-------- tests/Messaging/FQCNMessageFactoryTest.php | 17 ++----- tests/Messaging/MessageDataAssertionTest.php | 12 ++--- tests/Messaging/NoOpMessageConverterTest.php | 10 ++-- tests/Messaging/QueryTest.php | 5 +- 8 files changed, 61 insertions(+), 151 deletions(-) diff --git a/tests/Event/DefaultActionEventTest.php b/tests/Event/DefaultActionEventTest.php index b89475f..ed5ac64 100644 --- a/tests/Event/DefaultActionEventTest.php +++ b/tests/Event/DefaultActionEventTest.php @@ -13,6 +13,7 @@ namespace ProophTest\Common\Event; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Prooph\Common\Event\DefaultActionEvent; @@ -26,9 +27,7 @@ private function getTestEvent() return new DefaultActionEvent('test-event', 'target', ['param1' => 'foo']); } - /** - * @test - */ + #[Test] public function it_can_be_initialized_with_a_name_a_target_and_params(): void { $event = $this->getTestEvent(); @@ -38,9 +37,7 @@ public function it_can_be_initialized_with_a_name_a_target_and_params(): void $this->assertEquals(['param1' => 'foo'], $event->getParams()); } - /** - * @test - */ + #[Test] public function it_can_initialized_without_a_target_and_params(): void { $event = new DefaultActionEvent('test-event'); @@ -49,9 +46,7 @@ public function it_can_initialized_without_a_target_and_params(): void $this->assertEquals([], $event->getParams()); } - /** - * @test - */ + #[Test] public function it_returns_param_if_set(): void { $event = $this->getTestEvent(); @@ -60,25 +55,19 @@ public function it_returns_param_if_set(): void $this->assertEquals('bar', $event->getParam('param1')); } - /** - * @test - */ + #[Test] public function it_returns_null_if_param_is_not_set_and_no_other_default_is_given(): void { $this->assertNull($this->getTestEvent()->getParam('unknown')); } - /** - * @test - */ + #[Test] public function it_returns_default_if_param_is_not_set(): void { $this->assertEquals('default', $this->getTestEvent()->getParam('unknown', 'default')); } - /** - * @test - */ + #[Test] public function it_changes_name_when_new_one_is_set(): void { $event = $this->getTestEvent(); @@ -88,9 +77,7 @@ public function it_changes_name_when_new_one_is_set(): void $this->assertEquals('new name', $event->getName()); } - /** - * @test - */ + #[Test] public function it_overrides_params_array_if_new_one_is_set(): void { $event = $this->getTestEvent(); @@ -100,9 +87,7 @@ public function it_overrides_params_array_if_new_one_is_set(): void $this->assertEquals(['param_new' => 'bar'], $event->getParams()); } - /** - * @test - */ + #[Test] public function it_allows_object_implementing_array_access_as_params(): void { $arrayLikeObject = new \ArrayObject(['object_param' => 'baz']); @@ -114,9 +99,7 @@ public function it_allows_object_implementing_array_access_as_params(): void $this->assertSame($arrayLikeObject, $event->getParams()); } - /** - * @test - */ + #[Test] public function it_does_not_allow_params_object_that_is_not_of_type_array_access(): void { $this->expectException(\InvalidArgumentException::class); @@ -128,9 +111,7 @@ public function it_does_not_allow_params_object_that_is_not_of_type_array_access $this->getTestEvent()->setParams($stdObj); } - /** - * @test - */ + #[Test] public function it_changes_target_if_new_is_set(): void { $event = $this->getTestEvent(); @@ -142,9 +123,7 @@ public function it_changes_target_if_new_is_set(): void $this->assertSame($target, $event->getTarget()); } - /** - * @test - */ + #[Test] public function it_indicates_that_propagation_should_be_stopped(): void { $event = $this->getTestEvent(); diff --git a/tests/Event/ProophActionEventEmitterTest.php b/tests/Event/ProophActionEventEmitterTest.php index 2b10495..939196f 100644 --- a/tests/Event/ProophActionEventEmitterTest.php +++ b/tests/Event/ProophActionEventEmitterTest.php @@ -13,6 +13,7 @@ namespace ProophTest\Common\Event; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Prooph\Common\Event\ActionEvent; use Prooph\Common\Event\ListenerHandler; @@ -29,9 +30,7 @@ protected function setUp(): void $this->proophActionEventEmitter = new ProophActionEventEmitter(); } - /** - * @test - */ + #[Test] public function it_attaches_action_event_listeners_and_dispatch_event_to_them(): void { $lastEvent = null; @@ -52,9 +51,7 @@ public function it_attaches_action_event_listeners_and_dispatch_event_to_them(): $this->assertSame($lastEvent, $listener1->lastEvent); } - /** - * @test - */ + #[Test] public function it_detaches_a_listener(): void { $lastEvent = null; @@ -78,9 +75,7 @@ public function it_detaches_a_listener(): void $this->assertSame($actionEvent, $lastEvent); } - /** - * @test - */ + #[Test] public function it_triggers_listeners_until_callback_returns_true(): void { $lastEvent = null; @@ -103,9 +98,7 @@ public function it_triggers_listeners_until_callback_returns_true(): void $this->assertSame($actionEvent, $listener1->lastEvent); } - /** - * @test - */ + #[Test] public function it_stops_dispatching_when_event_propagation_is_stopped(): void { $lastEvent = null; @@ -131,9 +124,7 @@ public function it_stops_dispatching_when_event_propagation_is_stopped(): void $this->assertSame($actionEvent, $listener1->lastEvent); } - /** - * @test - */ + #[Test] public function it_stops_dispatching_when_event_propagation_is_stopped_2(): void { $lastEvent = null; @@ -160,9 +151,7 @@ public function it_stops_dispatching_when_event_propagation_is_stopped_2(): void $this->assertSame($actionEvent, $listener1->lastEvent); } - /** - * @test - */ + #[Test] public function it_triggers_listeners_with_high_priority_first(): void { $lastEvent = null; @@ -188,9 +177,7 @@ public function it_triggers_listeners_with_high_priority_first(): void $this->assertNull($listener1->lastEvent); } - /** - * @test - */ + #[Test] public function it_attaches_a_listener_aggregate(): void { $listener1 = new ActionEventListenerMock(); @@ -207,9 +194,7 @@ public function it_attaches_a_listener_aggregate(): void $this->assertNull($listener1->lastEvent); } - /** - * @test - */ + #[Test] public function it_detaches_listener_aggregate(): void { $listener1 = new ActionEventListenerMock(); @@ -227,18 +212,14 @@ public function it_detaches_listener_aggregate(): void $this->assertSame($actionEvent, $listener1->lastEvent); } - /** - * @test - */ + #[Test] public function it_uses_default_event_name_if_none_given(): void { $event = $this->proophActionEventEmitter->getNewActionEvent(); $this->assertEquals('action_event', $event->getName()); } - /** - * @test - */ + #[Test] public function it_returns_false_when_unattached_listener_handler_gets_detached(): void { $listener = $this->getMockForAbstractClass(ListenerHandler::class); @@ -246,9 +227,7 @@ public function it_returns_false_when_unattached_listener_handler_gets_detached( $this->assertFalse($this->proophActionEventEmitter->detachListener($listener)); } - /** - * @test - */ + #[Test] public function it_dispatches_until_with_no_listeners_attached(): void { $this->expectNotToPerformAssertions(); @@ -258,9 +237,7 @@ public function it_dispatches_until_with_no_listeners_attached(): void $this->proophActionEventEmitter->dispatchUntil($actionEventMock, fn () => true); } - /** - * @test - */ + #[Test] public function it_attaches_to_known_event_names(): void { $this->expectNotToPerformAssertions(); @@ -270,9 +247,7 @@ public function it_attaches_to_known_event_names(): void }); } - /** - * @test - */ + #[Test] public function it_does_not_attach_to_unknown_event_names(): void { $this->expectException(\InvalidArgumentException::class); diff --git a/tests/Messaging/CommandTest.php b/tests/Messaging/CommandTest.php index 1d2556f..d379630 100644 --- a/tests/Messaging/CommandTest.php +++ b/tests/Messaging/CommandTest.php @@ -15,6 +15,7 @@ use DateTimeImmutable; use DateTimeZone; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Prooph\Common\Messaging\Command; use Prooph\Common\Messaging\DomainMessage; @@ -44,49 +45,37 @@ protected function setUp(): void ]); } - /** - * @test - */ + #[Test] public function it_has_a_name(): void { $this->assertEquals('TestCommand', $this->command->messageName()); } - /** - * @test - */ + #[Test] public function it_has_a_uuid(): void { $this->assertTrue($this->uuid->equals($this->command->uuid())); } - /** - * @test - */ + #[Test] public function it_has_created_at_information(): void { $this->assertEquals($this->createdAt->format(\DateTime::ISO8601), $this->command->createdAt()->format(\DateTime::ISO8601)); } - /** - * @test - */ + #[Test] public function it_has_payload(): void { $this->assertEquals(['command' => 'payload'], $this->command->payload()); } - /** - * @test - */ + #[Test] public function it_has_metadata(): void { $this->assertEquals(['command' => 'metadata'], $this->command->metadata()); } - /** - * @test - */ + #[Test] public function it_can_be_converted_to_array_and_back(): void { $commandData = $this->command->toArray(); @@ -96,9 +85,7 @@ public function it_can_be_converted_to_array_and_back(): void $this->assertEquals($commandData, $commandCopy->toArray()); } - /** - * @test - */ + #[Test] public function it_returns_new_instance_with_replaced_metadata(): void { $newCommand = $this->command->withMetadata(['other' => 'metadata']); @@ -108,9 +95,7 @@ public function it_returns_new_instance_with_replaced_metadata(): void $this->assertEquals(['other' => 'metadata'], $newCommand->metadata()); } - /** - * @test - */ + #[Test] public function it_returns_new_instance_with_added_metadata(): void { $newCommand = $this->command->withAddedMetadata('other', 'metadata'); @@ -120,9 +105,7 @@ public function it_returns_new_instance_with_added_metadata(): void $this->assertEquals(['command' => 'metadata', 'other' => 'metadata'], $newCommand->metadata()); } - /** - * @test - */ + #[Test] public function it_is_initialized_with_defaults(): void { $command = new DoSomething(['command' => 'payload']); @@ -134,9 +117,7 @@ public function it_is_initialized_with_defaults(): void $this->assertEquals([], $command->metadata()); } - /** - * @test - */ + #[Test] public function it_is_of_type_command(): void { $this->assertEquals(DomainMessage::TYPE_COMMAND, $this->command->messageType()); diff --git a/tests/Messaging/DomainEventTest.php b/tests/Messaging/DomainEventTest.php index a1cfbb5..7c9e768 100644 --- a/tests/Messaging/DomainEventTest.php +++ b/tests/Messaging/DomainEventTest.php @@ -15,6 +15,7 @@ use DateTimeImmutable; use DateTimeZone; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Prooph\Common\Messaging\DomainEvent; use Prooph\Common\Messaging\DomainMessage; @@ -44,49 +45,37 @@ protected function setUp(): void ]); } - /** - * @test - */ + #[Test] public function it_has_a_name(): void { $this->assertEquals('TestDomainEvent', $this->domainEvent->messageName()); } - /** - * @test - */ + #[Test] public function it_has_a_uuid(): void { $this->assertTrue($this->uuid->equals($this->domainEvent->uuid())); } - /** - * @test - */ + #[Test] public function it_has_created_at_information(): void { $this->assertEquals($this->createdAt->format(\DateTime::ISO8601), $this->domainEvent->createdAt()->format(\DateTime::ISO8601)); } - /** - * @test - */ + #[Test] public function it_has_payload(): void { $this->assertEquals(['event' => 'payload'], $this->domainEvent->payload()); } - /** - * @test - */ + #[Test] public function it_has_metadata(): void { $this->assertEquals(['event' => 'metadata'], $this->domainEvent->metadata()); } - /** - * @test - */ + #[Test] public function it_can_be_converted_to_array_and_back(): void { $commandData = $this->domainEvent->toArray(); @@ -96,9 +85,7 @@ public function it_can_be_converted_to_array_and_back(): void $this->assertEquals($commandData, $commandCopy->toArray()); } - /** - * @test - */ + #[Test] public function it_is_of_type_event(): void { $this->assertEquals(DomainMessage::TYPE_EVENT, $this->domainEvent->messageType()); diff --git a/tests/Messaging/FQCNMessageFactoryTest.php b/tests/Messaging/FQCNMessageFactoryTest.php index f0e55e3..e54d411 100644 --- a/tests/Messaging/FQCNMessageFactoryTest.php +++ b/tests/Messaging/FQCNMessageFactoryTest.php @@ -14,6 +14,7 @@ namespace ProophTest\Common\Messaging; use DateTimeImmutable; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Prooph\Common\Messaging\FQCNMessageFactory; use ProophTest\Common\Mock\DoSomething; @@ -29,9 +30,7 @@ protected function setUp(): void $this->messageFactory = new FQCNMessageFactory(); } - /** - * @test - */ + #[Test] public function it_creates_a_new_message_from_array_and_fqcn(): void { $uuid = Uuid::uuid4(); @@ -51,9 +50,7 @@ public function it_creates_a_new_message_from_array_and_fqcn(): void $this->assertEquals(['command' => 'metadata'], $command->metadata()); } - /** - * @test - */ + #[Test] public function it_creates_a_new_message_with_defaults_from_array_and_fqcn(): void { $command = $this->messageFactory->createMessageFromArray(DoSomething::class, [ @@ -65,9 +62,7 @@ public function it_creates_a_new_message_with_defaults_from_array_and_fqcn(): vo $this->assertEquals([], $command->metadata()); } - /** - * @test - */ + #[Test] public function it_throws_exception_when_message_class_cannot_be_found(): void { $this->expectException(\UnexpectedValueException::class); @@ -75,9 +70,7 @@ public function it_throws_exception_when_message_class_cannot_be_found(): void $this->messageFactory->createMessageFromArray('NotExistingClass', []); } - /** - * @test - */ + #[Test] public function it_throws_exception_when_message_class_is_not_a_sub_class_domain_message(): void { $this->expectException(\UnexpectedValueException::class); diff --git a/tests/Messaging/MessageDataAssertionTest.php b/tests/Messaging/MessageDataAssertionTest.php index 28f8f70..40c1826 100644 --- a/tests/Messaging/MessageDataAssertionTest.php +++ b/tests/Messaging/MessageDataAssertionTest.php @@ -14,6 +14,8 @@ namespace ProophTest\Common\Messaging; use InvalidArgumentException; +use PHPUnit\Framework\Attributes\DataProvider; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Prooph\Common\Messaging\MessageDataAssertion; use Prooph\Common\Messaging\NoOpMessageConverter; @@ -22,9 +24,7 @@ class MessageDataAssertionTest extends TestCase { - /** - * @test - */ + #[Test] public function it_asserts_message_data_returned_by_the_no_op_message_converter(): void { $testAssertions = new DoSomething(['test' => 'assertions', ['null' => null]]); @@ -37,10 +37,8 @@ public function it_asserts_message_data_returned_by_the_no_op_message_converter( $this->assertTrue(true); } - /** - * @test - * @dataProvider provideMessageDataWithMissingKey - */ + #[Test] + #[DataProvider('provideMessageDataWithMissingKey')] public function it_throws_exception_if_message_data_is_invalid($messageData, $errorMessage) { $this->expectException(InvalidArgumentException::class); diff --git a/tests/Messaging/NoOpMessageConverterTest.php b/tests/Messaging/NoOpMessageConverterTest.php index 936e013..85d8218 100644 --- a/tests/Messaging/NoOpMessageConverterTest.php +++ b/tests/Messaging/NoOpMessageConverterTest.php @@ -14,6 +14,8 @@ namespace ProophTest\Common\Messaging; use Assert\InvalidArgumentException; +use PHPUnit\Framework\Attributes\Test; +use PHPUnit\Framework\MockObject\MockObject; use PHPUnit\Framework\TestCase; use Prooph\Common\Messaging\DomainMessage; use Prooph\Common\Messaging\Message; @@ -21,9 +23,7 @@ class NoOpMessageConverterTest extends TestCase { - /** - * @test - */ + #[Test] public function it_converts_to_array(): void { $messageMock = $this->getMockForAbstractClass(DomainMessage::class, [], '', true, true, true, ['toArray']); @@ -33,9 +33,7 @@ public function it_converts_to_array(): void $converter->convertToArray($messageMock); } - /** - * @test - */ + #[Test] public function it_throws_exception_when_message_is_not_a_domain_message(): void { $this->expectException(InvalidArgumentException::class); diff --git a/tests/Messaging/QueryTest.php b/tests/Messaging/QueryTest.php index 2e70d95..75a5836 100644 --- a/tests/Messaging/QueryTest.php +++ b/tests/Messaging/QueryTest.php @@ -13,6 +13,7 @@ namespace ProophTest\Common\Messaging; +use PHPUnit\Framework\Attributes\Test; use PHPUnit\Framework\TestCase; use Prooph\Common\Messaging\DomainMessage; use ProophTest\Common\Mock\AskSomething; @@ -20,9 +21,7 @@ class QueryTest extends TestCase { - /** - * @test - */ + #[Test] public function it_has_the_message_type_query(): void { $query = AskSomething::fromArray([ From 10c9f6ad5dab1bcbe65db3c0e9206f1ea4d20070 Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Wed, 12 Feb 2025 14:01:20 +0100 Subject: [PATCH 8/9] refactor around deprecated getMockForAbstractClass --- tests/Event/ProophActionEventEmitterTest.php | 4 +++- tests/Messaging/NoOpMessageConverterTest.php | 11 +++++++++-- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/tests/Event/ProophActionEventEmitterTest.php b/tests/Event/ProophActionEventEmitterTest.php index 939196f..6564894 100644 --- a/tests/Event/ProophActionEventEmitterTest.php +++ b/tests/Event/ProophActionEventEmitterTest.php @@ -222,7 +222,9 @@ public function it_uses_default_event_name_if_none_given(): void #[Test] public function it_returns_false_when_unattached_listener_handler_gets_detached(): void { - $listener = $this->getMockForAbstractClass(ListenerHandler::class); + $listener = $this->getMockBuilder(ListenerHandler::class) + ->onlyMethods(['getActionEventListener']) + ->getMock(); $this->assertFalse($this->proophActionEventEmitter->detachListener($listener)); } diff --git a/tests/Messaging/NoOpMessageConverterTest.php b/tests/Messaging/NoOpMessageConverterTest.php index 85d8218..5e62453 100644 --- a/tests/Messaging/NoOpMessageConverterTest.php +++ b/tests/Messaging/NoOpMessageConverterTest.php @@ -26,7 +26,12 @@ class NoOpMessageConverterTest extends TestCase #[Test] public function it_converts_to_array(): void { - $messageMock = $this->getMockForAbstractClass(DomainMessage::class, [], '', true, true, true, ['toArray']); + /** @var DomainMessage|MockObject $messageMock */ + $messageMock = $this->getMockBuilder(DomainMessage::class) + ->disableOriginalConstructor() + ->onlyMethods(['toArray', 'setPayload', 'messageType', 'payload']) + ->getMock(); + $messageMock->expects($this->once())->method('toArray'); $converter = new NoOpMessageConverter(); @@ -39,7 +44,9 @@ public function it_throws_exception_when_message_is_not_a_domain_message(): void $this->expectException(InvalidArgumentException::class); $this->expectExceptionMessage('was expected to be instanceof of "Prooph\Common\Messaging\DomainMessage" but is not'); - $messageMock = $this->getMockForAbstractClass(Message::class); + /** @var Message|MockObject $messageMock */ + $messageMock = $this->getMockBuilder(Message::class) + ->getMock(); $converter = new NoOpMessageConverter(); $converter->convertToArray($messageMock); From 7ffafdf4aff329b92cd290c0b91b4e750b7efdb0 Mon Sep 17 00:00:00 2001 From: Bas Kamer Date: Wed, 12 Feb 2025 14:01:47 +0100 Subject: [PATCH 9/9] cs --- tests/Event/ProophActionEventEmitterTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Event/ProophActionEventEmitterTest.php b/tests/Event/ProophActionEventEmitterTest.php index 6564894..5af5a60 100644 --- a/tests/Event/ProophActionEventEmitterTest.php +++ b/tests/Event/ProophActionEventEmitterTest.php @@ -243,7 +243,7 @@ public function it_dispatches_until_with_no_listeners_attached(): void public function it_attaches_to_known_event_names(): void { $this->expectNotToPerformAssertions(); - + $proophActionEventEmitter = new ProophActionEventEmitter(['foo']); $proophActionEventEmitter->attachListener('foo', function (): void { });