23 lines
515 B
PHP
23 lines
515 B
PHP
|
|
<?php
|
||
|
|
|
||
|
|
declare(strict_types=1);
|
||
|
|
|
||
|
|
use Illuminate\Support\Facades\DB;
|
||
|
|
use Infrastructure\Adapters\Services\LaravelTransactionManager;
|
||
|
|
|
||
|
|
it('executes callback in transaction', function () {
|
||
|
|
// GIVEN
|
||
|
|
DB::shouldReceive('transaction')->once()->andReturnUsing(function ($callback) {
|
||
|
|
return $callback();
|
||
|
|
});
|
||
|
|
$manager = new LaravelTransactionManager();
|
||
|
|
|
||
|
|
// WHEN
|
||
|
|
$result = $manager->execute(function () {
|
||
|
|
return 'success';
|
||
|
|
});
|
||
|
|
|
||
|
|
// THEN
|
||
|
|
expect($result)->toBe('success');
|
||
|
|
});
|