From a42dc67fad5f6cd0969f86f8a29e5e1a77b75141 Mon Sep 17 00:00:00 2001 From: Corpsee Date: Fri, 9 May 2014 14:25:24 +0700 Subject: [PATCH] Fixed duplicate methods of CommandExecutor helper: executeCommand and buildAndExecuteCommand --- PHPCI/Builder.php | 2 +- PHPCI/Helper/CommandExecutor.php | 12 +----------- Tests/PHPCI/Helper/CommandExecutorTest.php | 10 +++++----- 3 files changed, 7 insertions(+), 17 deletions(-) diff --git a/PHPCI/Builder.php b/PHPCI/Builder.php index ccb78c6b..69db31e1 100644 --- a/PHPCI/Builder.php +++ b/PHPCI/Builder.php @@ -242,7 +242,7 @@ class Builder implements LoggerAwareInterface */ public function executeCommand() { - return $this->commandExecutor->buildAndExecuteCommand(func_get_args()); + return $this->commandExecutor->executeCommand(func_get_args()); } /** diff --git a/PHPCI/Helper/CommandExecutor.php b/PHPCI/Helper/CommandExecutor.php index dc284b6a..438829af 100644 --- a/PHPCI/Helper/CommandExecutor.php +++ b/PHPCI/Helper/CommandExecutor.php @@ -51,22 +51,12 @@ 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 buildAndExecuteCommand($args = array()) + public function executeCommand($args = array()) { $this->lastOutput = array(); diff --git a/Tests/PHPCI/Helper/CommandExecutorTest.php b/Tests/PHPCI/Helper/CommandExecutorTest.php index 4925e639..ae6809d5 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->buildAndExecuteCommand(array('echo "%s"', 'Hello World')); + $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello World')); $output = $this->testedExecutor->getLastOutput(); $this->assertEquals("Hello World", $output); } public function testGetLastOutput_ForgetsPreviousCommandOutput() { - $this->testedExecutor->buildAndExecuteCommand(array('echo "%s"', 'Hello World')); - $this->testedExecutor->buildAndExecuteCommand(array('echo "%s"', 'Hello Tester')); + $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello World')); + $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello Tester')); $output = $this->testedExecutor->getLastOutput(); $this->assertEquals("Hello Tester", $output); } public function testExecuteCommand_ReturnsTrueForValidCommands() { - $returnValue = $this->testedExecutor->buildAndExecuteCommand(array('echo "%s"', 'Hello World')); + $returnValue = $this->testedExecutor->executeCommand(array('echo "%s"', 'Hello World')); $this->assertTrue($returnValue); } public function testExecuteCommand_ReturnsFalseForInvalidCommands() { - $returnValue = $this->testedExecutor->buildAndExecuteCommand(array('eerfdcvcho "%s" > /dev/null 2>&1', 'Hello World')); + $returnValue = $this->testedExecutor->executeCommand(array('eerfdcvcho "%s" > /dev/null 2>&1', 'Hello World')); $this->assertFalse($returnValue); }