-
-
Notifications
You must be signed in to change notification settings - Fork 85
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor: make "database reset" mechanism extendable (#690)
- Loading branch information
Showing
26 changed files
with
617 additions
and
466 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
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 was deleted.
Oops, something went wrong.
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,11 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zenstruck\Foundry\Mongo; | ||
|
||
use Zenstruck\Foundry\Persistence\ResetDatabase\BeforeEachTestResetter; | ||
|
||
interface MongoResetter extends 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 |
---|---|---|
@@ -0,0 +1,38 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Zenstruck\Foundry\Mongo; | ||
|
||
use Symfony\Component\HttpKernel\KernelInterface; | ||
use Zenstruck\Foundry\Persistence\SymfonyCommandRunner; | ||
|
||
/** | ||
* @internal | ||
* @author Nicolas PHILIPPE <nikophil@gmail.com> | ||
*/ | ||
final class MongoSchemaResetter implements MongoResetter | ||
{ | ||
use SymfonyCommandRunner; | ||
|
||
/** | ||
* @param list<string> $managers | ||
*/ | ||
public function __construct(private array $managers) | ||
{ | ||
} | ||
|
||
public function resetBeforeEachTest(KernelInterface $kernel): void | ||
{ | ||
$application = self::application($kernel); | ||
|
||
foreach ($this->managers as $manager) { | ||
try { | ||
self::runCommand($application, 'doctrine:mongodb:schema:drop', ['--dm' => $manager]); | ||
} catch (\Exception) { | ||
} | ||
|
||
self::runCommand($application, 'doctrine:mongodb:schema:create', ['--dm' => $manager]); | ||
} | ||
} | ||
} |
Oops, something went wrong.