Fixed duplicate methods of CommandExecutor helper: executeCommand and buildAndExecuteCommand
This commit is contained in:
parent
3a0e62657b
commit
a42dc67fad
|
@ -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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue