/** * Constructor. * * If there is no readline support for the current PHP executable * a \RuntimeException exception is thrown. * * @param Application $application An application instance * * @throws \RuntimeException When Readline extension is not enabled */ public function __construct(Application $application) { if (!function_exists('readline')) { throw new \RuntimeException('Unable to start the shell as the Readline extension is not enabled.'); } $this->application = $application; $this->history = getenv('HOME') . '/.history_' . $application->getName(); $this->output = new ConsoleOutput(); }
public function testSetGetName() { $application = new Application(); $application->setName('foo'); $this->assertEquals('foo', $application->getName(), '->setName() sets the name of the application'); }
require_once $fixtures.'/Foo2Command.php'; $t = new LimeTest(52); // __construct() $t->diag('__construct()'); $application = new Application('foo', 'bar'); $t->is($application->getName(), 'foo', '__construct() takes the application name as its first argument'); $t->is($application->getVersion(), 'bar', '__construct() takes the application version as its first argument'); $t->is(array_keys($application->getCommands()), array('help', 'list'), '__construct() registered the help and list commands by default'); // ->setName() ->getName() $t->diag('->setName() ->getName()'); $application = new Application(); $application->setName('foo'); $t->is($application->getName(), 'foo', '->setName() sets the name of the application'); // ->getVersion() ->getVersion() $t->diag('->getVersion() ->getVersion()'); $application = new Application(); $application->setVersion('bar'); $t->is($application->getVersion(), 'bar', '->setVersion() sets the version of the application'); // ->getLongVersion() $t->diag('->getLongVersion()'); $application = new Application('foo', 'bar'); $t->is($application->getLongVersion(), '<info>foo</info> version <comment>bar</comment>', '->getLongVersion() returns the long version of the application'); // ->getHelp() $t->diag('->getHelp()'); $application = new Application();