-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
rename outdated into detached & worker should not discover new subscr…
…iptions in running process
- Loading branch information
1 parent
437be5d
commit 8dca190
Showing
11 changed files
with
512 additions
and
41 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
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
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
66 changes: 66 additions & 0 deletions
66
tests/Integration/Subscription/Subscriber/ProfileNewProjection.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,66 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcing\Tests\Integration\Subscription\Subscriber; | ||
|
||
use Doctrine\DBAL\Connection; | ||
use Doctrine\DBAL\Schema\Table; | ||
use Patchlevel\EventSourcing\Attribute\Setup; | ||
use Patchlevel\EventSourcing\Attribute\Subscribe; | ||
use Patchlevel\EventSourcing\Attribute\Subscriber; | ||
use Patchlevel\EventSourcing\Attribute\Teardown; | ||
use Patchlevel\EventSourcing\EventBus\Message; | ||
use Patchlevel\EventSourcing\Subscription\Subscriber\SubscriberUtil; | ||
use Patchlevel\EventSourcing\Tests\Integration\Subscription\Events\ProfileCreated; | ||
|
||
use function assert; | ||
|
||
#[Subscriber('profile_2')] | ||
Check failure on line 19 in tests/Integration/Subscription/Subscriber/ProfileNewProjection.php GitHub Actions / Static Analysis by Psalm (locked, 8.3, ubuntu-latest)TooFewArguments
|
||
final class ProfileNewProjection | ||
{ | ||
use SubscriberUtil; | ||
|
||
public function __construct( | ||
private Connection $connection, | ||
) { | ||
} | ||
|
||
#[Setup] | ||
public function create(): void | ||
{ | ||
$table = new Table($this->tableName()); | ||
$table->addColumn('id', 'string')->setLength(36); | ||
$table->addColumn('firstname', 'string')->setLength(255); | ||
$table->setPrimaryKey(['id']); | ||
|
||
$this->connection->createSchemaManager()->createTable($table); | ||
} | ||
|
||
#[Teardown] | ||
public function drop(): void | ||
{ | ||
$this->connection->createSchemaManager()->dropTable($this->tableName()); | ||
} | ||
|
||
#[Subscribe(ProfileCreated::class)] | ||
public function handleProfileCreated(Message $message): void | ||
{ | ||
$profileCreated = $message->event(); | ||
|
||
assert($profileCreated instanceof ProfileCreated); | ||
|
||
$this->connection->executeStatement( | ||
'INSERT INTO ' . $this->tableName() . ' (id, firstname) VALUES(:id, :firstname);', | ||
[ | ||
'id' => $profileCreated->profileId->toString(), | ||
'firstname' => $profileCreated->name, | ||
], | ||
); | ||
} | ||
|
||
private function tableName(): string | ||
{ | ||
return 'projection_' . $this->subscriberId(); | ||
} | ||
} |
Oops, something went wrong.