-
-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
101 additions
and
23 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Mongo; | ||
|
||
use Zenstruck\Foundry\Persistence\ResetDatabase\BeforeEachTestResetter; | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Mongo; | ||
|
||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\ORM\ResetDatabase; | ||
|
||
use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver; | ||
|
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 |
---|---|---|
|
@@ -2,10 +2,19 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\ORM\ResetDatabase; | ||
|
||
use Zenstruck\Foundry\Persistence\ResetDatabase\BeforeFirstTestResetter; | ||
use Zenstruck\Foundry\Persistence\ResetDatabase\BeforeEachTestResetter; | ||
use Zenstruck\Foundry\Persistence\ResetDatabase\BeforeFirstTestResetter; | ||
|
||
/** | ||
* @author Nicolas PHILIPPE <[email protected]> | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\ORM\ResetDatabase; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
|
@@ -13,15 +22,15 @@ | |
*/ | ||
final class SchemaDatabaseResetter extends BaseOrmResetter implements OrmResetter | ||
{ | ||
final public function resetBeforeFirstTest(KernelInterface $kernel): void | ||
public function resetBeforeFirstTest(KernelInterface $kernel): void | ||
{ | ||
$application = self::application($kernel); | ||
|
||
$this->dropAndResetDatabase($application); | ||
$this->createSchema($application); | ||
} | ||
|
||
final public function resetBeforeEachTest(KernelInterface $kernel): void | ||
public function resetBeforeEachTest(KernelInterface $kernel): void | ||
{ | ||
$application = self::application($kernel); | ||
|
||
|
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 |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Persistence\ResetDatabase; | ||
|
||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Persistence\ResetDatabase; | ||
|
||
use Symfony\Component\HttpKernel\KernelInterface; | ||
|
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 |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Persistence\ResetDatabase; | ||
|
||
use DAMA\DoctrineTestBundle\Doctrine\DBAL\StaticDriver; | ||
|
@@ -21,17 +30,17 @@ final class ResetDatabaseManager | |
|
||
/** | ||
* @param iterable<BeforeFirstTestResetter> $beforeFirstTestResetters | ||
* @param iterable<BeforeEachTestResetter> $beforeEachTestResetter | ||
* @param iterable<BeforeEachTestResetter> $beforeEachTestResetter | ||
*/ | ||
public function __construct( | ||
private iterable $beforeFirstTestResetters, | ||
private iterable $beforeEachTestResetter | ||
private iterable $beforeEachTestResetter, | ||
) { | ||
} | ||
|
||
/** | ||
* @param callable():KernelInterface $createKernel | ||
* @param callable():void $shutdownKernel | ||
* @param callable():void $shutdownKernel | ||
*/ | ||
public static function resetBeforeFirstTest(callable $createKernel, callable $shutdownKernel): void | ||
{ | ||
|
@@ -64,7 +73,7 @@ public static function resetBeforeFirstTest(callable $createKernel, callable $sh | |
|
||
/** | ||
* @param callable():KernelInterface $createKernel | ||
* @param callable():void $shutdownKernel | ||
* @param callable():void $shutdownKernel | ||
*/ | ||
public static function resetBeforeEachTest(callable $createKernel, callable $shutdownKernel): void | ||
{ | ||
|
@@ -96,13 +105,13 @@ public static function resetBeforeEachTest(callable $createKernel, callable $shu | |
$shutdownKernel(); | ||
} | ||
|
||
private static function canSkipSchemaReset(): bool | ||
public static function isDAMADoctrineTestBundleEnabled(): bool | ||
{ | ||
return PersistenceManager::isOrmOnly() && self::isDAMADoctrineTestBundleEnabled(); | ||
return \class_exists(StaticDriver::class) && StaticDriver::isKeepStaticConnections(); | ||
} | ||
|
||
public static function isDAMADoctrineTestBundleEnabled(): bool | ||
private static function canSkipSchemaReset(): bool | ||
{ | ||
return \class_exists(StaticDriver::class) && StaticDriver::isKeepStaticConnections(); | ||
return PersistenceManager::isOrmOnly() && self::isDAMADoctrineTestBundleEnabled(); | ||
} | ||
} |
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 |
---|---|---|
|
@@ -2,6 +2,15 @@ | |
|
||
declare(strict_types=1); | ||
|
||
/* | ||
* This file is part of the zenstruck/foundry package. | ||
* | ||
* (c) Kevin Bond <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
namespace Zenstruck\Foundry\Persistence; | ||
|
||
use Symfony\Bundle\FrameworkBundle\Console\Application; | ||
|
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