Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
19 / 19 |
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 | pest()->group('integration'); |
| 11 | |
| 12 | use AppDemo\Library\Infrastructure\Mapper\BookMapper; |
| 13 | use AppDemo\Library\Infrastructure\MysqlBookRepository; |
| 14 | use AppDemo\Loan\Infrastructure\Mapper\LoanMapper; |
| 15 | use AppDemo\Loan\Infrastructure\MysqlLoanRepository; |
| 16 | use AppDemo\User\Infrastructure\Mapper\UserMapper; |
| 17 | use AppDemo\User\Infrastructure\MysqlUserRepository; |
| 18 | use Phexium\Plugin\IdGenerator\Adapter\TimestampIdGenerator; |
| 19 | use Phexium\Plugin\SqlDriver\Adapter\MysqlDriver; |
| 20 | use Tests\Phexium\Component\Support\PdoRegistry; |
| 21 | |
| 22 | // @codeCoverageIgnoreStart |
| 23 | require __DIR__.'/BaseLoanRepositoryTests.php'; |
| 24 | |
| 25 | $dbName = null; |
| 26 | beforeAll(function () use (&$dbName): void { |
| 27 | $dbName = PdoRegistry::initializeMysql(true); |
| 28 | }); |
| 29 | afterAll(function () use (&$dbName): void { |
| 30 | PdoRegistry::cleanupMysql($dbName); |
| 31 | }); |
| 32 | // @codeCoverageIgnoreEnd |
| 33 | |
| 34 | beforeEach(function (): void { |
| 35 | PdoRegistry::getConnection()->beginTransaction(); |
| 36 | $pdo = PdoRegistry::getConnection(); |
| 37 | $idGenerator = new TimestampIdGenerator(); |
| 38 | $driver = new MysqlDriver($pdo); |
| 39 | $bookMapper = new BookMapper($idGenerator); |
| 40 | $userMapper = new UserMapper($idGenerator); |
| 41 | $loanMapper = new LoanMapper($idGenerator); |
| 42 | $this->bookRepository = new MysqlBookRepository($driver, $bookMapper); |
| 43 | $this->userRepository = new MysqlUserRepository($driver, $userMapper); |
| 44 | $this->repository = new MysqlLoanRepository($driver, $pdo, $loanMapper); |
| 45 | |
| 46 | givenUserExistsForLoan($this->userRepository, 400, 'user400@test.com'); |
| 47 | givenBookExistsForLoan($this->bookRepository, 567, '9780134494166'); |
| 48 | givenBookExistsForLoan($this->bookRepository, 678, '9781737519799'); |
| 49 | }); |
| 50 | |
| 51 | afterEach(function (): void { |
| 52 | PdoRegistry::getConnection()->rollBack(); |
| 53 | }); |