forked from laravel/framework
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleApplicationTest.php
More file actions
executable file
·56 lines (45 loc) · 2.06 KB
/
ConsoleApplicationTest.php
File metadata and controls
executable file
·56 lines (45 loc) · 2.06 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
52
53
54
55
56
<?php
use Mockery as m;
class ConsoleApplicationTest extends PHPUnit_Framework_TestCase
{
public function tearDown()
{
m::close();
}
public function testAddSetsLaravelInstance()
{
$app = $this->getMockConsole(['addToParent']);
$command = m::mock('Illuminate\Console\Command');
$command->shouldReceive('setLaravel')->once()->with(m::type('Illuminate\Contracts\Foundation\Application'));
$app->expects($this->once())->method('addToParent')->with($this->equalTo($command))->will($this->returnValue($command));
$result = $app->add($command);
$this->assertEquals($command, $result);
}
public function testLaravelNotSetOnSymfonyCommands()
{
$app = $this->getMockConsole(['addToParent']);
$command = m::mock('Symfony\Component\Console\Command\Command');
$command->shouldReceive('setLaravel')->never();
$app->expects($this->once())->method('addToParent')->with($this->equalTo($command))->will($this->returnValue($command));
$result = $app->add($command);
$this->assertEquals($command, $result);
}
public function testResolveAddsCommandViaApplicationResolution()
{
$app = $this->getMockConsole(['addToParent']);
$command = m::mock('Symfony\Component\Console\Command\Command');
$app->getLaravel()->shouldReceive('make')->once()->with('foo')->andReturn(m::mock('Symfony\Component\Console\Command\Command'));
$app->expects($this->once())->method('addToParent')->with($this->equalTo($command))->will($this->returnValue($command));
$result = $app->resolve('foo');
$this->assertEquals($command, $result);
}
protected function getMockConsole(array $methods)
{
$app = m::mock('Illuminate\Contracts\Foundation\Application', ['version' => '5.1']);
$events = m::mock('Illuminate\Contracts\Events\Dispatcher', ['fire' => null]);
$console = $this->getMock('Illuminate\Console\Application', $methods, [
$app, $events, 'test-version',
]);
return $console;
}
}