forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDatabaseSeederTest.php
More file actions
executable file
·51 lines (44 loc) · 1.55 KB
/
DatabaseSeederTest.php
File metadata and controls
executable file
·51 lines (44 loc) · 1.55 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
50
51
<?php
use Mockery as m;
use Illuminate\Database\Seeder;
class TestSeeder extends Seeder
{
public function run()
{
//
}
}
class DatabaseSeederTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
m::close();
}
public function testCallResolveTheClassAndCallsRun()
{
$seeder = new TestSeeder;
$seeder->setContainer($container = m::mock('Illuminate\Container\Container'));
$output = m::mock('Symfony\Component\Console\Output\OutputInterface');
$output->shouldReceive('writeln')->once()->andReturn('foo');
$command = m::mock('Illuminate\Console\Command');
$command->shouldReceive('getOutput')->once()->andReturn($output);
$seeder->setCommand($command);
$container->shouldReceive('make')->once()->with('ClassName')->andReturn($child = m::mock('StdClass'));
$child->shouldReceive('setContainer')->once()->with($container)->andReturn($child);
$child->shouldReceive('setCommand')->once()->with($command)->andReturn($child);
$child->shouldReceive('run')->once();
$seeder->call('ClassName');
}
public function testSetContainer()
{
$seeder = new TestSeeder;
$container = m::mock('Illuminate\Container\Container');
$this->assertEquals($seeder->setContainer($container), $seeder);
}
public function testSetCommand()
{
$seeder = new TestSeeder;
$command = m::mock('Illuminate\Console\Command');
$this->assertEquals($seeder->setCommand($command), $seeder);
}
}