Skip to content

Commit 71b31b0

Browse files
committed
IHF: CommandTest added.
1 parent 840f7f4 commit 71b31b0

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

tests/classes/Artisan/CommandTest.php

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,27 @@
22

33
namespace Illuminated\Helpers\Artisan;
44

5+
use Mockery as m;
56
use PHPUnit_Framework_Error;
67
use TestCase;
78

89
class CommandTest extends TestCase
910
{
11+
public static $functions;
12+
13+
protected function setUp()
14+
{
15+
self::$functions = m::mock();
16+
17+
$phpBinaryMock = m::mock('overload:Symfony\Component\Process\PhpExecutableFinder');
18+
$phpBinaryMock->shouldReceive('find')->with(false)->zeroOrMoreTimes()->andReturn('php');
19+
20+
$utilsMock = m::mock('alias:Symfony\Component\Process\ProcessUtils');
21+
$utilsMock->shouldReceive('escapeArgument')->withAnyArgs()->zeroOrMoreTimes()->andReturnUsing(function ($value) {
22+
return $value;
23+
});
24+
}
25+
1026
/** @test */
1127
public function it_has_required_arguments()
1228
{
@@ -27,4 +43,18 @@ public function it_has_static_constructor_named_factory()
2743
$command = Command::factory('test');
2844
$this->assertInstanceOf(Command::class, $command);
2945
}
46+
47+
/** @test */
48+
public function it_can_run_command_in_background()
49+
{
50+
self::$functions->shouldReceive('exec')->with("(php artisan test command) > /dev/null 2>&1 &")->once();
51+
52+
$command = Command::factory('test command');
53+
$command->runInBackground();
54+
}
55+
}
56+
57+
function exec($command)
58+
{
59+
return CommandTest::$functions->exec($command);
3060
}

0 commit comments

Comments
 (0)