本文整理汇总了PHP中LimeTest::like方法的典型用法代码示例。如果您正苦于以下问题:PHP LimeTest::like方法的具体用法?PHP LimeTest::like怎么用?PHP LimeTest::like使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LimeTest
的用法示例。
在下文中一共展示了LimeTest::like方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: LimeTest
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../../bootstrap.php';
use Symfony\Components\CLI\Tester\CommandTester;
use Symfony\Components\CLI\Application;
$t = new LimeTest(2);
$application = new Application();
// ->execute()
$t->diag('->execute()');
$commandTester = new CommandTester($application->getCommand('list'));
$commandTester->execute(array());
$t->like($commandTester->getDisplay(), '/help Displays help for a command/', '->execute() returns a list of available commands');
$commandTester->execute(array('--xml' => true));
$t->like($commandTester->getDisplay(), '/<command id="list" namespace="_global" name="list">/', '->execute() returns a list of available commands in XML if --xml is passed');
示例2: LimeTest
<?php
/*
* This file is part of the symfony package.
* (c) Fabien Potencier <fabien.potencier@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../../bootstrap.php';
use Symfony\Components\CLI\Tester\CommandTester;
use Symfony\Components\CLI\Command\HelpCommand;
use Symfony\Components\CLI\Command\ListCommand;
use Symfony\Components\CLI\Application;
$t = new LimeTest(4);
// ->execute()
$t->diag('->execute()');
$command = new HelpCommand();
$command->setCommand(new ListCommand());
$commandTester = new CommandTester($command);
$commandTester->execute(array());
$t->like($commandTester->getDisplay(), '/list \\[--xml\\] \\[namespace\\]/', '->execute() returns a text help for the given command');
$commandTester->execute(array('--xml' => true));
$t->like($commandTester->getDisplay(), '/<command/', '->execute() returns an XML help text if --xml is passed');
$application = new Application();
$commandTester = new CommandTester($application->getCommand('help'));
$commandTester->execute(array('command_name' => 'list'));
$t->like($commandTester->getDisplay(), '/list \\[--xml\\] \\[namespace\\]/', '->execute() returns a text help for the given command');
$commandTester->execute(array('command_name' => 'list', '--xml' => true));
$t->like($commandTester->getDisplay(), '/<command/', '->execute() returns an XML help text if --xml is passed');
示例3: Application
$t->is($application->asText('foo'), file_get_contents($fixtures . '/application_astext2.txt'), '->asText() returns a text representation of the application');
// ->asXml()
$t->diag('->asXml()');
$application = new Application();
$application->addCommand(new FooCommand());
$t->is($application->asXml(), file_get_contents($fixtures . '/application_asxml1.txt'), '->asXml() returns an XML representation of the application');
$t->is($application->asXml('foo'), file_get_contents($fixtures . '/application_asxml2.txt'), '->asXml() returns an XML representation of the application');
// ->renderException()
$t->diag('->renderException()');
$application = new Application();
$application->setAutoExit(false);
$tester = new ApplicationTester($application);
$tester->run(array('command' => 'foo'));
$t->is($tester->getDisplay(), file_get_contents($fixtures . '/application_renderexception1.txt'), '->renderException() renders a pretty exception');
$tester->run(array('command' => 'foo'), array('verbosity' => Output::VERBOSITY_VERBOSE));
$t->like($tester->getDisplay(), '/Exception trace/', '->renderException() renders a pretty exception with a stack trace when verbosity is verbose');
$tester->run(array('command' => 'list', '--foo' => true));
$t->is($tester->getDisplay(), file_get_contents($fixtures . '/application_renderexception2.txt'), '->renderException() renders the command synopsis when an exception occurs in the context of a command');
// ->run()
$t->diag('->run()');
$application = new Application();
$application->setAutoExit(false);
$application->setCatchExceptions(false);
$application->addCommand($command = new Foo1Command());
$_SERVER['argv'] = array('cli.php', 'foo:bar1');
ob_start();
$application->run();
ob_end_clean();
$t->is(get_class($command->input), 'Symfony\\Components\\CLI\\Input\\ArgvInput', '->run() creates an ArgvInput by default if none is given');
$t->is(get_class($command->output), 'Symfony\\Components\\CLI\\Output\\ConsoleOutput', '->run() creates a ConsoleOutput by default if none is given');
$application = new Application();