Skip to content
This repository has been archived by the owner on Aug 23, 2022. It is now read-only.

Commit

Permalink
Add HerdWasRenamed event to the model
Browse files Browse the repository at this point in the history
  • Loading branch information
ramondelafuente committed Sep 29, 2017
1 parent 7256601 commit 74a45da
Show file tree
Hide file tree
Showing 2 changed files with 60 additions and 0 deletions.
28 changes: 28 additions & 0 deletions spec/Elewant/Herding/Model/Events/HerdWasRenamedSpec.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
<?php

namespace spec\Elewant\Herding\Model\Events;

use Elewant\Herding\Model\Events\HerdWasRenamed;
use Elewant\Herding\Model\HerdId;
use PhpSpec\ObjectBehavior;

class HerdWasRenamedSpec extends ObjectBehavior
{
function it_took_place()
{
$herdId = HerdId::fromString('00000000-0000-0000-0000-000000000000');

$this->beConstructedThrough(
'tookPlace',
[
$herdId,
'new herd name',
]
);

$this->shouldHaveType(HerdWasRenamed::class);
$this->aggregateId()->shouldReturn($herdId->toString());
$this->herdId()->shouldEqual($herdId);
$this->newHerdName()->shouldEqual('new herd name');
}
}
32 changes: 32 additions & 0 deletions src/Elewant/Herding/Model/Events/HerdWasRenamed.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

declare(strict_types=1);

namespace Elewant\Herding\Model\Events;

use Elewant\Herding\Model\HerdId;
use Prooph\EventSourcing\AggregateChanged;

class HerdWasRenamed extends AggregateChanged
{
public static function tookPlace(HerdId $herdId, string $newHerdName): self
{
return self::occur(
$herdId->toString(),
[
'newHerdName' => $newHerdName,
]
);
}

public function herdId(): HerdId
{
return HerdId::fromString($this->aggregateId());
}

public function newHerdName(): string
{
return $this->payload['newHerdName'];
}

}

0 comments on commit 74a45da

Please sign in to comment.