Skip to content

Commit 1ce5f49

Browse files
committed
Merge branch '5.6' of github.com:laravel/framework into 5.6
2 parents c25d3a5 + f20e43c commit 1ce5f49

File tree

4 files changed

+51
-4
lines changed

4 files changed

+51
-4
lines changed

src/Illuminate/Database/Console/Migrations/FreshCommand.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ public function handle()
5050
$this->call('migrate', [
5151
'--database' => $database,
5252
'--path' => $this->input->getOption('path'),
53+
'--realpath' => $this->input->getOption('realpath'),
5354
'--force' => true,
5455
]);
5556

src/Illuminate/Database/Console/Migrations/RefreshCommand.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ public function handle()
6161
$this->call('migrate', [
6262
'--database' => $database,
6363
'--path' => $path,
64+
'--realpath' => $this->input->getOption('realpath'),
6465
'--force' => $force,
6566
]);
6667

@@ -83,6 +84,7 @@ protected function runRollback($database, $path, $step, $force)
8384
$this->call('migrate:rollback', [
8485
'--database' => $database,
8586
'--path' => $path,
87+
'--realpath' => $this->input->getOption('realpath'),
8688
'--step' => $step,
8789
'--force' => $force,
8890
]);
@@ -101,6 +103,7 @@ protected function runReset($database, $path, $force)
101103
$this->call('migrate:reset', [
102104
'--database' => $database,
103105
'--path' => $path,
106+
'--realpath' => $this->input->getOption('realpath'),
104107
'--force' => $force,
105108
]);
106109
}

tests/Database/DatabaseMigrationRefreshCommandTest.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@ public function testRefreshCommandCallsCommandsWithProperArguments()
3535
$console->shouldReceive('find')->with('migrate:reset')->andReturn($resetCommand);
3636
$console->shouldReceive('find')->with('migrate')->andReturn($migrateCommand);
3737

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

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

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

6363
$this->runCommand($command, ['--step' => 2]);
6464
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
<?php
2+
3+
namespace Illuminate\Tests\Integration\Database;
4+
5+
use Illuminate\Support\Facades\DB;
6+
7+
class RefreshCommandTest extends DatabaseTestCase
8+
{
9+
public function test_refresh_without_realpath()
10+
{
11+
$this->app->setBasePath(__DIR__);
12+
13+
$options = [
14+
'--path' => 'stubs/',
15+
];
16+
17+
$this->migrate_refresh_with($options);
18+
}
19+
20+
public function test_refresh_with_realpath()
21+
{
22+
$options = [
23+
'--path' => realpath(__DIR__.'/stubs/'),
24+
'--realpath' => true,
25+
];
26+
27+
$this->migrate_refresh_with($options);
28+
}
29+
30+
private function migrate_refresh_with(array $options)
31+
{
32+
$this->beforeApplicationDestroyed(function () use ($options) {
33+
$this->artisan('migrate:rollback', $options);
34+
});
35+
36+
$this->artisan('migrate:refresh', $options);
37+
DB::table('members')->insert(['name' => 'foo', 'email' => 'foo@bar', 'password' => 'secret']);
38+
$this->assertEquals(1, DB::table('members')->count());
39+
40+
$this->artisan('migrate:refresh', $options);
41+
$this->assertEquals(0, DB::table('members')->count());
42+
}
43+
}

0 commit comments

Comments
 (0)