From 3a3cc98f86765fcfb93df7574aff02a2a208d939 Mon Sep 17 00:00:00 2001 From: meadsteve Date: Fri, 13 Dec 2013 14:41:02 +0000 Subject: [PATCH] rename CommandExecutor::executeCommand() so that it's not confused with the Builder::executeCommand() --- PHPCI/Builder.php | 2 +- PHPCI/Helper/CommandExecutor.php | 12 +++++++++++- Tests/PHPCI/Helper/CommandExecutorTest.php | 10 +++++----- 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index c1203b13..7b36d55b 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -217,7 +217,7 @@ class Builder implements LoggerAwareInterface, BuildLogger */ public function executeCommand() { - return $this->commandExecutor->executeCommand(func_get_args()); + return $this->commandExecutor->buildAndExecuteCommand(func_get_args()); } /** diff --git a/PHPCI/Helper/CommandExecutor.php b/PHPCI/Helper/CommandExecutor.php index bce980e7..43813924 100644 --- a/PHPCI/Helper/CommandExecutor.php +++ b/PHPCI/Helper/CommandExecutor.php @@ -47,12 +47,22 @@ class CommandExecutor $this->rootDir = $rootDir; } + /** + * Executes shell commands. Accepts multiple arguments the first + * is the template and everything else is inserted in. c.f. sprintf + * @return bool Indicates success + */ + public function executeCommand() + { + return $this->buildAndExecuteCommand(func_get_args()); + } + /** * Executes shell commands. * @param array $args * @return bool Indicates success */ - public function executeCommand($args = array()) + public function buildAndExecuteCommand($args = array()) { $this->lastOutput = array(); diff --git a/Tests/PHPCI/Helper/CommandExecutorTest.php b/Tests/PHPCI/Helper/CommandExecutorTest.php index c50fc0be..008443e9 100644 --- a/Tests/PHPCI/Helper/CommandExecutorTest.php +++ b/Tests/PHPCI/Helper/CommandExecutorTest.php @@ -21,28 +21,28 @@ class CommandExecutorTest extends ProphecyTestCase public function testGetLastOutput_ReturnsOutputOfCommand() { - $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello World')); + $this->testedExecutor->buildAndExecuteCommand(array('echo "%s"', 'Hello World')); $output = $this->testedExecutor->getLastOutput(); $this->assertEquals("Hello World", $output); } public function testGetLastOutput_ForgetsPreviousCommandOutput() { - $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello World')); - $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello Tester')); + $this->testedExecutor->buildAndExecuteCommand(array('echo "%s"', 'Hello World')); + $this->testedExecutor->buildAndExecuteCommand(array('echo "%s"', 'Hello Tester')); $output = $this->testedExecutor->getLastOutput(); $this->assertEquals("Hello Tester", $output); } public function testExecuteCommand_ReturnsTrueForValidCommands() { - $returnValue = $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello World')); + $returnValue = $this->testedExecutor->buildAndExecuteCommand(array('echo "%s"', 'Hello World')); $this->assertTrue($returnValue); } public function testExecuteCommand_ReturnsFalseForInvalidCommands() { - $returnValue = $this->testedExecutor->executeCommand(array('eerfdcvcho "%s"', 'Hello World')); + $returnValue = $this->testedExecutor->buildAndExecuteCommand(array('eerfdcvcho "%s"', 'Hello World')); $this->assertFalse($returnValue); }