Skip to content

Commit

Permalink
move refresh database state to external class for easier trait usage
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed May 18, 2017
1 parent c73447d commit 0322e32
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
11 changes: 2 additions & 9 deletions src/Illuminate/Foundation/Testing/RefreshDatabase.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,6 @@

trait RefreshDatabase
{
/**
* Indicates if the test database has been migrated.
*
* @var bool
*/
protected static $migrated = false;

/**
* Define hooks to migrate the database before and after each test.
*
Expand Down Expand Up @@ -56,12 +49,12 @@ protected function refreshInMemoryDatabase()
*/
protected function refreshTestDatabase()
{
if (! static::$migrated) {
if (! RefreshDatabaseState::$migrated) {
$this->artisan('migrate:fresh');

$this->app[Kernel::class]->setArtisan(null);

static::$migrated = true;
RefreshDatabaseState::$migrated = true;
}

$this->beginDatabaseTransaction();
Expand Down
13 changes: 13 additions & 0 deletions src/Illuminate/Foundation/Testing/RefreshDatabaseState.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php

namespace Illuminate\Foundation\Testing;

class RefreshDatabaseState
{
/**
* Indicates if the test database has been migrated.
*
* @var bool
*/
public static $migrated = false;
}

0 comments on commit 0322e32

Please sign in to comment.