Fixed namespaces (PHPCI -> PHPCensor)
This commit is contained in:
parent
60d74b0b44
commit
60a2b7282a
238 changed files with 1014 additions and 863 deletions
87
tests/PHPCensor/Helper/CommandExecutorTest.php
Normal file
87
tests/PHPCensor/Helper/CommandExecutorTest.php
Normal file
|
|
@ -0,0 +1,87 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* PHPCI - Continuous Integration for PHP
|
||||
*
|
||||
* @copyright Copyright 2015, Block 8 Limited.
|
||||
* @license https://github.com/Block8/PHPCI/blob/master/LICENSE.md
|
||||
* @link https://www.phptesting.org/
|
||||
*/
|
||||
|
||||
namespace Tests\PHPCensor\Helper;
|
||||
|
||||
use PHPCensor\Helper\UnixCommandExecutor;
|
||||
|
||||
class CommandExecutorTest extends \PHPUnit_Framework_TestCase
|
||||
{
|
||||
/**
|
||||
* @var UnixCommandExecutor
|
||||
*/
|
||||
protected $testedExecutor;
|
||||
|
||||
protected function setUp()
|
||||
{
|
||||
if (IS_WIN) {
|
||||
$this->markTestSkipped("Cannot test UnixCommandExecutor on ".PHP_OS);
|
||||
return;
|
||||
}
|
||||
parent::setUp();
|
||||
|
||||
$mockBuildLogger = $this->prophesize('PHPCensor\Logging\BuildLogger');
|
||||
|
||||
$class = IS_WIN
|
||||
? 'PHPCensor\Helper\WindowsCommandExecutor'
|
||||
: 'PHPCensor\Helper\UnixCommandExecutor';
|
||||
$this->testedExecutor = new $class($mockBuildLogger->reveal(), __DIR__);
|
||||
}
|
||||
|
||||
public function testGetLastOutput_ReturnsOutputOfCommand()
|
||||
{
|
||||
$this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']);
|
||||
$output = $this->testedExecutor->getLastOutput();
|
||||
$this->assertEquals("Hello World", $output);
|
||||
}
|
||||
|
||||
public function testGetLastOutput_ForgetsPreviousCommandOutput()
|
||||
{
|
||||
$this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']);
|
||||
$this->testedExecutor->executeCommand(['echo "%s"', 'Hello Tester']);
|
||||
$output = $this->testedExecutor->getLastOutput();
|
||||
$this->assertEquals("Hello Tester", $output);
|
||||
}
|
||||
|
||||
public function testExecuteCommand_ReturnsTrueForValidCommands()
|
||||
{
|
||||
$returnValue = $this->testedExecutor->executeCommand(['echo "%s"', 'Hello World']);
|
||||
$this->assertTrue($returnValue);
|
||||
}
|
||||
|
||||
public function testExecuteCommand_ReturnsFalseForInvalidCommands()
|
||||
{
|
||||
$returnValue = $this->testedExecutor->executeCommand(['eerfdcvcho "%s" > /dev/null 2>&1', 'Hello World']);
|
||||
$this->assertFalse($returnValue);
|
||||
}
|
||||
|
||||
public function testFindBinary_ReturnsPathInSpecifiedRoot()
|
||||
{
|
||||
$thisFileName = "CommandExecutorTest.php";
|
||||
$returnValue = $this->testedExecutor->findBinary($thisFileName, true);
|
||||
$this->assertEquals(__DIR__ . DIRECTORY_SEPARATOR . $thisFileName, $returnValue);
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectedException \Exception
|
||||
* @expectedMessageRegex WorldWidePeace
|
||||
*/
|
||||
public function testFindBinary_ThrowsWhenNotFound()
|
||||
{
|
||||
$thisFileName = "WorldWidePeace";
|
||||
$this->testedExecutor->findBinary($thisFileName);
|
||||
}
|
||||
|
||||
public function testFindBinary_ReturnsNullWihQuietArgument()
|
||||
{
|
||||
$thisFileName = "WorldWidePeace";
|
||||
$this->assertNull($this->testedExecutor->findBinary($thisFileName, true));
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue