Skip to content

Commit

Permalink
add SQL savepoint test
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Oct 30, 2023
1 parent f6f11e5 commit 27f83fa
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions tests/Persistence/Sql/WithDb/TransactionTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -223,4 +223,27 @@ public function testAtomicNested(): void
['id' => '1', 'name' => 'John'],
], $this->q('employee')->getRows());
}

public function testAtomicSavepoint(): void
{
$this->setupEmployeeTable();

$this->getConnection()->atomic(function () {
$this->executeOnePassingInsert();
try {
$this->getConnection()->atomic(function () {
$this->executeOneFailingInsert();
});
} catch (Exception $e) {
self::assertInstanceOf(InvalidFieldNameException::class, $e->getPrevious());
}
$this->executeOnePassingInsert();
});

self::assertSameExportUnordered([
['id' => '1', 'name' => 'John'],
// TODO replace ID with fixed value once auto increment ID after rollback is consistent
['id' => $this->q('employee')->field($this->q()->expr('max({})', ['id']))->getOne(), 'name' => 'John'],
], $this->q('employee')->getRows());
}
}

0 comments on commit 27f83fa

Please sign in to comment.