forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseMigrationResetCommandTest.php
More file actions
executable file
·49 lines (36 loc) · 1.56 KB
/
DatabaseMigrationResetCommandTest.php
File metadata and controls
executable file
·49 lines (36 loc) · 1.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
<?php
use Mockery as m;
use Illuminate\Database\Console\Migrations\ResetCommand;
class DatabaseMigrationResetCommandTest extends PHPUnit_Framework_TestCase {
public function tearDown()
{
m::close();
}
public function testResetCommandCallsMigratorWithProperArguments()
{
$command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator'));
$command->setLaravel(new AppDatabaseMigrationStub());
$migrator->shouldReceive('setConnection')->once()->with(null);
$migrator->shouldReceive('repositoryExists')->once()->andReturn(true);
$migrator->shouldReceive('reset')->once()->with(false);
$migrator->shouldReceive('getNotes')->andReturn([]);
$this->runCommand($command);
}
public function testResetCommandCanBePretended()
{
$command = new ResetCommand($migrator = m::mock('Illuminate\Database\Migrations\Migrator'));
$command->setLaravel(new AppDatabaseMigrationStub());
$migrator->shouldReceive('setConnection')->once()->with('foo');
$migrator->shouldReceive('repositoryExists')->once()->andReturn(true);
$migrator->shouldReceive('reset')->once()->with(true);
$migrator->shouldReceive('getNotes')->andReturn([]);
$this->runCommand($command, array('--pretend' => true, '--database' => 'foo'));
}
protected function runCommand($command, $input = array())
{
return $command->run(new Symfony\Component\Console\Input\ArrayInput($input), new Symfony\Component\Console\Output\NullOutput);
}
}
class AppDatabaseMigrationStub extends \Illuminate\Foundation\Application {
public function environment() { return 'development'; }
}