Skip to content

Commit

Permalink
Merge branch '5.6' of github.com:laravel/framework into 5.6
Browse files Browse the repository at this point in the history
  • Loading branch information
taylorotwell committed Jun 30, 2018
2 parents c25d3a5 + f20e43c commit 1ce5f49
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ public function handle()
$this->call('migrate', [
'--database' => $database,
'--path' => $this->input->getOption('path'),
'--realpath' => $this->input->getOption('realpath'),
'--force' => true,
]);

Expand Down
3 changes: 3 additions & 0 deletions src/Illuminate/Database/Console/Migrations/RefreshCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ public function handle()
$this->call('migrate', [
'--database' => $database,
'--path' => $path,
'--realpath' => $this->input->getOption('realpath'),
'--force' => $force,
]);

Expand All @@ -83,6 +84,7 @@ protected function runRollback($database, $path, $step, $force)
$this->call('migrate:rollback', [
'--database' => $database,
'--path' => $path,
'--realpath' => $this->input->getOption('realpath'),
'--step' => $step,
'--force' => $force,
]);
Expand All @@ -101,6 +103,7 @@ protected function runReset($database, $path, $force)
$this->call('migrate:reset', [
'--database' => $database,
'--path' => $path,
'--realpath' => $this->input->getOption('realpath'),
'--force' => $force,
]);
}
Expand Down
8 changes: 4 additions & 4 deletions tests/Database/DatabaseMigrationRefreshCommandTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ public function testRefreshCommandCallsCommandsWithProperArguments()
$console->shouldReceive('find')->with('migrate:reset')->andReturn($resetCommand);
$console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand);

$resetCommand->shouldReceive('run')->with(new InputMatcher("--database --path --force 'migrate:reset'"), m::any());
$migrateCommand->shouldReceive('run')->with(new InputMatcher('--database --path --force migrate'), m::any());
$resetCommand->shouldReceive('run')->with(new InputMatcher("--database --path --realpath --force 'migrate:reset'"), m::any());
$migrateCommand->shouldReceive('run')->with(new InputMatcher('--database --path --realpath --force migrate'), m::any());

$this->runCommand($command);
}
Expand All @@ -57,8 +57,8 @@ public function testRefreshCommandCallsCommandsWithStep()
$console->shouldReceive('find')->with('migrate:rollback')->andReturn($rollbackCommand);
$console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand);

$rollbackCommand->shouldReceive('run')->with(new InputMatcher("--database --path --step=2 --force 'migrate:rollback'"), m::any());
$migrateCommand->shouldReceive('run')->with(new InputMatcher('--database --path --force migrate'), m::any());
$rollbackCommand->shouldReceive('run')->with(new InputMatcher("--database --path --realpath --step=2 --force 'migrate:rollback'"), m::any());
$migrateCommand->shouldReceive('run')->with(new InputMatcher('--database --path --realpath --force migrate'), m::any());

$this->runCommand($command, ['--step' => 2]);
}
Expand Down
43 changes: 43 additions & 0 deletions tests/Integration/Database/RefreshCommandTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<?php

namespace Illuminate\Tests\Integration\Database;

use Illuminate\Support\Facades\DB;

class RefreshCommandTest extends DatabaseTestCase
{
public function test_refresh_without_realpath()
{
$this->app->setBasePath(__DIR__);

$options = [
'--path' => 'stubs/',
];

$this->migrate_refresh_with($options);
}

public function test_refresh_with_realpath()
{
$options = [
'--path' => realpath(__DIR__.'/stubs/'),
'--realpath' => true,
];

$this->migrate_refresh_with($options);
}

private function migrate_refresh_with(array $options)
{
$this->beforeApplicationDestroyed(function () use ($options) {
$this->artisan('migrate:rollback', $options);
});

$this->artisan('migrate:refresh', $options);
DB::table('members')->insert(['name' => 'foo', 'email' => 'foo@bar', 'password' => 'secret']);
$this->assertEquals(1, DB::table('members')->count());

$this->artisan('migrate:refresh', $options);
$this->assertEquals(0, DB::table('members')->count());
}
}

0 comments on commit 1ce5f49

Please sign in to comment.