-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
cac2265
commit 744e6e3
Showing
4 changed files
with
96 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
<?php | ||
|
||
namespace SimpleBus\SymfonyBridge\Tests\Functional; | ||
|
||
use SimpleBus\Message\Bus\MessageBus; | ||
use SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto\AutoEvent2; | ||
use SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto\AutoEvent3; | ||
use SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto\AutoEventSubscriberUsingPublicMethodAndUnion; | ||
use SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\TestKernel; | ||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
|
||
/** | ||
* @internal | ||
* @coversNothing | ||
* @requires PHP 8.0 | ||
*/ | ||
class Php8SmokeTest extends KernelTestCase | ||
{ | ||
protected function tearDown(): void | ||
{ | ||
parent::tearDown(); | ||
|
||
static::$class = null; | ||
} | ||
|
||
/** | ||
* @test | ||
*/ | ||
public function itCanAutoRegisterEventSubscribersUsingPublicMethodAndUnion(): void | ||
{ | ||
self::bootKernel(['environment' => 'config2_php8']); | ||
$container = self::$kernel->getContainer(); | ||
|
||
$event2 = new AutoEvent2(); | ||
$event3 = new AutoEvent3(); | ||
|
||
$this->assertFalse($event2->isHandledBy(AutoEventSubscriberUsingPublicMethodAndUnion::class)); | ||
$this->assertFalse($event3->isHandledBy(AutoEventSubscriberUsingPublicMethodAndUnion::class)); | ||
|
||
$eventBus = $container->get('event_bus'); | ||
|
||
$this->assertInstanceOf(MessageBus::class, $eventBus); | ||
|
||
$eventBus->handle($event2); | ||
$eventBus->handle($event3); | ||
|
||
$this->assertTrue($event2->isHandledBy(AutoEventSubscriberUsingPublicMethodAndUnion::class)); | ||
$this->assertTrue($event3->isHandledBy(AutoEventSubscriberUsingPublicMethodAndUnion::class)); | ||
} | ||
|
||
protected static function getKernelClass(): string | ||
{ | ||
return TestKernel::class; | ||
} | ||
} |
11 changes: 11 additions & 0 deletions
11
tests/Functional/SmokeTest/Auto/AutoEventSubscriberUsingPublicMethodAndUnion.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<?php | ||
|
||
namespace SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto; | ||
|
||
final class AutoEventSubscriberUsingPublicMethodAndUnion | ||
{ | ||
public function __invoke(AutoEvent2 | AutoEvent3 $event): void | ||
{ | ||
$event->setHandledBy($this); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
imports: | ||
- { resource: config.yml } | ||
|
||
services: | ||
auto_event_subscriber_using_public_method_and_union: | ||
class: SimpleBus\SymfonyBridge\Tests\Functional\SmokeTest\Auto\AutoEventSubscriberUsingPublicMethodAndUnion | ||
tags: | ||
- { name: event_subscriber, register_public_methods: true } | ||
public: false |