1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
declare(strict_types=1); |
4
|
|
|
|
5
|
|
|
namespace Gember\RdbmsEventStoreDoctrineDbal\Test\Saga; |
6
|
|
|
|
7
|
|
|
use Doctrine\DBAL\DriverManager; |
8
|
|
|
use Doctrine\DBAL\Tools\DsnParser; |
9
|
|
|
use Gember\DependencyContracts\EventStore\Saga\RdbmsSagaNotFoundException; |
10
|
|
|
use Gember\RdbmsEventStoreDoctrineDbal\Saga\DoctrineDbalRdbmsSagaFactory; |
|
|
|
|
11
|
|
|
use Gember\RdbmsEventStoreDoctrineDbal\Saga\DoctrineRdbmsSagaStoreRepository; |
|
|
|
|
12
|
|
|
use Gember\RdbmsEventStoreDoctrineDbal\Saga\TableSchema\SagaTableSchemaFactory; |
|
|
|
|
13
|
|
|
use PHPUnit\Framework\Attributes\Test; |
|
|
|
|
14
|
|
|
use PHPUnit\Framework\TestCase; |
15
|
|
|
use Override; |
|
|
|
|
16
|
|
|
use DateTimeImmutable; |
17
|
|
|
|
18
|
|
|
/** |
19
|
|
|
* @internal |
20
|
|
|
*/ |
21
|
|
|
final class DoctrineRdbmsSagaStoreRepositoryTest extends TestCase |
22
|
|
|
{ |
23
|
|
|
private DoctrineRdbmsSagaStoreRepository $repository; |
24
|
|
|
|
25
|
|
|
#[Override] |
26
|
|
|
protected function setUp(): void |
27
|
|
|
{ |
28
|
|
|
parent::setUp(); |
29
|
|
|
|
30
|
|
|
$connection = DriverManager::getConnection((new DsnParser())->parse('pdo-sqlite:///:memory:')); |
31
|
|
|
$connection->executeStatement((string) file_get_contents(__DIR__ . '/../schema.sql')); |
32
|
|
|
|
33
|
|
|
$this->repository = new DoctrineRdbmsSagaStoreRepository( |
34
|
|
|
$connection, |
35
|
|
|
SagaTableSchemaFactory::createDefaultSagaStore(), |
36
|
|
|
new DoctrineDbalRdbmsSagaFactory(), |
37
|
|
|
); |
38
|
|
|
} |
39
|
|
|
|
40
|
|
|
#[Test] |
41
|
|
|
public function itShouldThrowExceptionWhenSagaNotFound(): void |
42
|
|
|
{ |
43
|
|
|
self::expectException(RdbmsSagaNotFoundException::class); |
|
|
|
|
44
|
|
|
|
45
|
|
|
$this->repository->get('some.saga', '01K76GDQ5RT71G7HQVNR264KD4'); |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
#[Test] |
49
|
|
|
public function itShouldSaveAndGetSaga(): void |
50
|
|
|
{ |
51
|
|
|
$this->repository->save( |
52
|
|
|
'some.saga', |
53
|
|
|
'01K76GDQ5RT71G7HQVNR264KD4', |
54
|
|
|
'{"some":"data"}', |
55
|
|
|
new DateTimeImmutable('2025-10-10 12:00:34'), |
56
|
|
|
); |
57
|
|
|
|
58
|
|
|
$saga = $this->repository->get('some.saga', '01K76GDQ5RT71G7HQVNR264KD4'); |
59
|
|
|
|
60
|
|
|
self::assertSame('some.saga', $saga->sagaName); |
61
|
|
|
self::assertSame('01K76GDQ5RT71G7HQVNR264KD4', $saga->sagaId); |
62
|
|
|
self::assertSame('{"some":"data"}', $saga->payload); |
63
|
|
|
self::assertEquals(new DateTimeImmutable('2025-10-10 12:00:34'), $saga->createdAt); |
64
|
|
|
self::assertNull($saga->updatedAt); |
65
|
|
|
} |
66
|
|
|
|
67
|
|
|
#[Test] |
68
|
|
|
public function itShouldSaveExistingSaga(): void |
69
|
|
|
{ |
70
|
|
|
$this->repository->save( |
71
|
|
|
'some.saga', |
72
|
|
|
'01K76GDQ5RT71G7HQVNR264KD4', |
73
|
|
|
'{"some":"data"}', |
74
|
|
|
new DateTimeImmutable('2025-10-10 12:00:34'), |
75
|
|
|
); |
76
|
|
|
|
77
|
|
|
$this->repository->save( |
78
|
|
|
'some.saga', |
79
|
|
|
'01K76GDQ5RT71G7HQVNR264KD4', |
80
|
|
|
'{"some":"updated"}', |
81
|
|
|
new DateTimeImmutable('2025-10-10 13:30:12'), |
82
|
|
|
); |
83
|
|
|
|
84
|
|
|
$saga = $this->repository->get('some.saga', '01K76GDQ5RT71G7HQVNR264KD4'); |
85
|
|
|
|
86
|
|
|
self::assertSame('some.saga', $saga->sagaName); |
87
|
|
|
self::assertSame('01K76GDQ5RT71G7HQVNR264KD4', $saga->sagaId); |
88
|
|
|
self::assertSame('{"some":"updated"}', $saga->payload); |
89
|
|
|
self::assertEquals(new DateTimeImmutable('2025-10-10 12:00:34'), $saga->createdAt); |
90
|
|
|
self::assertEquals(new DateTimeImmutable('2025-10-10 13:30:12'), $saga->updatedAt); |
91
|
|
|
} |
92
|
|
|
} |
93
|
|
|
|
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"]
, you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths