Mercurial > hg > isophonics-drupal-site
view vendor/consolidation/annotated-command/tests/testAnnotatedCommand.php @ 13:5fb285c0d0e3
Update Drupal core to 8.4.7 via Composer. Security update; I *think* we've
been lucky to get away with this so far, as we don't support self-registration
which seems to be used by the so-called "drupalgeddon 2" attack that 8.4.5
was vulnerable to.
author | Chris Cannam |
---|---|
date | Mon, 23 Apr 2018 09:33:26 +0100 |
parents | 4c8ae668cc8c |
children |
line wrap: on
line source
<?php namespace Consolidation\AnnotatedCommand; use Symfony\Component\Console\Command\Command; use Symfony\Component\Console\Input\InputInterface; use Symfony\Component\Console\Output\OutputInterface; use Symfony\Component\Console\Input\StringInput; use Symfony\Component\Console\Output\BufferedOutput; use Symfony\Component\Console\Application; class AnnotatedCommandTests extends \PHPUnit_Framework_TestCase { function testMyCatCommand() { $command = new \Consolidation\TestUtils\ExampleAnnotatedCommand(); $this->assertInstanceOf('\Symfony\Component\Console\Command\Command', $command); $this->assertEquals('my:cat', $command->getName()); $this->assertEquals('This is the my:cat command implemented as an AnnotatedCommand subclass.', $command->getDescription()); $this->assertEquals("This command will concatenate two parameters. If the --flip flag\nis provided, then the result is the concatenation of two and one.", $command->getHelp()); $this->assertEquals('c', implode(',', $command->getAliases())); // Symfony Console composes the synopsis; perhaps we should not test it. Remove if this gives false failures. $this->assertEquals('my:cat [--multiple MULTIPLE] [--flip] [--] <one> [<two>]', $command->getSynopsis()); $this->assertEquals('my:cat bet alpha --flip', implode(',', $command->getUsages())); $input = new StringInput('my:cat b alpha --multiple=t --multiple=e --flip'); $this->assertRunCommandViaApplicationEquals($command, $input, 'alphabet'); } // TODO: Make a base test class to hold this. function assertRunCommandViaApplicationEquals($command, $input, $expectedOutput, $expectedStatusCode = 0) { $output = new BufferedOutput(); $application = new Application('TestApplication', '0.0.0'); $application->setAutoExit(false); $application->add($command); $statusCode = $application->run($input, $output); $commandOutput = trim($output->fetch()); $this->assertEquals($expectedOutput, $commandOutput); $this->assertEquals($expectedStatusCode, $statusCode); } }