Skip to content

Commit 73b6070

Browse files
committed
IHF: Functions mocking moved to base class.
1 parent e53a43a commit 73b6070

File tree

2 files changed

+17
-10
lines changed

2 files changed

+17
-10
lines changed

tests/TestCase.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33
abstract class TestCase extends \PHPUnit\Framework\TestCase
44
{
5+
public static $functions;
6+
7+
protected function setUp()
8+
{
9+
self::$functions = Mockery::mock();
10+
}
11+
12+
protected function shouldReceiveExecCallOnceWith($with)
13+
{
14+
self::$functions->shouldReceive('exec')->with($with)->once();
15+
}
16+
517
protected function tearDown()
618
{
719
Mockery::close();

tests/classes/Artisan/CommandTest.php

Lines changed: 5 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,9 @@
88

99
class CommandTest extends TestCase
1010
{
11-
public static $functions;
12-
1311
protected function setUp()
1412
{
15-
self::$functions = Mockery::mock();
13+
parent::setUp();
1614

1715
$phpBinaryMock = Mockery::mock('overload:Symfony\Component\Process\PhpExecutableFinder');
1816
$phpBinaryMock->shouldReceive('find')->withNoArgs()->once()->andReturn('php');
@@ -88,14 +86,11 @@ public function it_supports_overriding_of_artisan_binary_through_constant()
8886
$command = Command::factory('test:command', 'before', 'after');
8987
$command->runInBackground();
9088
}
89+
}
9190

92-
private function shouldReceiveExecCallOnceWith($with)
91+
if (!function_exists(__NAMESPACE__ . '\exec')) {
92+
function exec($command)
9393
{
94-
self::$functions->shouldReceive('exec')->with($with)->once();
94+
return TestCase::$functions->exec($command);
9595
}
9696
}
97-
98-
function exec($command)
99-
{
100-
return CommandTest::$functions->exec($command);
101-
}

0 commit comments

Comments
 (0)