ExecutableFinderTraitTest.php in Tome 8
File
modules/tome_base/tests/src/Unit/ExecutableFinderTraitTest.php
View source
<?php
namespace Drupal\Tests\tome_base\Unit;
use Drupal\Tests\UnitTestCase;
use Drupal\tome_base\ExecutableFinderTrait;
use Symfony\Component\Console\Input\InputInterface;
class ExecutableFinderTraitTest extends UnitTestCase {
public function testFindExecutable($first_argument, $argv, $expected) {
$mock = $this
->getMockForTrait(ExecutableFinderTrait::class);
$input = $this
->prophesize(InputInterface::class);
$input
->getFirstArgument()
->willReturn($first_argument);
$reflection = new \ReflectionMethod(get_class($mock), 'findExecutable');
$reflection
->setAccessible(TRUE);
$_SERVER['argv'] = $argv;
$this
->assertEquals($expected, $reflection
->invoke($mock, $input
->reveal()));
}
public function dataProvider() {
return [
[
'tome:static',
explode(' ', 'php command.php tome:static foo'),
'php command.php',
],
[
'tome:static',
explode(' ', 'php command.php --backend --option tome:static foo'),
'php command.php --option',
],
];
}
}