-
-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow to return new instances of same aggregate (#417)
* Allow to return new instances of same aggregate * treat factory method separately * test fixes
- Loading branch information
Showing
12 changed files
with
285 additions
and
9 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
15 changes: 15 additions & 0 deletions
15
packages/PdoEventSourcing/tests/Fixture/Calendar/CalendarClosed.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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\EventSourcing\Fixture\Calendar; | ||
|
||
/** | ||
* licence Apache-2.0 | ||
*/ | ||
final class CalendarClosed | ||
{ | ||
public function __construct(public string $calendarId) | ||
{ | ||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
packages/PdoEventSourcing/tests/Fixture/Calendar/CloseCalendar.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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\EventSourcing\Fixture\Calendar; | ||
|
||
/** | ||
* licence Apache-2.0 | ||
*/ | ||
final class CloseCalendar | ||
{ | ||
public function __construct(public string $calendarId) | ||
{ | ||
} | ||
} |
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
15 changes: 15 additions & 0 deletions
15
packages/PdoEventSourcing/tests/Fixture/Calendar/OpenFreshCalendar.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,15 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\EventSourcing\Fixture\Calendar; | ||
|
||
/** | ||
* licence Apache-2.0 | ||
*/ | ||
final class OpenFreshCalendar | ||
{ | ||
public function __construct(public string $calendarId, public string $freshCalendarId) | ||
{ | ||
} | ||
} |
46 changes: 46 additions & 0 deletions
46
packages/PdoEventSourcing/tests/Fixture/CalendarProjection/CalendarProjection.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,46 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Test\Ecotone\EventSourcing\Fixture\CalendarProjection; | ||
|
||
use Ecotone\EventSourcing\Attribute\Projection; | ||
use Ecotone\Messaging\Support\Assert; | ||
use Ecotone\Modelling\Attribute\EventHandler; | ||
use Ecotone\Modelling\Attribute\QueryHandler; | ||
use Test\Ecotone\EventSourcing\Fixture\Calendar\CalendarCreated; | ||
use Test\Ecotone\EventSourcing\Fixture\Calendar\MeetingCreated; | ||
use Test\Ecotone\EventSourcing\Fixture\Calendar\MeetingScheduled; | ||
use Test\Ecotone\EventSourcing\Fixture\Calendar\MeetingWithEventSourcing; | ||
use Test\Ecotone\EventSourcing\Fixture\EventSourcingCalendarWithInternalRecorder\CalendarWithInternalRecorder; | ||
|
||
#[Projection('calendar', [CalendarWithInternalRecorder::class, MeetingWithEventSourcing::class])] | ||
final class CalendarProjection | ||
{ | ||
private $calendars = []; | ||
|
||
#[EventHandler] | ||
public function whenCalendarCreated(CalendarCreated $event): void | ||
{ | ||
$this->calendars[$event->calendarId] = []; | ||
} | ||
|
||
#[EventHandler] | ||
public function whenMeetingScheduled(MeetingScheduled $event): void | ||
{ | ||
$this->calendars[$event->calendarId][$event->meetingId] = 'scheduled'; | ||
} | ||
|
||
#[EventHandler] | ||
public function whenMeetingCreated(MeetingCreated $event): void | ||
{ | ||
$this->calendars[$event->calendarId][$event->meetingId] = 'created'; | ||
} | ||
|
||
#[QueryHandler('getCalendar')] | ||
public function getCalendar(string $calendarId): array | ||
{ | ||
Assert::keyExists($this->calendars, $calendarId, "Calendar with id {$calendarId} not found"); | ||
return $this->calendars[$calendarId]; | ||
} | ||
} |
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
Oops, something went wrong.