Repository navigation
Expand file tree
/
Copy pathStreamSourceTest.php
More file actions
82 lines (65 loc) · 2.26 KB
/
Copy pathStreamSourceTest.php
File metadata and controls
82 lines (65 loc) · 2.26 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
<?php
declare(strict_types=1);
namespace IDCT\NATS\Tests\Unit;
use IDCT\NATS\JetStream\Configuration\StreamSource;
use PHPUnit\Framework\TestCase;
final class StreamSourceTest extends TestCase
{
public function testMirrorMinimal(): void
{
$mirror = StreamSource::mirror('ORIGIN')->toArray();
self::assertSame(['name' => 'ORIGIN'], $mirror);
}
public function testMirrorWithStartSeq(): void
{
$mirror = StreamSource::mirror('ORIGIN')
->startSeq(42)
->toArray();
self::assertSame('ORIGIN', $mirror['name']);
self::assertSame(42, $mirror['opt_start_seq']);
}
public function testMirrorWithStartTime(): void
{
$mirror = StreamSource::mirror('ORIGIN')
->startTime('2026-01-01T00:00:00Z')
->toArray();
self::assertSame('2026-01-01T00:00:00Z', $mirror['opt_start_time']);
}
public function testSourceWithFilterSubject(): void
{
$source = StreamSource::source('ORDERS')
->filterSubject('orders.>')
->toArray();
self::assertSame('ORDERS', $source['name']);
self::assertSame('orders.>', $source['filter_subject']);
}
public function testSourceWithExternal(): void
{
$source = StreamSource::source('REMOTE')
->external('$JS.other.API', '_DELIVER.other')
->toArray();
self::assertSame('REMOTE', $source['name']);
self::assertSame(['api' => '$JS.other.API', 'deliver' => '_DELIVER.other'], $source['external']);
}
public function testExternalWithoutDeliver(): void
{
$source = StreamSource::source('REMOTE')
->external('$JS.other.API')
->toArray();
self::assertSame(['api' => '$JS.other.API'], $source['external']);
}
public function testFullyConfiguredSource(): void
{
$source = StreamSource::source('EVENTS')
->startSeq(100)
->filterSubject('events.>')
->external('$JS.X.API', '_D.X')
->toArray();
self::assertSame([
'name' => 'EVENTS',
'opt_start_seq' => 100,
'filter_subject' => 'events.>',
'external' => ['api' => '$JS.X.API', 'deliver' => '_D.X'],
], $source);
}
}