From 637be4af6306965301b4eda1258db545ba4cfc35 Mon Sep 17 00:00:00 2001 From: meadsteve Date: Sun, 3 Nov 2013 11:48:01 +0000 Subject: [PATCH] added mocking for missing FindBinary command in phpunit tests --- Tests/PHPCI/Plugin/PHPUnitTest.php | 27 +++++++++++++++++++++++---- 1 file changed, 23 insertions(+), 4 deletions(-) diff --git a/Tests/PHPCI/Plugin/PHPUnitTest.php b/Tests/PHPCI/Plugin/PHPUnitTest.php index 10c48d4e..5809ac67 100644 --- a/Tests/PHPCI/Plugin/PHPUnitTest.php +++ b/Tests/PHPCI/Plugin/PHPUnitTest.php @@ -59,6 +59,24 @@ class PHPUnitTest extends \PHPUnit_Framework_TestCase $this->testedPhpUnit = new PHPUnit($this->mockCiBuilder,$this->mockBuild, $arrOptions); } + /** + * @param \PHPUnit_Framework_MockObject_Matcher_Invocation $expectation + */ + protected function expectFindBinaryToBeCalled($expectation) { + $this->mockCiBuilder->expects($expectation) + ->method("findBinary") + ->will($this->returnValue("phpunit")); + } + + /** + * @param \PHPUnit_Framework_MockObject_Matcher_Invocation $expectation + */ + public function expectExectuteCommandToBeCalled($expectation) + { + $this->mockCiBuilder->expects($expectation) + ->method("executeCommand"); + } + /** * @covers PHPUnit::execute */ @@ -82,7 +100,8 @@ class PHPUnitTest extends \PHPUnit_Framework_TestCase 'directory' => "Fake/Test/Path" )); - $this->mockCiBuilder->expects($this->once())->method("executeCommand"); + $this->expectFindBinaryToBeCalled($this->once()); + $this->expectExectuteCommandToBeCalled($this->once()); $returnValue = $this->testedPhpUnit->execute(); } @@ -99,9 +118,10 @@ class PHPUnitTest extends \PHPUnit_Framework_TestCase 'config' => "Fake/Test/config.xml" )); - $this->mockCiBuilder->expects($this->once())->method("executeCommand"); + $this->expectFindBinaryToBeCalled($this->once()); + $this->expectExectuteCommandToBeCalled($this->once()); - $returnValue = $this->testedPhpUnit->execute(); + $returnValue = $this->testedPhpUnit->execute(); } /** @@ -139,5 +159,4 @@ class PHPUnitTest extends \PHPUnit_Framework_TestCase $returnValue = $this->testedPhpUnit->execute(); } - } \ No newline at end of file