-
Notifications
You must be signed in to change notification settings - Fork 0
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
Showing
13 changed files
with
173 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,3 +6,4 @@ | |
/.phpunit.cache | ||
/clover.xml | ||
/coveralls-upload.json | ||
/tests/Integration/TestApplication/var/ |
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
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 |
---|---|---|
|
@@ -3,3 +3,5 @@ parameters: | |
paths: | ||
- src | ||
- tests | ||
excludePaths: | ||
- 'tests/Integration/TestApplication/var' |
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,44 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\MbtBundle\Tests\Integration\Service; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Test\KernelTestCase; | ||
use Symfony\Component\Messenger\Envelope; | ||
use Symfony\Component\Messenger\MessageBusInterface; | ||
use Tienvx\Bundle\PactMessengerBundle\Service\EnvelopeCollectorInterface; | ||
use Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message\UserCreated; | ||
use Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message\UserDeleted; | ||
use Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message\UserUpdated; | ||
|
||
class EnvelopeCollectorTest extends KernelTestCase | ||
{ | ||
private int $id = 123; | ||
|
||
public function testEnvelopCollector(): void | ||
{ | ||
self::bootKernel(); | ||
|
||
$container = static::getContainer(); | ||
|
||
$bus = $container->get(MessageBusInterface::class); | ||
$bus->dispatch(new UserCreated($this->id)); | ||
$bus->dispatch(new UserUpdated($this->id)); | ||
$bus->dispatch(new UserDeleted($this->id)); | ||
|
||
$collector = $container->get(EnvelopeCollectorInterface::class); | ||
$this->assertCount(3, $all = $collector->getAll()); | ||
|
||
$this->assertInstanceOf(Envelope::class, $created = $collector->getSingle(UserCreated::class)); | ||
$this->assertTrue(in_array($created, $all)); | ||
$this->assertInstanceOf(UserCreated::class, $message = $created->getMessage()); | ||
$this->assertSame($this->id, $message->userId); | ||
$this->assertInstanceOf(Envelope::class, $updated = $collector->getSingle(UserUpdated::class)); | ||
$this->assertTrue(in_array($updated, $all)); | ||
$this->assertInstanceOf(UserUpdated::class, $message = $updated->getMessage()); | ||
$this->assertSame($this->id, $message->userId); | ||
$this->assertInstanceOf(Envelope::class, $deleted = $collector->getSingle(UserDeleted::class)); | ||
$this->assertTrue(in_array($deleted, $all)); | ||
$this->assertInstanceOf(UserDeleted::class, $message = $deleted->getMessage()); | ||
$this->assertSame($this->id, $message->userId); | ||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
tests/Integration/TestApplication/config/packages/framework.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,29 @@ | ||
<?php | ||
|
||
use Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Kernel; | ||
|
||
$configuration = [ | ||
'http_method_override' => false, | ||
'handle_all_throwables' => true, | ||
'php_errors' => [ | ||
'log' => true, | ||
], | ||
'test' => true, | ||
'messenger' => [ | ||
'transports' => [ | ||
'async' => 'in-memory://', | ||
'audit' => 'in-memory://', | ||
], | ||
'routing' => [ | ||
'Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message\UserCreated' => 'async', | ||
'Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message\UserUpdated' => 'async', | ||
'Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message\UserDeleted' => ['async', 'audit'], | ||
], | ||
], | ||
]; | ||
|
||
if (Kernel::MAJOR_VERSION <= 5) { | ||
unset($configuration['handle_all_throwables']); | ||
} | ||
|
||
$container->loadFromExtension('framework', $configuration); |
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,14 @@ | ||
<?php | ||
|
||
namespace Symfony\Component\DependencyInjection\Loader\Configurator; | ||
|
||
return static function (ContainerConfigurator $container) { | ||
$services = $container->services() | ||
->defaults() | ||
->autowire() | ||
->autoconfigure() | ||
; | ||
|
||
$services->load('Tienvx\\Bundle\\PactMessengerBundle\\Tests\\Integration\\TestApplication\\', '../src/*') | ||
->exclude('../{Entity,Tests,Kernel.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,41 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication; | ||
|
||
use Symfony\Bundle\FrameworkBundle\FrameworkBundle; | ||
use Symfony\Bundle\FrameworkBundle\Kernel\MicroKernelTrait; | ||
use Symfony\Component\Config\Loader\LoaderInterface; | ||
use Symfony\Component\DependencyInjection\ContainerBuilder; | ||
use Symfony\Component\HttpKernel\Kernel as SymfonyKernel; | ||
use Tienvx\Bundle\PactMessengerBundle\TienvxPactMessengerBundle; | ||
|
||
final class Kernel extends SymfonyKernel | ||
{ | ||
use MicroKernelTrait; | ||
|
||
public function __construct() | ||
{ | ||
parent::__construct('test', true); | ||
} | ||
|
||
public function registerBundles(): iterable | ||
{ | ||
return [ | ||
new FrameworkBundle(), | ||
new TienvxPactMessengerBundle(), | ||
]; | ||
} | ||
|
||
public function getProjectDir(): string | ||
{ | ||
return \dirname(__DIR__); | ||
} | ||
|
||
protected function configureContainer(ContainerBuilder $containerBuilder, LoaderInterface $loader): void | ||
{ | ||
$loader->load($this->getProjectDir().'/config/{packages}/*.php', 'glob'); | ||
$loader->load($this->getProjectDir().'/config/{packages}/'.$this->environment.'/*.php', 'glob'); | ||
$loader->load($this->getProjectDir().'/config/{services}.php', 'glob'); | ||
$loader->load($this->getProjectDir().'/config/{services}_'.$this->environment.'.php', 'glob'); | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/Integration/TestApplication/src/Message/UserCreated.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,10 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message; | ||
|
||
class UserCreated | ||
{ | ||
public function __construct(public readonly int $userId) | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/Integration/TestApplication/src/Message/UserDeleted.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,10 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message; | ||
|
||
class UserDeleted | ||
{ | ||
public function __construct(public readonly int $userId) | ||
{ | ||
} | ||
} |
10 changes: 10 additions & 0 deletions
10
tests/Integration/TestApplication/src/Message/UserUpdated.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,10 @@ | ||
<?php | ||
|
||
namespace Tienvx\Bundle\PactMessengerBundle\Tests\Integration\TestApplication\Message; | ||
|
||
class UserUpdated | ||
{ | ||
public function __construct(public readonly int $userId) | ||
{ | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...tion/TienvxPactMessengerExtensionTest.php → ...tion/TienvxPactMessengerExtensionTest.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