diff --git a/src/Illuminate/Database/Console/Migrations/FreshCommand.php b/src/Illuminate/Database/Console/Migrations/FreshCommand.php index 58c28614bcc1..50dfe2bf8a92 100644 --- a/src/Illuminate/Database/Console/Migrations/FreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/FreshCommand.php @@ -4,6 +4,8 @@ use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; +use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Database\Events\DatabaseRefreshed; use Symfony\Component\Console\Input\InputOption; class FreshCommand extends Command @@ -57,6 +59,10 @@ public function handle() $this->runSeeder($database); } + $this->laravel[Dispatcher::class]->dispatch( + new DatabaseRefreshed() + ); + return 0; } diff --git a/src/Illuminate/Database/Console/Migrations/RefreshCommand.php b/src/Illuminate/Database/Console/Migrations/RefreshCommand.php index 1c210eb8a584..328ccee23007 100755 --- a/src/Illuminate/Database/Console/Migrations/RefreshCommand.php +++ b/src/Illuminate/Database/Console/Migrations/RefreshCommand.php @@ -4,6 +4,8 @@ use Illuminate\Console\Command; use Illuminate\Console\ConfirmableTrait; +use Illuminate\Contracts\Events\Dispatcher; +use Illuminate\Database\Events\DatabaseRefreshed; use Symfony\Component\Console\Input\InputOption; class RefreshCommand extends Command @@ -67,6 +69,10 @@ public function handle() $this->runSeeder($database); } + $this->laravel[Dispatcher::class]->dispatch( + new DatabaseRefreshed() + ); + return 0; } diff --git a/src/Illuminate/Database/Events/DatabaseRefreshed.php b/src/Illuminate/Database/Events/DatabaseRefreshed.php new file mode 100644 index 000000000000..5b1fb45856b3 --- /dev/null +++ b/src/Illuminate/Database/Events/DatabaseRefreshed.php @@ -0,0 +1,10 @@ + __DIR__]); + $dispatcher = $app->instance(Dispatcher::class, $events = m::mock()); $console = m::mock(ConsoleApplication::class)->makePartial(); $console->__construct(); $command->setLaravel($app); @@ -35,6 +38,7 @@ public function testRefreshCommandCallsCommandsWithProperArguments() $console->shouldReceive('find')->with('migrate:reset')->andReturn($resetCommand); $console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand); + $dispatcher->shouldReceive('dispatch')->once()->with(m::type(DatabaseRefreshed::class)); $quote = DIRECTORY_SEPARATOR == '\\' ? '"' : "'"; $resetCommand->shouldReceive('run')->with(new InputMatcher("--force=1 {$quote}migrate:reset{$quote}"), m::any()); @@ -48,6 +52,7 @@ public function testRefreshCommandCallsCommandsWithStep() $command = new RefreshCommand(); $app = new ApplicationDatabaseRefreshStub(['path.database' => __DIR__]); + $dispatcher = $app->instance(Dispatcher::class, $events = m::mock()); $console = m::mock(ConsoleApplication::class)->makePartial(); $console->__construct(); $command->setLaravel($app); @@ -58,6 +63,7 @@ public function testRefreshCommandCallsCommandsWithStep() $console->shouldReceive('find')->with('migrate:rollback')->andReturn($rollbackCommand); $console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand); + $dispatcher->shouldReceive('dispatch')->once()->with(m::type(DatabaseRefreshed::class)); $quote = DIRECTORY_SEPARATOR == '\\' ? '"' : "'"; $rollbackCommand->shouldReceive('run')->with(new InputMatcher("--step=2 --force=1 {$quote}migrate:rollback{$quote}"), m::any());