-
-
Notifications
You must be signed in to change notification settings - Fork 180
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
[QUESTION] Seed does not rollback in test #460
Comments
Have you confirmed that |
public function beginDatabaseTransaction()
{
$connection = $this->app->make('em')->getConnection();
$connection->beginTransaction();
Log::debug('run beginTransaction()');
$this->beforeApplicationDestroyed(function () use ($connection) {
$connection->rollBack();
Log::debug('run rollBack()');
});
} protected function setUp(): void
{
parent::setUp();
$this->seed();
Log::debug('run seed()');
}
public function testFoo()
{
Log::debug('run testFoo()');
entity(ExampleEntity::class)->create();
}
public function testBar()
{
Log::debug('run testBar()');
entity(ExampleEntity::class)->create();
} This is the log.
|
Did you manage to figure out what the problem was @MP-okui ? |
I solved it by running protected function refreshTestDatabase()
{
if (! RefreshDatabaseState::$migrated) {
$this->artisan('doctrine:schema:drop --force');
$this->artisan('doctrine:schema:create');
// added
$this->seed();
$this->app[Kernel::class]->setArtisan(null);
RefreshDatabaseState::$migrated = true;
}
$this->beginDatabaseTransaction();
} |
Not that I am aware of. I am not able to figure the problem with the information currently available. If you want help fixing this then I would be grateful for a reproducible test (either a new test-repo or a testcase here). |
I expect a seed rollback.
Package version, Laravel version
Steps to reproduce the behaviour
Using the RefreshDatabase.
Execute
seed()
withsetUp()
.Is it because not using EntityManager in
seed()
?The text was updated successfully, but these errors were encountered: