setAppNamespace(); Plugin::load('TestPlugin'); $this->out = new ConsoleOutput(); $this->err = new ConsoleOutput(); $this->io = new ConsoleIo($this->out, $this->err); $this->shell = new HelpShell($this->io); $commands = new CommandCollection(); $commands->addMany($commands->autoDiscover()); $this->shell->setCommandCollection($commands); } /** * Test the command listing fallback when no commands are set * * @return void */ public function testMainNoCommandsFallback() { $shell = new HelpShell($this->io); $this->assertNull($shell->main()); $output = implode("\n", $this->out->messages()); $this->assertOutput($output); } /** * Test the command listing * * @return void */ public function testMain() { $this->assertNull($this->shell->main()); $output = implode("\n", $this->out->messages()); $this->assertOutput($output); } /** * Assert the help output. * * @param string $output The output to check. * @return void */ protected function assertOutput($output) { $this->assertContains('- sample', $output, 'app shell'); $this->assertContains('- test_plugin.sample', $output, 'Long plugin name'); $this->assertContains('- routes', $output, 'core shell'); $this->assertContains('- test_plugin.example', $output, 'Long plugin name'); $this->assertContains('To run a command', $output, 'more info present'); $this->assertContains('To get help', $output, 'more info present'); } /** * Test help --xml * * @return void */ public function testMainAsXml() { $this->shell->params['xml'] = true; $this->shell->main(); $output = implode("\n", $this->out->messages()); $this->assertContains('', $output); $find = 'assertContains($find, $output); $find = 'assertContains($find, $output); $find = 'assertContains($find, $output); } }