Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
100.00% |
26 / 26 |
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('unit'); |
| 11 | |
| 12 | use Phexium\Plugin\Transaction\Adapter\InMemoryTransaction; |
| 13 | use Tests\Phexium\Fake\Plugin\Transaction\Transaction as FakeTransaction; |
| 14 | |
| 15 | describe('Commit', function (): void { |
| 16 | it('tracks begin calls', function (): void { |
| 17 | $transaction = new FakeTransaction(new InMemoryTransaction()); |
| 18 | expect($transaction->inTransaction())->toBeFalse(); |
| 19 | |
| 20 | $transaction->begin(); |
| 21 | |
| 22 | expect($transaction->inTransaction())->toBeTrue(); |
| 23 | expect($transaction->getCallHistory())->toBe(['begin']); |
| 24 | }); |
| 25 | |
| 26 | it('tracks commit calls', function (): void { |
| 27 | $transaction = new FakeTransaction(new InMemoryTransaction()); |
| 28 | |
| 29 | $transaction->begin(); |
| 30 | $transaction->commit(); |
| 31 | |
| 32 | expect($transaction->inTransaction())->toBeFalse(); |
| 33 | expect($transaction->getCallHistory())->toBe(['begin', 'commit']); |
| 34 | }); |
| 35 | }); |
| 36 | |
| 37 | describe('Rollback', function (): void { |
| 38 | it('tracks rollback calls', function (): void { |
| 39 | $transaction = new FakeTransaction(new InMemoryTransaction()); |
| 40 | |
| 41 | $transaction->begin(); |
| 42 | $transaction->rollback(); |
| 43 | |
| 44 | expect($transaction->inTransaction())->toBeFalse(); |
| 45 | expect($transaction->getCallHistory())->toBe(['begin', 'rollback']); |
| 46 | }); |
| 47 | }); |