Skip to content

Commit 943d153

Browse files
committed
IHF: New tests for call_in_background helper.
1 parent b776772 commit 943d153

File tree

2 files changed

+44
-90
lines changed

2 files changed

+44
-90
lines changed
Lines changed: 44 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,57 +1,50 @@
11
<?php
22

3-
// use Mockery as m;
4-
//
3+
use Mockery as m;
4+
55
// /**
66
// * @runTestsInSeparateProcesses
77
// * @preserveGlobalState disabled
88
// */
9-
// class CallInBackgroundTest extends TestCase
10-
// {
11-
// protected function setUp()
12-
// {
13-
// $phpMock = m::mock('overload:Symfony\Component\Process\PhpExecutableFinder');
14-
// $phpMock->shouldReceive('find')->with(false)->once()->andReturn('php');
15-
//
16-
// $utilsMock = m::mock('alias:Symfony\Component\Process\ProcessUtils');
17-
// $utilsMock->shouldReceive('escapeArgument')->withAnyArgs()->atLeast()->once()->andReturnUsing(function ($v) {
18-
// return $v;
19-
// });
20-
// }
21-
//
22-
// /** @test */
23-
// public function it_works_without_before_and_after_parameters()
24-
// {
25-
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
26-
// $mock->shouldReceive('exec')->with('(php artisan test command) > /dev/null 2>&1 &')->once();
27-
//
28-
// call_in_background('test command');
29-
// }
30-
//
31-
// /** @test */
32-
// public function it_works_with_only_before_parameter()
33-
// {
34-
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
35-
// $mock->shouldReceive('exec')->with('(before command && php artisan test command) > /dev/null 2>&1 &')->once();
36-
//
37-
// call_in_background('test command', 'before command');
38-
// }
39-
//
40-
// /** @test */
41-
// public function it_works_with_only_after_parameter()
42-
// {
43-
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
44-
// $mock->shouldReceive('exec')->with('(php artisan test command && after command) > /dev/null 2>&1 &')->once();
45-
//
46-
// call_in_background('test command', null, 'after command');
47-
// }
48-
//
49-
// /** @test */
50-
// public function it_works_with_before_and_after_parameters()
51-
// {
52-
// $mock = m::mock('alias:Illuminated\Helpers\System\Command');
53-
// $mock->shouldReceive('exec')->with('(before && php artisan test command && after) > /dev/null 2>&1 &')->once();
54-
//
55-
// call_in_background('test command', 'before', 'after');
56-
// }
57-
// }
9+
class CallInBackgroundTest extends TestCase
10+
{
11+
/** @test */
12+
public function it_works_without_before_and_after_parameters()
13+
{
14+
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
15+
$mock->shouldReceive('factory')->withArgs(['test command', null, null])->once()->andReturnSelf();
16+
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
17+
18+
call_in_background('test command');
19+
}
20+
21+
/** @test */
22+
public function it_works_with_only_before_parameter()
23+
{
24+
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
25+
$mock->shouldReceive('factory')->withArgs(['test command', 'before command', null])->once()->andReturnSelf();
26+
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
27+
28+
call_in_background('test command', 'before command');
29+
}
30+
31+
/** @test */
32+
public function it_works_with_only_after_parameter()
33+
{
34+
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
35+
$mock->shouldReceive('factory')->withArgs(['test command', null, 'after command'])->once()->andReturnSelf();
36+
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
37+
38+
call_in_background('test command', null, 'after command');
39+
}
40+
41+
/** @test */
42+
public function it_works_with_before_and_after_parameters()
43+
{
44+
$mock = m::mock('alias:Illuminated\Helpers\Artisan\Command');
45+
$mock->shouldReceive('factory')->withArgs(['test command', 'before', 'after'])->once()->andReturnSelf();
46+
$mock->shouldReceive('runInBackground')->withNoArgs()->once();
47+
48+
call_in_background('test command', 'before', 'after');
49+
}
50+
}

tests/artisan/CallInBackgroundValidationsTest.php

Lines changed: 0 additions & 39 deletions
This file was deleted.

0 commit comments

Comments
 (0)