-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathReadEventTypeTest.php
More file actions
executable file
·63 lines (50 loc) · 1.73 KB
/
Copy pathReadEventTypeTest.php
File metadata and controls
executable file
·63 lines (50 loc) · 1.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<?php
declare(strict_types=1);
use PHPUnit\Framework\TestCase;
use Thenativeweb\Eventsourcingdb\EventCandidate;
use Thenativeweb\Eventsourcingdb\EventType;
use Thenativeweb\Eventsourcingdb\Tests\Trait\ClientTestTrait;
final class ReadEventTypeTest extends TestCase
{
use ClientTestTrait;
public function testFailsIfTheEventTypeDoesNotExist(): void
{
$this->expectExceptionMessage("Failed to read event type, got HTTP status code '404', expected '200'");
$this->client->readEventType('non.existent.eventType');
}
public function testFailsIfTheEventTypeIsMalformed(): void
{
$this->expectExceptionMessage("Failed to read event type, got HTTP status code '400', expected '200'");
$this->client->readEventType('malformed.eventType.');
}
public function testReadAnExistingEventType(): void
{
$firstEvent = new EventCandidate(
source: 'https://www.eventsourcingdb.io',
subject: '/test',
type: 'io.eventsourcingdb.test.foo',
data: [
'value' => 23,
]
);
$secondEvent = new EventCandidate(
source: 'https://www.eventsourcingdb.io',
subject: '/test',
type: 'io.eventsourcingdb.test.bar',
data: [
'value' => 42,
]
);
$this->client->writeEvents([
$firstEvent,
$secondEvent,
]);
$eventType = $this->client->readEventType('io.eventsourcingdb.test.foo');
$expected = new EventType(
eventType: 'io.eventsourcingdb.test.foo',
isPhantom: false,
schema: [],
);
$this->assertEquals($expected, $eventType);
}
}