-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #63 from patchlevel/fix-data-collector-for-symfony4
fix data collector for symfony 4
- Loading branch information
Showing
6 changed files
with
95 additions
and
44 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
namespace Patchlevel\EventSourcingBundle\Tests\Fixtures; | ||
|
||
use Patchlevel\EventSourcing\Aggregate\AggregateChanged; | ||
|
||
class ProfileCreated extends AggregateChanged | ||
{ | ||
public static function raise(string $id): static | ||
{ | ||
return new static($id); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
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,37 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcingBundle\Tests\Unit\DataCollector; | ||
|
||
use Patchlevel\EventSourcingBundle\DataCollector\EventCollector; | ||
use Patchlevel\EventSourcingBundle\DataCollector\EventListener; | ||
use Patchlevel\EventSourcingBundle\Tests\Fixtures\Profile; | ||
use Patchlevel\EventSourcingBundle\Tests\Fixtures\ProfileCreated; | ||
use PHPUnit\Framework\TestCase; | ||
use Symfony\Component\HttpFoundation\Request; | ||
use Symfony\Component\HttpFoundation\Response; | ||
|
||
class EventCollectorTest extends TestCase | ||
{ | ||
public function testCollectData(): void | ||
{ | ||
$eventListener = new EventListener(); | ||
|
||
$collector = new EventCollector( | ||
$eventListener, | ||
[Profile::class => 'profile'] | ||
); | ||
|
||
$event = ProfileCreated::raise('foo'); | ||
$eventListener($event); | ||
|
||
$collector->collect( | ||
new Request(), | ||
new Response() | ||
); | ||
|
||
self::assertSame([Profile::class => 'profile'], $collector->getAggregates()); | ||
self::assertCount(1, $collector->getEvents()); | ||
} | ||
} |
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,32 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Patchlevel\EventSourcingBundle\Tests\Unit\Loader; | ||
|
||
use InvalidArgumentException; | ||
use Patchlevel\EventSourcingBundle\Loader\AggregateAttributesLoader; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class AggregateAttributeLoaderTest extends TestCase | ||
{ | ||
public function testDuplicateAggregateName() | ||
{ | ||
$this->expectException(InvalidArgumentException::class); | ||
|
||
$loader = new AggregateAttributesLoader(); | ||
$loader->load([ | ||
__DIR__ . '/../../Fixtures/AttributedAggregatesSameName' | ||
]); | ||
} | ||
|
||
public function testLoadPathWithAttributedAggregates() | ||
{ | ||
$loader = new AggregateAttributesLoader(); | ||
$result = $loader->load([ | ||
__DIR__ . '/../../Fixtures/AttributedAggregates' | ||
]); | ||
|
||
self::assertCount(2, $result); | ||
} | ||
} |