Code Coverage
 
Lines
Functions and Methods
Classes and Traits
Total
100.00% covered (success)
100.00%
15 / 15
n/a
0 / 0
CRAP
n/a
0 / 0
1<?php
2
3// ╔════════════════════════════════════════════════════════════╗
4// ║ MIT Licence (#Expat) - https://opensource.org/licenses/MIT ║
5// ║ Copyright 2026 Frederic Poeydomenge <dyno@phexium.com>     ║
6// ╚════════════════════════════════════════════════════════════╝
7
8declare(strict_types=1);
9
10use AppDemo\Library\Infrastructure\PostgresqlBookRepository;
11use AppDemo\Loan\Infrastructure\PostgresqlLoanRepository;
12use AppDemo\User\Infrastructure\PostgresqlUserRepository;
13use Phexium\Plugin\IdGenerator\Adapter\TimestampIdGenerator;
14use Phexium\Plugin\SqlDriver\Adapter\PostgresqlDriver;
15use Tests\Phexium\Integration\Support\PdoRegistry;
16
17// @codeCoverageIgnoreStart
18require_once __DIR__.'/BaseLoanRepositoryTests.php';
19registerBaseLoanRepositoryTests();
20
21$dbName = null;
22beforeAll(function () use (&$dbName): void {
23    $dbName = PdoRegistry::initializePostgresql(true);
24});
25afterAll(function () use (&$dbName): void {
26    PdoRegistry::cleanupPostgresql($dbName);
27});
28// @codeCoverageIgnoreEnd
29
30beforeEach(function (): void {
31    PdoRegistry::getConnection()->beginTransaction();
32    $pdo = PdoRegistry::getConnection();
33    $idGenerator = new TimestampIdGenerator();
34    $driver = new PostgresqlDriver($pdo);
35    $this->bookRepository = new PostgresqlBookRepository($driver, $idGenerator);
36    $this->userRepository = new PostgresqlUserRepository($driver, $idGenerator);
37    $this->repository = new PostgresqlLoanRepository($driver, $pdo, $idGenerator);
38
39    givenUserExistsForLoan($this->userRepository, 400, 'user400@test.com');
40    givenBookExistsForLoan($this->bookRepository, 567, '9780134494166');
41    givenBookExistsForLoan($this->bookRepository, 678, '9781737519799');
42});
43
44afterEach(function (): void {
45    PdoRegistry::getConnection()->rollBack();
46});