Skip to content

Commit

Permalink
Apply coding standards
Browse files Browse the repository at this point in the history
  • Loading branch information
othillo committed Apr 14, 2023
1 parent 3a586d3 commit e99a898
Show file tree
Hide file tree
Showing 7 changed files with 12 additions and 16 deletions.
2 changes: 2 additions & 0 deletions examples/upcasting/UpcastingExampleTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ public function it_should_do_nothing_if_there_are_no_new_versions(): void

/**
* @test
*
* @testdox It should upcast UserCreatedV1 to UserCreateV3 when only v1 stored
*/
public function it_should_upcast_user_created_v1_to_user_created_v3_when_only_v1_stored(): void
Expand Down Expand Up @@ -96,6 +97,7 @@ public function it_should_upcast_user_created_v1_to_user_created_v3_when_only_v1

/**
* @test
*
* @testdox It should upcast UserCreatedV1 to UserCreateV3 when v1 and v2 are stored
*/
public function it_should_upcast_user_created_v1_to_user_created_v3_when_v1_and_v2_are_stored(): void
Expand Down
2 changes: 1 addition & 1 deletion examples/upcasting/UserCreatedUpcasterV1toV2.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public function upcast(DomainMessage $domainMessage): DomainMessage
{
$payload = $domainMessage->getPayload();

$upcastedEvent= new UserCreatedV2(
$upcastedEvent = new UserCreatedV2(
$payload->userId,
$payload->name,
'N/A',
Expand Down
4 changes: 1 addition & 3 deletions examples/upcasting/UserCreatedUpcasterV2toV3.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public function upcast(DomainMessage $domainMessage): DomainMessage
{
$payload = $domainMessage->getPayload();

$upcastedEvent= new UserCreatedV3(
$upcastedEvent = new UserCreatedV3(
$payload->userId,
$payload->name,
$payload->surname,
Expand All @@ -37,7 +37,5 @@ public function upcast(DomainMessage $domainMessage): DomainMessage
$upcastedEvent,
$domainMessage->getRecordedOn()
);


}
}
1 change: 0 additions & 1 deletion src/Broadway/Upcasting/Upcaster.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

use Broadway\Domain\DomainMessage;


interface Upcaster
{
public function supports(DomainMessage $domainMessage): bool;
Expand Down
1 change: 0 additions & 1 deletion src/Broadway/Upcasting/UpcastingEventStore.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
namespace Broadway\Upcasting;

use Broadway\Domain\DomainEventStream;
use Broadway\Domain\DomainMessage;
use Broadway\EventStore\EventStore;
use Broadway\EventStore\EventVisitor;
use Broadway\EventStore\Management\Criteria;
Expand Down
11 changes: 5 additions & 6 deletions test/Broadway/Upcasting/SequentialUpcasterChainTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ public function it_should_upcast_domain_messages_sequentially(): void
{
$sequentialUpcasterChain = new SequentialUpcasterChain([
new SomeEventV1toV2Upcaster(),
new SomeEventV2toV3Upcaster()
new SomeEventV2toV3Upcaster(),
]);

$domainMessage = new DomainMessage(1,0, new Metadata(), new SomeEvent('matiux'), DateTime::now());
$domainMessage = new DomainMessage(1, 0, new Metadata(), new SomeEvent('matiux'), DateTime::now());

$upcastedDomainMessage = $sequentialUpcasterChain->upcast($domainMessage);

Expand Down Expand Up @@ -78,7 +78,7 @@ public function upcast(DomainMessage $domainMessage): DomainMessage
{
$payload = $domainMessage->getPayload();

$upcastedEvent= new SomeEventV2(
$upcastedEvent = new SomeEventV2(
$payload->name,
'N/A'
);
Expand All @@ -93,7 +93,6 @@ public function upcast(DomainMessage $domainMessage): DomainMessage
}
}


class SomeEventV2toV3Upcaster implements Upcaster
{
public function supports(DomainMessage $domainMessage): bool
Expand All @@ -105,7 +104,7 @@ public function upcast(DomainMessage $domainMessage): DomainMessage
{
$payload = $domainMessage->getPayload();

$upcastedEvent= new SomeEventV3(
$upcastedEvent = new SomeEventV3(
$payload->name,
$payload->surname,
0
Expand All @@ -119,4 +118,4 @@ public function upcast(DomainMessage $domainMessage): DomainMessage
$domainMessage->getRecordedOn()
);
}
}
}
7 changes: 3 additions & 4 deletions test/Broadway/Upcasting/UpcastingEventStoreTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,18 +21,17 @@ public function it_should_call_upcaster_when_event_stream_is_not_empty(): void

$eventStore = new UpcastingEventStore(new InMemoryEventStore(), $upcasterChain);

$events[] = DomainMessage::recordNow(5,0, new Metadata([]),'Foo');
$events[] = DomainMessage::recordNow(5,1, new Metadata([]),'Bar');
$events[] = DomainMessage::recordNow(5, 0, new Metadata([]), 'Foo');
$events[] = DomainMessage::recordNow(5, 1, new Metadata([]), 'Bar');

$upcasterChain->expects($this->exactly(2))
->method('upcast')
->willReturnMap([
[$events[0], $events[0]],
[$events[1], $events[1]]
[$events[1], $events[1]],
]);

$eventStore->append(1, new DomainEventStream($events));
$eventStore->load(1);
}
}

0 comments on commit e99a898

Please sign in to comment.