public function testShouldReturnErrorIfThereIsFilesWithWrongStyle() { $kernel = $this->getMock(\stdClass::class); /* @var \Behat\Gherkin\Parser|\PHPUnit_Framework_MockObject_MockObject $parser */ $parser = $this->getMockBuilder(Parser::class)->disableOriginalConstructor()->getMock(); /* @var \Behat\Gherkin\Node\FeatureNode|\PHPUnit_Framework_MockObject_MockObject $feature */ $feature = $this->getMockBuilder(FeatureNode::class)->disableOriginalConstructor()->getMock(); $feature->expects(self::once())->method('hasTags')->willReturn(true); $feature->expects(self::once())->method('getKeyword')->willReturn('Feature'); $feature->expects(self::once())->method('getTags')->willReturn(['users', 'another-feature', 'another-tag']); $feature->expects(self::once())->method('getTitle')->willReturn('User registration'); $feature->expects(self::once())->method('hasDescription')->willReturn(true); $feature->expects(self::once())->method('getDescription')->willReturn("In order to order products\n" . "As a visitor\n" . "I need to be able to create an account in the store"); $feature->expects(self::once())->method('hasBackground')->willReturn(true); $feature->expects(self::once())->method('getBackground')->willReturn($this->getBackground()); $feature->expects(self::once())->method('hasScenarios')->willReturn(false); $parser->expects(self::once())->method('parse')->willReturn($feature); $application = new Application($kernel); $application->add(new CheckGherkinCodeStyle(null, $parser)); $command = $application->find('gherkin:check'); $commandTester = new CommandTester($command); $commandTester->execute(['directory' => __DIR__ . '/../assets/left-aligned.feature']); self::assertRegExp('/Wrong style/', $commandTester->getDisplay()); self::assertNotRegExp('/I need to be able to create an account in the store/', $commandTester->getDisplay()); }
/** * @test */ public function shouldExecuteConsumeCommand() { $application = new Application('prod'); // Add command $command = new TestableConsumerCommand('fake:consumer', $this->getMockForAbstractClass('Boot\\RabbitMQ\\Consumer\\AbstractConsumer', [$this->queueTemplate], 'MockConsumer'), $this->createLogger()); $application->add($command); // Create command tester $commandTester = new CommandTester($command); // Execute consumer $commandTester->execute(['command' => $command->getName()]); // Should have declared the queue once $this->assertEquals(1, $this->basicQueueDeclareInvocations->getInvocationCount()); $args = $this->basicQueueDeclareInvocations->getInvocations()[0]->parameters; // Make sure that the queue name is correct $this->assertEquals('some_test_queue', $args[0]); // Make sure that the queue is durable $this->assertTrue($args[2], 'The queue is not durable!'); // Make sure that the queue is not automatically deleted $this->assertFalse($args[4], 'The queue is automatically deleted!'); // Should have declared the quality of service once $this->assertEquals(1, $this->basicQosInvocations->getInvocationCount()); // Should have declared the quality of service once $this->assertEquals(1, $this->basicConsumeInvocations->getInvocationCount()); // The wait method should have been invoked once $this->assertEquals(1, $this->waitInvocations->getInvocationCount()); // Should have status code 0 $this->assertEquals(0, $commandTester->getStatusCode()); }
public function testExecute() { $expected = 'Connection opened to foo:22/path/'; $commandTester = new CommandTester($this->instance->find('haytool:file-upload')); $commandTester->execute(array()); $this->assertStringStartsWith($expected, $commandTester->getDisplay()); }
/** * @dataProvider inputInteractiveCommandToOutputFilesProvider */ public function testInteractiveOutputs($inputCommandFilepath, $outputFilepath) { $code = (require $inputCommandFilepath); $this->command->setCode($code); $this->tester->execute(array(), array('interactive' => true, 'decorated' => false)); $this->assertStringEqualsFile($outputFilepath, $this->tester->getDisplay(true)); }
/** * @dataProvider getFormat * @runInSeparateProcess */ public function testExecution($format) { $tmpDir = sys_get_temp_dir() . '/sf_hello'; $filesystem = new Filesystem(); $filesystem->remove($tmpDir); $filesystem->mkdirs($tmpDir); chdir($tmpDir); $tester = new CommandTester(new InitCommand()); $tester->execute(array('--name' => 'Hello' . $format, '--app-path' => 'hello' . $format, '--web-path' => 'web', '--src-path' => 'src', '--format' => $format)); // autoload $content = file_get_contents($file = $tmpDir . '/src/autoload.php'); $content = str_replace("__DIR__.'/vendor", "'" . __DIR__ . "/../../../../src/vendor", $content); file_put_contents($file, $content); // Kernel $class = 'Hello' . $format . 'Kernel'; $file = $tmpDir . '/hello' . $format . '/' . $class . '.php'; $this->assertTrue(file_exists($file)); $content = file_get_contents($file); $content = str_replace("__DIR__.'/../src/vendor/Symfony/src/Symfony/Bundle'", "'" . __DIR__ . "/../../../../src/vendor/Symfony/src/Symfony/Bundle'", $content); file_put_contents($file, $content); require_once $file; $kernel = new $class('dev', true); $response = $kernel->handle(Request::create('/')); $this->assertRegExp('/successfully/', $response->getContent()); $filesystem->remove($tmpDir); }
public function testExecute() { $application = $this->getApplication(); $application->add(new ListCommand()); $command = $this->getApplication()->find('dev:module:create'); $root = getcwd(); // delete old module if (is_dir($root . '/N98Magerun_UnitTest')) { $filesystem = new Filesystem(); $filesystem->recursiveRemoveDirectory($root . '/N98Magerun_UnitTest'); clearstatcache(); } $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), '--add-all' => true, '--add-setup' => true, '--add-readme' => true, '--add-composer' => true, '--modman' => true, '--description' => 'Unit Test Description', '--author-name' => 'Unit Test', '--author-email' => '*****@*****.**', 'vendorNamespace' => 'N98Magerun', 'moduleName' => 'UnitTest')); $this->assertFileExists($root . '/N98Magerun_UnitTest/composer.json'); $this->assertFileExists($root . '/N98Magerun_UnitTest/readme.md'); $moduleBaseFolder = $root . '/N98Magerun_UnitTest/src/app/code/local/N98Magerun/UnitTest/'; $this->assertFileExists($moduleBaseFolder . 'etc/config.xml'); $this->assertFileExists($moduleBaseFolder . 'Block'); $this->assertFileExists($moduleBaseFolder . 'Model'); $this->assertFileExists($moduleBaseFolder . 'Helper'); $this->assertFileExists($moduleBaseFolder . 'data/n98magerun_unittest_setup'); $this->assertFileExists($moduleBaseFolder . 'sql/n98magerun_unittest_setup'); // delete old module if (is_dir($root . '/N98Magerun_UnitTest')) { $filesystem = new Filesystem(); $filesystem->recursiveRemoveDirectory($root . '/N98Magerun_UnitTest'); clearstatcache(); } }
/** * @param string $commandName * @param array $options * @return CommandTester */ protected function getCommandTester($commandName, array $options = []) { $command = $this->getApplication()->find($commandName); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $commandName], $options); return $commandTester; }
/** * @Then /^I should get the following products after apply the following updater to it:$/ * * @param TableNode $updates * * @throws \Exception */ public function iShouldGetTheFollowingProductsAfterApplyTheFollowingUpdaterToIt(TableNode $updates) { $application = $this->getApplicationsForUpdaterProduct(); $updateCommand = $application->find('pim:product:update'); $updateCommand->setContainer($this->getMainContext()->getContainer()); $updateCommandTester = new CommandTester($updateCommand); $getCommand = $application->find('pim:product:get'); $getCommand->setContainer($this->getMainContext()->getContainer()); $getCommandTester = new CommandTester($getCommand); foreach ($updates->getHash() as $update) { $username = isset($update['username']) ? $update['username'] : null; $updateCommandTester->execute(['command' => $updateCommand->getName(), 'identifier' => $update['product'], 'json_updates' => $update['actions'], 'username' => $username]); $expected = json_decode($update['result'], true); if (isset($expected['product'])) { $getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $expected['product']]); unset($expected['product']); } else { $getCommandTester->execute(['command' => $getCommand->getName(), 'identifier' => $update['product']]); } $actual = json_decode($getCommandTester->getDisplay(), true); if (null === $actual) { throw new \Exception(sprintf('An error occured during the execution of the update command : %s', $getCommandTester->getDisplay())); } if (null === $expected) { throw new \Exception(sprintf('Looks like the expected result is not valid json : %s', $update['result'])); } $diff = $this->arrayIntersect($actual, $expected); assertEquals($expected, $diff); } }
public function testExecute() { $expected = '/^Hashing pid data/'; $commandTester = new CommandTester($this->instance->find('haytool:pid-obfuscation')); $commandTester->execute(array()); $this->assertRegExp($expected, $commandTester->getDisplay()); }
/** * Runa a command in and returns the commandTester object. This method can * run either a blend command or a sub-application command * @param string $projectFolder * @param string $commandName * @param string $params * @param string $app In case of null it will be set to blend. In case of * className as string, the application's class name will be used * @return CommandTester */ public static function runCommand($projectFolder, $commandName, array $params = [], $app = null, $runOptions = []) { $loader = new ClassLoader(); $curDir = getcwd(); chdir($projectFolder); if ($app === null) { $app = new SetupApplication($projectFolder); } else { if (is_string($app)) { $classes = explode('\\', $app); $loader->addPsr4("{$classes[0]}\\", $projectFolder . '/src/'); $loader->register(true); $c = new Container(); $c->defineSingletonWithInterface('app', $app, ['scriptPath' => $projectFolder . '/bin']); $app = $c->get('app'); } } $commandTester = new CommandTester($app->find($commandName)); $commandTester->execute($params, $runOptions); chdir($curDir); $c = null; if ($loader) { $loader->unregister(); } return $commandTester; }
public function testExecute() { $this->moduleList->expects($this->once())->method('getNames')->willReturn([]); $commandTester = new CommandTester($this->command); $commandTester->execute([]); $this->assertContains('List of active modules', $commandTester->getDisplay()); }
/** * Test setting the flag option on the test command.. * * @return void * @author Dan Cox */ public function test_options() { $command = $this->DI->get('console')->find('test:command'); $CT = new CommandTester($command); $CT->execute(['command' => $command->getName(), 'test' => 'foo', '--flag' => true]); $this->assertContains('flag set', $CT->getDisplay()); }
/** * @dataProvider provideSites * @param string $root Root directory of site * @param string|null $config Path to configuration file */ public function testSites($root, $config = null) { $application = new Application(); $application->add(new BuildCommand()); /** @var \CastlePointAnime\Brancher\Command\BuildCommand $command */ $command = $application->find('build'); $commandTester = new CommandTester($command); $outputDir = self::$outputDir; $commandTester->execute(array_filter(['--config' => $config, '--exclude' => '_site', 'root' => $root, 'output' => $outputDir])); // Test to make sure existing files match $finder = new Finder(); $finder->files()->in("{$root}/_site"); /** @var \Symfony\Component\Finder\SplFileInfo $fileInfo */ foreach ($finder as $fileInfo) { $this->assertFileEquals($fileInfo->getPathname(), "{$outputDir}/{$fileInfo->getRelativePathname()}", $fileInfo->getPathname()); } // Test to make sure excluded files do not exist $excludeDirs = $command->getContainer()->getParameter('castlepointanime.brancher.build.excludes'); if (count($excludeDirs)) { $finder = new Finder(); $finder->files()->in($root)->exclude('_site')->exclude('_templates'); array_map([$finder, 'path'], $excludeDirs); /** @var \Symfony\Component\Finder\SplFileInfo $fileInfo */ foreach ($finder as $fileInfo) { $this->assertFileNotExists("{$outputDir}/{$fileInfo->getRelativePathname()}"); } } }
/** * @param string $commandName * @return CommandTester */ protected function getCommandTester($commandName) { $command = $this->getApplication()->find($commandName); $commandTester = new CommandTester($command); $commandTester->execute(array_merge(array('command' => $commandName))); return $commandTester; }
/** * @test */ public function exceptionWhileParsingLongUrlOutputsError() { $this->urlShortener->urlToShortCode(Argument::cetera())->willThrow(new InvalidUrlException())->shouldBeCalledTimes(1); $this->commandTester->execute(['command' => 'shortcode:generate', 'longUrl' => 'http://domain.com/invalid']); $output = $this->commandTester->getDisplay(); $this->assertTrue(strpos($output, 'Provided URL "http://domain.com/invalid" is invalid. Try with a different one.') === 0); }
/** * Runs the command and returns it's output. * * @param array $input Command input. * @param array $options Command tester options. * * @return string */ protected function runCommand(array $input = array(), array $options = array()) { $input['command'] = $this->command->getName(); $options['interactive'] = true; $this->commandTester->execute($input, $options); return $this->commandTester->getDisplay(); }
public function testExecute() { $application = $this->getApplication(); $application->add(new DumpCommand()); $setCommand = $this->getApplication()->find('config:set'); $deleteCommand = $this->getApplication()->find('config:delete'); /** * Add a new entry */ $commandTester = new CommandTester($setCommand); $commandTester->execute(array('command' => $setCommand->getName(), 'path' => 'imi_conrun/foo/bar', 'value' => '1234')); $this->assertContains('imi_conrun/foo/bar => 1234', $commandTester->getDisplay()); $commandTester = new CommandTester($deleteCommand); $commandTester->execute(array('command' => $deleteCommand->getName(), 'path' => 'imi_conrun/foo/bar')); $this->assertContains('| imi_conrun/foo/bar | default | 0 |', $commandTester->getDisplay()); /** * Delete all */ foreach (\Mage::app()->getStores() as $store) { // add multiple entries $commandTester = new CommandTester($setCommand); $commandTester->execute(array('command' => $setCommand->getName(), 'path' => 'imi_conrun/foo/bar', '--scope' => 'stores', '--scope-id' => $store->getId(), 'value' => 'store-' . $store->getId())); } $commandTester = new CommandTester($deleteCommand); $commandTester->execute(array('command' => $deleteCommand->getName(), 'path' => 'imi_conrun/foo/bar', '--all' => true)); foreach (\Mage::app()->getStores() as $store) { $this->assertContains('| imi_conrun/foo/bar | stores | ' . $store->getId() . ' |', $commandTester->getDisplay()); } }
public function testExecute() { /** * Check autoloading */ /* @var $application Application */ $application = (require __DIR__ . '/../../../src/bootstrap.php'); $application->setMagentoRootFolder($this->getTestMagentoRoot()); $this->assertInstanceOf('\\N98\\Magento\\Application', $application); $loader = $application->getAutoloader(); $this->assertInstanceOf('\\Composer\\Autoload\\ClassLoader', $loader); /** * Check version */ $this->assertEquals(Application::APP_VERSION, trim(file_get_contents(__DIR__ . '/../../../version.txt'))); /* @var $loader \Composer\Autoload\ClassLoader */ $prefixes = $loader->getPrefixes(); $this->assertArrayHasKey('N98', $prefixes); $distConfigArray = Yaml::parse(file_get_contents(__DIR__ . '/../../../config.yaml')); $configArray = array('autoloaders' => array('N98MagerunTest' => __DIR__ . '/_ApplicationTestSrc'), 'commands' => array('customCommands' => array(0 => 'N98MagerunTest\\TestDummyCommand'), 'aliases' => array(array('ssl' => 'sys:store:list'))), 'init' => array('options' => array('config_model' => 'N98MagerunTest\\AlternativeConfigModel'))); $application->setAutoExit(false); $application->init(ArrayFunctions::mergeArrays($distConfigArray, $configArray)); $application->run(new StringInput('list'), new NullOutput()); // Check if autoloaders, commands and aliases are registered $prefixes = $loader->getPrefixes(); $this->assertArrayHasKey('N98MagerunTest', $prefixes); $testDummyCommand = $application->find('n98mageruntest:test:dummy'); $this->assertInstanceOf('\\N98MagerunTest\\TestDummyCommand', $testDummyCommand); $commandTester = new CommandTester($testDummyCommand); $commandTester->execute(array('command' => $testDummyCommand->getName())); $this->assertContains('dummy', $commandTester->getDisplay()); $this->assertTrue($application->getDefinition()->hasOption('root-dir')); // check alias $this->assertInstanceOf('\\N98\\Magento\\Command\\System\\Store\\ListCommand', $application->find('ssl')); }
public function testCompile() { $command = $this->application->find('help'); $commandTester = new CommandTester($command); $commandTester->execute([], ['interactive' => false]); $this->assertTrue(true); }
/** * @param array $sampleDataPackages * @param int $appRunResult - int 0 if everything went fine, or an error code * @param string $expectedMsg * @return void * * @dataProvider processDataProvider */ public function testExecute(array $sampleDataPackages, $appRunResult, $expectedMsg) { $directoryRead = $this->getMock('\\Magento\\Framework\\Filesystem\\Directory\\ReadInterface', [], [], '', false); $directoryRead->expects($this->any())->method('getAbsolutePath')->willReturn('/path/to/composer.json'); $filesystem = $this->getMock('Magento\\Framework\\Filesystem', [], [], '', false); $filesystem->expects($this->any())->method('getDirectoryRead')->with(DirectoryList::ROOT)->willReturn($directoryRead); $sampleDataDependency = $this->getMock('Magento\\SampleData\\Model\\Dependency', [], [], '', false); $sampleDataDependency->expects($this->any())->method('getSampleDataPackages')->willReturn($sampleDataPackages); $arrayInputFactory = $this->getMock('Symfony\\Component\\Console\\Input\\ArrayInputFactory', ['create'], [], '', false); $arrayInputFactory->expects($this->never())->method('create'); array_walk($sampleDataPackages, function (&$v, $k) { $v = "{$k}:{$v}"; }); $packages = array_values($sampleDataPackages); $requireArgs = ['command' => 'require', '--working-dir' => '/path/to/composer.json', '--no-progress' => 1, 'packages' => $packages]; $commandInput = new \Symfony\Component\Console\Input\ArrayInput($requireArgs); $application = $this->getMock('Composer\\Console\\Application', [], [], '', false); $application->expects($this->any())->method('run')->with($commandInput, $this->anything())->willReturn($appRunResult); if ($appRunResult !== 0 && !empty($sampleDataPackages)) { $application->expects($this->once())->method('resetComposer')->willReturnSelf(); } $applicationFactory = $this->getMock('Composer\\Console\\ApplicationFactory', ['create'], [], '', false); $applicationFactory->expects($this->any())->method('create')->willReturn($application); $commandTester = new CommandTester(new SampleDataDeployCommand($filesystem, $sampleDataDependency, $arrayInputFactory, $applicationFactory)); $commandTester->execute([]); $this->assertEquals($expectedMsg, $commandTester->getDisplay()); }
public static function setUpBeforeClass() { @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Resources/config/routing.rest.yml'); @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/CarController.php'); @unlink(__DIR__ . '/../Fixtures/Test/TestBundle/Controller/OrderController.php'); $kernel = new \AppKernel('test', true); $app = new Application($kernel); $app->addCommands(array(new GenerateRestControllerCommand())); $kernel->boot(); $command = $app->find('generate:rest:controller'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Order', '--entity' => 'TestTestBundle:Order', '--mongo' => true), array('interactive' => false)); $kernel->shutdown(); $kernel = new \AppKernel('test', true); $app = new Application($kernel); $app->addCommands(array(new GenerateRestControllerCommand())); $kernel->boot(); $command = $app->find('generate:rest:controller'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName(), '--controller' => 'TestTestBundle:Car', '--entity' => 'TestTestBundle:Car'), array('interactive' => false)); $kernel->shutdown(); @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php.meta'); @unlink(__DIR__ . '/../app/cache/test/appTestUrlGenerator.php'); @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php.meta'); @unlink(__DIR__ . '/../app/cache/test/appTestUrlMatcher.php'); }
/** * Asserts that the output contains the give regex * * @param $regex */ public function seeOutput($regex) { if (empty($this->commandTester)) { throw new \RuntimeException('You need to call runTheCommand() before checking the output'); } $this->assertRegExp('/' . preg_quote($regex, '/') . '/', $this->commandTester->getDisplay()); }
/** * @dataProvider dataProviderTestExecute * @param string $moduleName * @param int $all * @param array $contains * @param array $notContains */ public function testExecute($moduleName, $all, array $contains, array $notContains) { $application = $this->getApplication(); $application->add(new FromCommand()); $command = $this->getApplication()->find('dev:module:dependencies:from'); $commandTester = new CommandTester($command); $input = array('command' => $command->getName(), 'moduleName' => $moduleName); switch ($all) { case 2: $input['-a'] = true; break; case 1: $input['--all'] = true; break; default: break; } $commandTester->execute($input); foreach ($contains as $expectation) { $this->assertContains($expectation, $commandTester->getDisplay()); } foreach ($notContains as $expectation) { $this->assertNotContains($expectation, $commandTester->getDisplay()); } }
public function testCommand() { $command = Environment::getService('console')->find('system:register'); $answers = ['y', '/import', '1']; $helper = $command->getHelper('question'); $helper->setInputStream($this->getInputStream(implode("\n", $answers) . "\n")); $commandTester = new CommandTester($command); $commandTester->execute(['command' => $command->getName(), 'class' => 'Fusio\\Impl\\Tests\\Adapter\\TestAdapter']); $display = $commandTester->getDisplay(); $this->assertRegExp('/Registration successful/', $display, $display); // check action class $actionId = $this->connection->fetchColumn('SELECT id FROM fusio_action_class WHERE class = :class', ['class' => 'Fusio\\Impl\\Tests\\Adapter\\Test\\VoidAction']); $this->assertEquals(4, $actionId); // check connection class $connectionId = $this->connection->fetchColumn('SELECT id FROM fusio_connection_class WHERE class = :class', ['class' => 'Fusio\\Impl\\Tests\\Adapter\\Test\\VoidConnection']); $this->assertEquals(3, $connectionId); // check connection $connection = $this->connection->fetchAssoc('SELECT id, class, config FROM fusio_connection WHERE name = :name', ['name' => 'Adapter-Connection']); $this->assertEquals(2, $connection['id']); $this->assertEquals('Fusio\\Impl\\Tests\\Adapter\\Test\\VoidConnection', $connection['class']); $this->assertEquals(69, strlen($connection['config'])); // check schema $schema = $this->connection->fetchAssoc('SELECT id, source, cache FROM fusio_schema WHERE name = :name', ['name' => 'Adapter-Schema']); $source = <<<JSON { "id": "http://fusio-project.org", "title": "process", "type": "object", "properties": { "logId": { "type": "integer" }, "title": { "type": "string" }, "content": { "type": "string" } } } JSON; $this->assertEquals(3, $schema['id']); $this->assertJsonStringEqualsJsonString($source, $schema['source']); $this->assertInstanceOf('PSX\\Schema\\Schema', unserialize($schema['cache'])); // check action $action = $this->connection->fetchAssoc('SELECT id, class, config FROM fusio_action WHERE name = :name', ['name' => 'Void-Action']); $this->assertEquals(4, $action['id']); $this->assertEquals('Fusio\\Impl\\Tests\\Adapter\\Test\\VoidAction', $action['class']); $this->assertEquals(['foo' => 'bar', 'connection' => '2'], unserialize($action['config'])); // check routes $route = $this->connection->fetchAssoc('SELECT id, status, methods, controller FROM fusio_routes WHERE path = :path', ['path' => '/import/void']); $this->assertEquals(62, $route['id']); $this->assertEquals(1, $route['status']); $this->assertEquals('GET|POST|PUT|DELETE', $route['methods']); $this->assertEquals('Fusio\\Impl\\Controller\\SchemaApiController', $route['controller']); // check methods $methods = $this->connection->fetchAll('SELECT routeId, method, version, status, active, public, request, response, action FROM fusio_routes_method WHERE routeId = :routeId', ['routeId' => $route['id']]); $this->assertEquals(1, count($methods)); $this->assertEquals(['routeId' => 62, 'method' => 'GET', 'version' => 1, 'status' => Resource::STATUS_DEVELOPMENT, 'active' => 1, 'public' => 1, 'request' => 3, 'response' => 1, 'action' => 4], $methods[0]); }
public function testExecute() { $command = $this->getApplication()->find('list'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => 'list')); $this->assertContains(sprintf('imi-conrun version %s by netz98 new media GmbH', $this->getApplication()->getVersion()), $commandTester->getDisplay()); }
public function testExecute() { $command = $this->getApplication()->find('help'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => 'help')); $this->assertContains('The help command displays help for a given command', $commandTester->getDisplay()); }
public function testExecute() { $command = $this->console->find('version'); $commandTester = new CommandTester($command); $commandTester->execute(array('command' => $command->getName())); $this->assertEquals($this->console->project->version, trim($commandTester->getDisplay())); }
/** * @expectedException \InvalidArgumentException * @expectedExceptionMessage The following requested cache types are not supported: */ public function testExecuteInvalidCacheType() { $this->cacheManagerMock->expects($this->once())->method('getAvailableTypes')->willReturn(['A', 'B', 'C']); $param = ['types' => ['A', 'D']]; $commandTester = new CommandTester($this->command); $commandTester->execute($param); }
/** * @covers \Ilios\CliBundle\Command\ListRootUsersCommand::execute */ public function testListUsersNoResults() { $this->userManager->shouldReceive('findDTOsBy')->with(['root' => true])->andReturn([]); $this->commandTester->execute(['command' => ListRootUsersCommand::COMMAND_NAME]); $output = $this->commandTester->getDisplay(); $this->assertEquals('No users with root-level privileges found.', trim($output)); }
public function testExecute() { $cmd = $this->getCommandInstance(); $cmdTester = new CommandTester($cmd); try { $cmdTester->execute(array('command' => $cmd->getName())); $this->fail('The command without arguments should throw a \\RuntimeException'); } catch (\Exception $e) { $this->assertInstanceOf('\\RuntimeException', $e); } try { $cmdTester->execute(array('command' => $cmd->getName(), 'product' => 'Test')); $this->fail('The command without "service_id" argument should throw a \\RuntimeException'); } catch (\Exception $e) { $this->assertInstanceOf('\\RuntimeException', $e); } /* try { $cmdTester->execute(array( 'command' => $cmd->getName(), 'product' => 'Test', 'service_id' => 2 )); } catch (\Exception $e) { $this->fail('No exception should be thrown when all arguments are provided'); } */ }