/** * @test * @covers ::result */ public function it_should_retrieve_a_partition_of_the_results_as_an_instance_of_a_value_object() { $definition = Definition::createNew(self::EXAMPLE_PROJECTION_NAME, ''); $result = ['abc']; $expected = 'expected'; $partition = 'streamName-Id'; $this->givenDriverReturnsDefinition($definition); $this->thenDriverReturnsResult($definition, $result, $partition); $this->thenSerializerTransformsResultIntoAValueObject(self::EXAMPLE_CLASS_NAME, $result, $expected); $this->assertSame($expected, $this->repository->result($partition)); }
<?php use PhpInPractice\Matters\Projection\Driver\EventStore; use PhpInPractice\Matters\Projection\EventStoreRepository; use PhpInPractice\Matters\Projection\StateSerializer\FromArray; include __DIR__ . '/../vendor/autoload.php'; include __DIR__ . '/02-read-projection-state/Organisation.php'; include __DIR__ . '/02-read-projection-state/Organisations.php'; $projections = EventStore::forUrl('192.168.99.100:2113'); $repository = new EventStoreRepository($projections, new FromArray(), Organisations::class, 'Organisation'); var_dump($repository->result());