/** * @test * @covers ::forUrl */ public function it_should_create_instance_given_an_eventstore_url() { $this->thenConnectionIsChecked(); $projections = EventStore::forUrl('127.0.0.1', $this->httpClient); $this->assertInstanceOf(EventStore::class, $projections); $this->assertAttributeSame('127.0.0.1', 'url', $projections); }
/** * @test * @covers ::result */ public function it_should_error_when_an_invalid_response_is_returned_by_the_eventstore() { $this->setExpectedException(InvalidResponseException::class); $this->thenConnectionIsChecked(); $invalidResponse = ''; $projections = EventStore::forUrl('127.0.0.1', $this->httpClient); $this->httpClient->shouldReceive('send')->once()->with(m::on(function (Request $request) { return $request->getMethod() == 'GET' && (string) $request->getUri() === 'result-url'; }))->andReturn(new Response(200, [], $invalidResponse)); $projections->result(Definition::fromEventStore(['name' => '', 'mode' => '', 'status' => '', 'progress' => '', 'stateUrl' => '', 'resultUrl' => 'result-url', 'queryUrl' => '', 'enableCommandUrl' => '', 'disableCommandUrl' => ''])); }
<?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());