Add pear modules, mail and net_smtp via composer (#93)
Add pear modules, mail and net_smtp via composer, remove php 5.6 build due to phpunit 6
This commit is contained in:
@@ -10,6 +10,7 @@ use Consolidation\TestUtils\ExampleCommandInfoAlterer;
|
||||
use Symfony\Component\Console\Application;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Input\ArgvInput;
|
||||
use Symfony\Component\Console\Input\StringInput;
|
||||
use Symfony\Component\Console\Output\BufferedOutput;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@@ -19,6 +20,207 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
protected $commandFileInstance;
|
||||
protected $commandFactory;
|
||||
|
||||
function testFibonacci()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'fibonacci');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertEquals('fibonacci', $command->getName());
|
||||
$this->assertEquals('fibonacci [--graphic] [--] <start> <steps>', $command->getSynopsis());
|
||||
$this->assertEquals('Calculate the fibonacci sequence between two numbers.', $command->getDescription());
|
||||
$this->assertEquals("Graphic output will look like
|
||||
+----+---+-------------+
|
||||
| | | |
|
||||
| |-+-| |
|
||||
|----+-+-+ |
|
||||
| | |
|
||||
| | |
|
||||
| | |
|
||||
+--------+-------------+", $command->getHelp());
|
||||
|
||||
$this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command);
|
||||
|
||||
$input = new StringInput('help fibonacci');
|
||||
$this->assertRunCommandViaApplicationContains($command, $input, ['Display the sequence graphically using cube representation']);
|
||||
}
|
||||
|
||||
function testSniff()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'sniff');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertEquals('sniff', $command->getName());
|
||||
$this->assertEquals('sniff [--autofix] [--strict] [--] [<file>]', $command->getSynopsis());
|
||||
|
||||
$this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command);
|
||||
|
||||
$input = new StringInput('help sniff');
|
||||
$this->assertRunCommandViaApplicationContains($command, $input, ['A file or directory to analyze.']);
|
||||
|
||||
$input = new StringInput('sniff --autofix --strict -- foo');
|
||||
$this->assertRunCommandViaApplicationContains($command, $input, ["'autofix' => true",
|
||||
"'strict' => true"]);
|
||||
}
|
||||
|
||||
function testOptionDefaultValue()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'defaultOptionOne');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertEquals('default:option-one', $command->getName());
|
||||
$this->assertEquals('default:option-one [--foo [FOO]]', $command->getSynopsis());
|
||||
|
||||
$this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command);
|
||||
|
||||
$input = new StringInput('default:option-one');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'Foo is 1');
|
||||
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'defaultOptionTwo');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertEquals('default:option-two', $command->getName());
|
||||
$this->assertEquals('default:option-two [--foo [FOO]]', $command->getSynopsis());
|
||||
|
||||
$input = new StringInput('default:option-two');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'Foo is 2');
|
||||
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'defaultOptionNone');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertEquals('default:option-none', $command->getName());
|
||||
$this->assertEquals('default:option-none [--foo FOO]', $command->getSynopsis());
|
||||
|
||||
// Skip failing test until Symfony is fixed.
|
||||
$this->markTestSkipped('Symfony Console 3.2.5 and 3.2.6 do not handle default options with required values correctly.');
|
||||
|
||||
$input = new StringInput('default:option-none --foo');
|
||||
$this->assertRunCommandViaApplicationContains($command, $input, ['The "--foo" option requires a value.'], 1);
|
||||
}
|
||||
|
||||
function testGlobalOptionsOnly()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'globalOptionsOnly');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
$input = new StringInput('global-options-only test');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, "Arg is test, options[help] is false");
|
||||
}
|
||||
|
||||
function testOptionWithOptionalValue()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'defaultOptionalValue');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
// Test to see if we can differentiate between a missing option, and
|
||||
// an option that has no value at all.
|
||||
$input = new StringInput('default:optional-value --foo=bar');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, "Foo is 'bar'");
|
||||
|
||||
$input = new StringInput('default:optional-value --foo');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'Foo is true');
|
||||
|
||||
$input = new StringInput('default:optional-value');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'Foo is NULL');
|
||||
}
|
||||
|
||||
function testOptionThatDefaultsToTrue()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'defaultOptionDefaultsToTrue');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
// Test to see if we can differentiate between a missing option, and
|
||||
// an option that has no value at all.
|
||||
$input = new StringInput('default:option-defaults-to-true --foo=bar');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, "Foo is 'bar'");
|
||||
|
||||
$input = new StringInput('default:option-defaults-to-true --foo');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'Foo is true');
|
||||
|
||||
$input = new StringInput('default:option-defaults-to-true');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'Foo is true');
|
||||
|
||||
$input = new StringInput('help default:option-defaults-to-true');
|
||||
$this->assertRunCommandViaApplicationContains(
|
||||
$command,
|
||||
$input,
|
||||
[
|
||||
'--no-foo',
|
||||
'Negate --foo option',
|
||||
]
|
||||
);
|
||||
$input = new StringInput('default:option-defaults-to-true --no-foo');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'Foo is false');
|
||||
}
|
||||
/**
|
||||
* Test CommandInfo command caching.
|
||||
*
|
||||
* Sequence:
|
||||
* - Create all of the command info objects from one class, caching them.
|
||||
* - Change the method name of one of the items in the cache to a non-existent method
|
||||
* - Restore all of the cached commandinfo objects
|
||||
* - Ensure that the non-existent method cached commandinfo was not created
|
||||
* - Ensure that the now-missing cached commandinfo was still created
|
||||
*
|
||||
* This tests both save/restore, plus adding a new command method to
|
||||
* a class, and removing a command method from a class.
|
||||
*/
|
||||
function testAnnotatedCommandCache()
|
||||
{
|
||||
$testCacheStore = new \Consolidation\TestUtils\InMemoryCacheStore();
|
||||
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$this->commandFactory->setDataStore($testCacheStore);
|
||||
|
||||
// Make commandInfo objects for every command in the test commandfile.
|
||||
// These will also be stored in our cache.
|
||||
$commandInfoList = $this->commandFactory->getCommandInfoListFromClass($this->commandFileInstance);
|
||||
|
||||
$cachedClassName = get_class($this->commandFileInstance);
|
||||
|
||||
$this->assertTrue($testCacheStore->has($cachedClassName));
|
||||
|
||||
$cachedData = $testCacheStore->get($cachedClassName);
|
||||
$this->assertFalse(empty($cachedData));
|
||||
$this->assertTrue(array_key_exists('testArithmatic', $cachedData));
|
||||
|
||||
$alterCommandInfoCache = $cachedData['testArithmatic'];
|
||||
unset($cachedData['testArithmatic']);
|
||||
$alterCommandInfoCache['method_name'] = 'nonExistentMethod';
|
||||
$cachedData[$alterCommandInfoCache['method_name']] = $alterCommandInfoCache;
|
||||
|
||||
$testCacheStore->set($cachedClassName, $cachedData);
|
||||
|
||||
$restoredCommandInfoList = $this->commandFactory->getCommandInfoListFromClass($this->commandFileInstance);
|
||||
|
||||
$rebuiltCachedData = $testCacheStore->get($cachedClassName);
|
||||
|
||||
$this->assertFalse(empty($rebuiltCachedData));
|
||||
$this->assertTrue(array_key_exists('testArithmatic', $rebuiltCachedData));
|
||||
$this->assertFalse(array_key_exists('nonExistentMethod', $rebuiltCachedData));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test CommandInfo command annotation parsing.
|
||||
*/
|
||||
@@ -35,7 +237,7 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
$this->assertEquals('This is the test:arithmatic command', $command->getDescription());
|
||||
$this->assertEquals("This command will add one and two. If the --negate flag\nis provided, then the result is negated.", $command->getHelp());
|
||||
$this->assertEquals('arithmatic', implode(',', $command->getAliases()));
|
||||
$this->assertEquals('test:arithmatic [--negate] [--] <one> <two>', $command->getSynopsis());
|
||||
$this->assertEquals('test:arithmatic [--negate] [--unused [UNUSED]] [--] <one> [<two>]', $command->getSynopsis());
|
||||
$this->assertEquals('test:arithmatic 2 2 --negate', implode(',', $command->getUsages()));
|
||||
|
||||
$input = new StringInput('arithmatic 2 3 --negate');
|
||||
@@ -86,6 +288,29 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'alphabet');
|
||||
}
|
||||
|
||||
function testJoinCommandHelp()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'myJoin');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
$this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command);
|
||||
$this->assertEquals('my:join', $command->getName());
|
||||
$this->assertEquals('This is the my:join command', $command->getDescription());
|
||||
$this->assertEquals("This command will join its parameters together. It can also reverse and repeat its arguments.", $command->getHelp());
|
||||
$this->assertEquals('my:join [--flip] [--repeat [REPEAT]] [--] [<args>]...', $command->getSynopsis());
|
||||
|
||||
// TODO: Extra whitespace character if there are no options et. al. in the
|
||||
// usage. This is uncommon, and the defect is invisible. Maybe find it someday.
|
||||
$actualUsages = implode(',', $command->getUsages());
|
||||
$this->assertEquals('my:join a b,my:join ', $actualUsages);
|
||||
|
||||
$input = new StringInput('my:join bet alpha --flip --repeat=2');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'alphabetalphabet');
|
||||
}
|
||||
|
||||
function testDefaultsCommand()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
@@ -126,6 +351,34 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$input = new StringInput('command:with-no-options something');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'somethingdefault');
|
||||
|
||||
$input = new StringInput('help command:with-no-options something');
|
||||
$this->assertRunCommandViaApplicationContains(
|
||||
$command,
|
||||
$input,
|
||||
[
|
||||
'The first parameter.',
|
||||
'The other parameter.',
|
||||
]
|
||||
);
|
||||
}
|
||||
|
||||
function testCommandWithIOParameters()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'commandWithIOParameters');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
$this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command);
|
||||
$this->assertEquals('command:with-io-parameters', $command->getName());
|
||||
$this->assertEquals("This command work with app's input and output", $command->getDescription());
|
||||
$this->assertEquals('', $command->getHelp());
|
||||
$this->assertEquals('command:with-io-parameters', $command->getSynopsis());
|
||||
|
||||
$input = new StringInput('command:with-io-parameters');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'command:with-io-parameters');
|
||||
}
|
||||
|
||||
function testCommandWithNoArguments()
|
||||
@@ -237,6 +490,41 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'betxyzbetxyz');
|
||||
}
|
||||
|
||||
function testRequiredArrayOption()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'testRequiredArrayOption');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertEquals('test:required-array-option [-a|--arr ARR]', $command->getSynopsis());
|
||||
|
||||
$input = new StringInput('test:required-array-option --arr=1 --arr=2 --arr=3');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, '1 2 3');
|
||||
|
||||
$input = new StringInput('test:required-array-option -a 1 -a 2 -a 3');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, '1 2 3');
|
||||
}
|
||||
|
||||
function testArrayOption()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile;
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'testArrayOption');
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertEquals('test:array-option [-a|--arr [ARR]]', $command->getSynopsis());
|
||||
|
||||
$input = new StringInput('test:array-option');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, '1 2 3');
|
||||
|
||||
$input = new StringInput('test:array-option --arr=a --arr=b --arr=c');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'a b c');
|
||||
|
||||
$input = new StringInput('test:array-option -a a');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'a');
|
||||
}
|
||||
|
||||
function testHookedCommand()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile();
|
||||
@@ -264,6 +552,33 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$input = new StringInput('test:hook bar');
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, '<[bar]>');
|
||||
|
||||
$input = new StringInput('list --raw');
|
||||
$this->assertRunCommandViaApplicationContains($command, $input, ['This command wraps its parameter in []; its alter hook then wraps the result in .']);
|
||||
}
|
||||
|
||||
function testReplaceCommandHook(){
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile();
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
|
||||
$hookInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'hookTestReplaceCommandHook');
|
||||
|
||||
$this->assertTrue($hookInfo->hasAnnotation('hook'));
|
||||
$this->assertEquals('replace-command test:replace-command', $hookInfo->getAnnotation('hook'));
|
||||
|
||||
$this->commandFactory->registerCommandHook($hookInfo, $this->commandFileInstance);
|
||||
|
||||
$hookCallback = $this->commandFactory->hookManager()->get('test:replace-command', [HookManager::REPLACE_COMMAND_HOOK]);
|
||||
$this->assertTrue($hookCallback != null);
|
||||
$this->assertEquals(1, count($hookCallback));
|
||||
$this->assertEquals(2, count($hookCallback[0]));
|
||||
$this->assertTrue(is_callable($hookCallback[0]));
|
||||
$this->assertEquals('hookTestReplaceCommandHook', $hookCallback[0][1]);
|
||||
|
||||
$input = new StringInput('test:replace-command foo');
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'testReplaceCommand');
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, "bar", 0);
|
||||
}
|
||||
|
||||
function testPostCommandCalledAfterCommand()
|
||||
@@ -338,6 +653,22 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, '*** bar ***');
|
||||
}
|
||||
|
||||
function testDoubleDashWithVersion()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleHookAllCommandFile();
|
||||
$this->commandFactory = new AnnotatedCommandFactory();
|
||||
$commandInfo = $this->commandFactory->createCommandInfo($this->commandFileInstance, 'doCat');
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
$input = new ArgvInput(['placeholder', 'do:cat', 'one', '--', '--version']);
|
||||
list($statusCode, $commandOutput) = $this->runCommandViaApplication($command, $input);
|
||||
|
||||
if ($commandOutput == 'TestApplication version 0.0.0') {
|
||||
$this->markTestSkipped('Symfony/Console 2.x does not respect -- with --version');
|
||||
}
|
||||
$this->assertEquals('one--version', $commandOutput);
|
||||
}
|
||||
|
||||
function testAnnotatedHookedCommand()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile();
|
||||
@@ -404,7 +735,7 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
$annotationData = $commandInfo->getRawAnnotations();
|
||||
$this->assertEquals('addmycommandname', implode(',', $annotationData->keys()));
|
||||
$annotationData = $commandInfo->getAnnotations();
|
||||
$this->assertEquals('addmycommandname,command', implode(',', $annotationData->keys()));
|
||||
$this->assertEquals('addmycommandname,command,_path,_classname', implode(',', $annotationData->keys()));
|
||||
|
||||
$command = $this->commandFactory->createCommand($commandInfo, $this->commandFileInstance);
|
||||
|
||||
@@ -415,7 +746,6 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
$this->assertRunCommandViaApplicationEquals($command, $input, 'fantabulous from alter:me-too');
|
||||
}
|
||||
|
||||
|
||||
function testHookedCommandWithHookAddedLater()
|
||||
{
|
||||
$this->commandFileInstance = new \Consolidation\TestUtils\ExampleCommandFile();
|
||||
@@ -612,7 +942,25 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
return $r->invokeArgs($object, $args);
|
||||
}
|
||||
|
||||
function assertRunCommandViaApplicationContains($command, $input, $containsList, $expectedStatusCode = 0)
|
||||
{
|
||||
list($statusCode, $commandOutput) = $this->runCommandViaApplication($command, $input);
|
||||
|
||||
foreach ($containsList as $contains) {
|
||||
$this->assertContains($contains, $commandOutput);
|
||||
}
|
||||
$this->assertEquals($expectedStatusCode, $statusCode);
|
||||
}
|
||||
|
||||
function assertRunCommandViaApplicationEquals($command, $input, $expectedOutput, $expectedStatusCode = 0)
|
||||
{
|
||||
list($statusCode, $commandOutput) = $this->runCommandViaApplication($command, $input);
|
||||
|
||||
$this->assertEquals($expectedOutput, $commandOutput);
|
||||
$this->assertEquals($expectedStatusCode, $statusCode);
|
||||
}
|
||||
|
||||
function runCommandViaApplication($command, $input)
|
||||
{
|
||||
$output = new BufferedOutput();
|
||||
if ($this->commandFileInstance && method_exists($this->commandFileInstance, 'setOutput')) {
|
||||
@@ -624,16 +972,15 @@ class AnnotatedCommandFactoryTests extends \PHPUnit_Framework_TestCase
|
||||
|
||||
$eventDispatcher = new \Symfony\Component\EventDispatcher\EventDispatcher();
|
||||
$eventDispatcher->addSubscriber($this->commandFactory->commandProcessor()->hookManager());
|
||||
$eventDispatcher->addSubscriber($alterOptionsEventManager);
|
||||
$this->commandFactory->commandProcessor()->hookManager()->addCommandEvent($alterOptionsEventManager);
|
||||
$application->setDispatcher($eventDispatcher);
|
||||
|
||||
$application->setAutoExit(false);
|
||||
$application->add($command);
|
||||
|
||||
$statusCode = $application->run($input, $output);
|
||||
$commandOutput = trim($output->fetch());
|
||||
$commandOutput = trim(str_replace("\r", '', $output->fetch()));
|
||||
|
||||
$this->assertEquals($expectedOutput, $commandOutput);
|
||||
$this->assertEquals($expectedStatusCode, $statusCode);
|
||||
return [$statusCode, $commandOutput];
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user