-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resets transaction once processed by the
onFlush
event subscriber. F…
- Loading branch information
1 parent
6843e88
commit 6b4be4a
Showing
3 changed files
with
58 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
<?php | ||
|
||
namespace DH\Auditor\Tests\Provider\Doctrine\Issues; | ||
|
||
use DH\Auditor\Model\Transaction; | ||
use DH\Auditor\Tests\Provider\Doctrine\Fixtures\Entity\Standard\DummyEntity; | ||
use DH\Auditor\Tests\Provider\Doctrine\Traits\ReaderTrait; | ||
use DH\Auditor\Tests\Provider\Doctrine\Traits\Schema\SchemaSetupTrait; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @internal | ||
*/ | ||
final class Issue44Test extends TestCase | ||
{ | ||
use ReaderTrait; | ||
use SchemaSetupTrait; | ||
|
||
public function testIssue44(): void | ||
{ | ||
$reader = $this->createReader(); | ||
|
||
$em = $this->provider->getStorageServiceForEntity(DummyEntity::class)->getEntityManager(); | ||
$em->beginTransaction(); | ||
$entity = new DummyEntity(); | ||
$entity->setLabel('entity1'); | ||
$em->persist($entity); | ||
$em->flush(); | ||
$em->flush(); | ||
$em->commit(); | ||
for ($n = 1; $n <= 10; ++$n) { | ||
$em->beginTransaction(); | ||
$em->commit(); | ||
} | ||
|
||
$audits = $reader->createQuery(DummyEntity::class)->execute(); | ||
self::assertCount(1, $audits, 'results count ok.'); | ||
self::assertSame(Transaction::INSERT, $audits[0]->getType(), 'Reader::INSERT operation.'); | ||
} | ||
|
||
private function configureEntities(): void | ||
{ | ||
$this->provider->getConfiguration()->setEntities([ | ||
DummyEntity::class => ['enabled' => true], | ||
]); | ||
} | ||
} |