Skip to content
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

[5.6] apply realpath option to refresh and fresh commands #24683

Merged
merged 1 commit into from
Jun 30, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
}
}