setAppNamespace();
$this->useCommandRunner();
Plugin::getCollection()->clear();
$app = $this->getMockForAbstractClass(
BaseApplication::class,
['']
);
$app->addPlugin('TestPlugin');
}
/**
* tearDown
*
* @return void
*/
public function tearDown(): void
{
parent::tearDown();
$this->clearPlugins();
}
/**
* Test the command listing fallback when no commands are set
*
* @return void
*/
public function testMainNoCommandsFallback()
{
$this->exec('help');
$this->assertExitCode(Command::CODE_SUCCESS);
$this->assertCommandList();
$this->clearPlugins();
}
/**
* Test the command listing
*
* @return void
*/
public function testMain()
{
$this->exec('help');
$this->assertExitCode(Command::CODE_SUCCESS);
$this->assertCommandList();
}
/**
* Assert the help output.
*
* @return void
*/
protected function assertCommandList()
{
$this->assertOutputContains('TestPlugin', 'plugin header should appear');
$this->assertOutputContains('- widget', 'plugin command should appear');
$this->assertOutputNotContains(
'- test_plugin.widget',
'only short alias for plugin command.'
);
$this->assertOutputContains('App', 'app header should appear');
$this->assertOutputContains('- sample', 'app shell');
$this->assertOutputContains('CakePHP', 'cakephp header should appear');
$this->assertOutputContains('- routes', 'core shell');
$this->assertOutputContains('- example', 'short plugin name');
$this->assertOutputContains('- abort', 'command object');
$this->assertOutputContains('To run a command', 'more info present');
$this->assertOutputContains('To get help', 'more info present');
}
/**
* Test help --xml
*
* @return void
*/
public function testMainAsXml()
{
$this->exec('help --xml');
$this->assertExitCode(Command::CODE_SUCCESS);
$this->assertOutputContains('');
$find = 'assertOutputContains($find);
$find = 'assertOutputContains($find);
$find = 'assertOutputContains($find);
}
}