-
Notifications
You must be signed in to change notification settings - Fork 11.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow dependency injection on seeders
run
method.
- Loading branch information
Showing
4 changed files
with
84 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
use Illuminate\Container\Container; | ||
use Illuminate\Database\ConnectionResolverInterface; | ||
use Illuminate\Database\Console\Seeds\SeedCommand; | ||
use Illuminate\Database\Seeder; | ||
|
||
class SeedCommandTest extends PHPUnit_Framework_TestCase | ||
{ | ||
public function testFire() | ||
{ | ||
$seeder = Mockery::mock(Seeder::class); | ||
$seeder->shouldReceive('setContainer')->once()->andReturnSelf(); | ||
$seeder->shouldReceive('setCommand')->once()->andReturnSelf(); | ||
$seeder->shouldReceive('__invoke')->once(); | ||
|
||
$resolver = Mockery::mock(ConnectionResolverInterface::class); | ||
$resolver->shouldReceive('setDefaultConnection')->once()->with('sqlite'); | ||
|
||
$container = Mockery::mock(Container::class); | ||
$container->shouldReceive('call'); | ||
$container->shouldReceive('environment')->once()->andReturn('testing'); | ||
$container->shouldReceive('make')->with('DatabaseSeeder')->andReturn($seeder); | ||
|
||
$command = new SeedCommand($resolver); | ||
$command->setLaravel($container); | ||
|
||
// call run to set up IO, then fire manually. | ||
$command->run(new Symfony\Component\Console\Input\ArrayInput(['--force' => true, '--database' => 'sqlite']), new Symfony\Component\Console\Output\NullOutput); | ||
$command->fire(); | ||
|
||
$container->shouldHaveReceived('call')->with([$command, 'fire']); | ||
} | ||
|
||
protected function tearDown() | ||
{ | ||
Mockery::close(); | ||
} | ||
} |