Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow manual operations on static connections #203

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/DAMA/DoctrineTestBundle/Doctrine/DBAL/AbstractStaticDriver.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,11 @@ abstract class AbstractStaticDriver implements Driver, VersionAwarePlatformDrive
*/
protected static $connections = [];

/**
* @var bool
*/
protected static $manualOperations = false;

/**
* @var bool
*/
Expand Down Expand Up @@ -58,6 +63,16 @@ public static function isKeepStaticConnections(): bool
return self::$keepStaticConnections;
}

public static function setManualOperations(bool $manualOperations): void
{
self::$manualOperations = $manualOperations;
}

public static function isManualOperations(): bool
{
return self::$manualOperations;
}

public static function beginTransaction(): void
{
foreach (self::$connections as $con) {
Expand Down
8 changes: 6 additions & 2 deletions src/DAMA/DoctrineTestBundle/PHPUnit/PHPUnitExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,12 +17,16 @@ public function executeBeforeFirstTest(): void

public function executeBeforeTest(string $test): void
{
StaticDriver::beginTransaction();
if (!StaticDriver::isManualOperations()) {
StaticDriver::beginTransaction();
}
}

public function executeAfterTest(string $test, float $time): void
{
StaticDriver::rollBack();
if (!StaticDriver::isManualOperations()) {
StaticDriver::rollBack();
}
}

public function executeAfterLastTest(): void
Expand Down