-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
IlluminateTransactionalMessageRepositoryTest.php
72 lines (63 loc) · 2.38 KB
/
IlluminateTransactionalMessageRepositoryTest.php
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
<?php
namespace EventSauce\MessageOutbox\IlluminateOutbox;
use EventSauce\EventSourcing\AggregateRootId;
use EventSauce\EventSourcing\MessageRepository;
use EventSauce\EventSourcing\Serialization\ConstructingMessageSerializer;
use EventSauce\MessageOutbox\OutboxRepository;
use EventSauce\MessageOutbox\TestTooling\TransactionalMessageRepositoryTestCase;
use EventSauce\MessageRepository\IlluminateMessageRepository\DummyAggregateRootId;
use EventSauce\MessageRepository\IlluminateMessageRepository\IlluminateUuidV4MessageRepository;
use Illuminate\Database\Capsule\Manager;
use Illuminate\Database\ConnectionInterface;
class IlluminateTransactionalMessageRepositoryTest extends TransactionalMessageRepositoryTestCase
{
private ConnectionInterface $connection;
protected function setUp(): void
{
parent::setUp();
$manager = new Manager;
$manager->addConnection(
[
'driver' => 'mysql',
'host' => getenv('EVENTSAUCE_TESTING_MYSQL_HOST') ?: '127.0.0.1',
'port' => getenv('EVENTSAUCE_TESTING_MYSQL_PORT') ?: '3306',
'database' => 'outbox_messages',
'username' => 'username',
'password' => 'password',
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
]
);
$this->connection = $manager->getConnection();
$this->connection->table($this->repositoryTable)->truncate();
$this->connection->table($this->outboxTable)->truncate();
}
protected function messageRepository(): MessageRepository
{
return new IlluminateUuidV4MessageRepository(
$this->connection,
$this->repositoryTable,
new ConstructingMessageSerializer(),
);
}
protected function outboxRepository(): OutboxRepository
{
return new IlluminateOutboxRepository(
$this->connection,
$this->outboxTable,
new ConstructingMessageSerializer(),
);
}
protected function transactionalRepository(): MessageRepository
{
return new IlluminateTransactionalMessageRepository(
$this->connection,
$this->messageRepository(),
$this->outboxRepository(),
);
}
protected function aggregateRootId(): AggregateRootId
{
return DummyAggregateRootId::generate();
}
}