Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
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 | |
| 8 | declare(strict_types=1); |
| 9 | |
| 10 | use AppDemo\Library\Infrastructure\MysqlBookRepository; |
| 11 | use AppDemo\Loan\Infrastructure\MysqlLoanRepository; |
| 12 | use AppDemo\User\Infrastructure\MysqlUserRepository; |
| 13 | use Phexium\Plugin\IdGenerator\Adapter\TimestampIdGenerator; |
| 14 | use Phexium\Plugin\SqlDriver\Adapter\MysqlDriver; |
| 15 | use Tests\Phexium\Integration\Support\PdoRegistry; |
| 16 | |
| 17 | // @codeCoverageIgnoreStart |
| 18 | require_once __DIR__.'/BaseLoanRepositoryTests.php'; |
| 19 | registerBaseLoanRepositoryTests(); |
| 20 | |
| 21 | $dbName = null; |
| 22 | beforeAll(function () use (&$dbName): void { |
| 23 | $dbName = PdoRegistry::initializeMysql(true); |
| 24 | }); |
| 25 | afterAll(function () use (&$dbName): void { |
| 26 | PdoRegistry::cleanupMysql($dbName); |
| 27 | }); |
| 28 | // @codeCoverageIgnoreEnd |
| 29 | |
| 30 | beforeEach(function (): void { |
| 31 | PdoRegistry::getConnection()->beginTransaction(); |
| 32 | $pdo = PdoRegistry::getConnection(); |
| 33 | $idGenerator = new TimestampIdGenerator(); |
| 34 | $driver = new MysqlDriver($pdo); |
| 35 | $this->bookRepository = new MysqlBookRepository($driver, $idGenerator); |
| 36 | $this->userRepository = new MysqlUserRepository($driver, $idGenerator); |
| 37 | $this->repository = new MysqlLoanRepository($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 | |
| 44 | afterEach(function (): void { |
| 45 | PdoRegistry::getConnection()->rollBack(); |
| 46 | }); |