Refactoring
This commit is contained in:
86
lib/composer/vendor/consolidation/robo/tests/unit/Common/CommandArgumentsTest.php
vendored
Normal file
86
lib/composer/vendor/consolidation/robo/tests/unit/Common/CommandArgumentsTest.php
vendored
Normal file
@@ -0,0 +1,86 @@
|
||||
<?php
|
||||
|
||||
use Robo\Traits\Common\CommandArgumentsHost;
|
||||
|
||||
/**
|
||||
* Class CommandArgumentsTest.
|
||||
*
|
||||
* @coversDefaultClass \Robo\Common\CommandArguments
|
||||
*/
|
||||
class CommandArgumentsTest extends \Codeception\Test\Unit
|
||||
{
|
||||
/**
|
||||
* @var \CodeGuy
|
||||
*/
|
||||
protected $guy;
|
||||
|
||||
public function casesArgs() {
|
||||
return [
|
||||
'no arguments' => [
|
||||
' ',
|
||||
[],
|
||||
],
|
||||
'empty string' => [
|
||||
" ''",
|
||||
[''],
|
||||
],
|
||||
'space' => [
|
||||
" ' '",
|
||||
[' '],
|
||||
],
|
||||
'no escape - a' => [
|
||||
" a",
|
||||
['a'],
|
||||
],
|
||||
'no escape - A' => [
|
||||
" A",
|
||||
['A'],
|
||||
],
|
||||
'no escape - 0' => [
|
||||
" 0",
|
||||
['0'],
|
||||
],
|
||||
'no escape - --' => [
|
||||
" --",
|
||||
['--'],
|
||||
],
|
||||
'no escape - @_~.' => [
|
||||
" @_~.",
|
||||
['@_~.'],
|
||||
],
|
||||
'$' => [
|
||||
" 'a\$b'",
|
||||
['a$b'],
|
||||
],
|
||||
'*' => [
|
||||
" 'a*b'",
|
||||
['a*b'],
|
||||
],
|
||||
'multi' => [
|
||||
" '' a '\$PATH'",
|
||||
['', 'a', '$PATH'],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* @dataProvider casesArgs
|
||||
*
|
||||
* @covers ::args
|
||||
*
|
||||
* @param string $expected
|
||||
* @param array $args
|
||||
*/
|
||||
public function testArgs($expected, $args)
|
||||
{
|
||||
$commandArguments = new CommandArgumentsHost();
|
||||
$commandArguments->args($args);
|
||||
$this->guy->assertEquals($expected, $commandArguments->getArguments());
|
||||
|
||||
if ($args) {
|
||||
$commandArguments = new CommandArgumentsHost();
|
||||
call_user_func_array([$commandArguments, 'args'], $args);
|
||||
$this->guy->assertEquals($expected, $commandArguments->getArguments());
|
||||
}
|
||||
}
|
||||
}
|
||||
80
lib/composer/vendor/consolidation/robo/tests/unit/Common/ResourceExistenceChecker.php
vendored
Normal file
80
lib/composer/vendor/consolidation/robo/tests/unit/Common/ResourceExistenceChecker.php
vendored
Normal file
@@ -0,0 +1,80 @@
|
||||
<?php
|
||||
use Robo\Common\ResourceExistenceChecker;
|
||||
use Robo\Result;
|
||||
use Robo\Task\BaseTask;
|
||||
|
||||
class ResourceExistenceCheckerTest extends \Codeception\TestCase\Test
|
||||
{
|
||||
use ResourceExistenceChecker;
|
||||
|
||||
protected $testDir = null;
|
||||
|
||||
protected $testFile = null;
|
||||
|
||||
protected function _before()
|
||||
{
|
||||
$this->apigen = test::double('Robo\Task\ApiGen\ApiGen', [
|
||||
'executeCommand' => null,
|
||||
'output' => new \Symfony\Component\Console\Output\NullOutput()
|
||||
]);
|
||||
if (!defined('DS')) {
|
||||
define('DS', DIRECTORY_SEPARATOR);
|
||||
}
|
||||
$this->testDir = __DIR__ . '..' . DS . '..' . DS . 'data' . DS;
|
||||
$this->testFile = $this->testDir . 'dump.sql';
|
||||
}
|
||||
|
||||
/**
|
||||
* testCheckResources
|
||||
*/
|
||||
public function testCheckResources()
|
||||
{
|
||||
$this->assertTrue($this->checkResources($this->testDir, 'dir'));
|
||||
$this->assertTrue($this->checkResources([
|
||||
$this->testDir,
|
||||
$this->testFile
|
||||
]));
|
||||
}
|
||||
|
||||
/**
|
||||
* @expectException \InvalidArgumentException
|
||||
*/
|
||||
public function testCheckResourcesException()
|
||||
{
|
||||
$this->checkResources('does not exist', 'invalid type');
|
||||
}
|
||||
|
||||
/**
|
||||
* testCheckResource
|
||||
*/
|
||||
public function testCheckResource()
|
||||
{
|
||||
$this->assertTrue($this->checkResource($this->testDir, 'dir'));
|
||||
$this->assertTrue($this->checkResource($this->testDir, 'fileAndDir'));
|
||||
$this->assertTrue($this->checkResource($this->testFile, 'file'));
|
||||
$this->assertTrue($this->checkResource($this->testFile, 'fileAndDir'));
|
||||
|
||||
$this->assertFalse($this->checkResource('does-not-exist', 'dir'));
|
||||
$this->assertFalse($this->checkResource('does-not-exist', 'fileAndDir'));
|
||||
$this->assertFalse($this->checkResource('does-not-exist', 'file'));
|
||||
$this->assertFalse($this->checkResource('does-not-exist', 'fileAndDir'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testIsDir
|
||||
*/
|
||||
public function testIsDir()
|
||||
{
|
||||
$this->assertTrue($this->isDir($this->testDir));
|
||||
$this->assertFalse($this->isDir('does-not-exist'));
|
||||
}
|
||||
|
||||
/**
|
||||
* testIsFile
|
||||
*/
|
||||
public function testIsFile()
|
||||
{
|
||||
$this->assertTrue($this->isFile($this->testFile));
|
||||
$this->assertFalse($this->isFile($this->testDir . 'does-not-exist'));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user