本文整理汇总了PHP中LimeTest::pass方法的典型用法代码示例。如果您正苦于以下问题:PHP LimeTest::pass方法的具体用法?PHP LimeTest::pass怎么用?PHP LimeTest::pass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LimeTest
的用法示例。
在下文中一共展示了LimeTest::pass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: catch
$t->is($sc['bar'], 'foo', '->offsetGet() gets the value of a parameter');
$sc['bar1'] = 'foo1';
$t->is($sc['bar1'], 'foo1', '->offsetset() sets the value of a parameter');
unset($sc['bar1']);
$t->ok(!isset($sc['bar1']), '->offsetUnset() removes a parameter');
$sc->setParameter('foo', 'baz');
$t->is($sc->getParameter('foo'), 'baz', '->setParameter() overrides previously set parameter');
$sc->setParameter('Foo', 'baz1');
$t->is($sc->getParameter('foo'), 'baz1', '->setParameter() converts the key to lowercase');
$t->is($sc->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase');
$t->is($sc['FOO'], 'baz1', '->offsetGet() converts the key to lowercase');
try {
$sc->getParameter('baba');
$t->fail('->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
} catch (\InvalidArgumentException $e) {
$t->pass('->getParameter() thrown an \\InvalidArgumentException if the key does not exist');
}
try {
$sc['baba'];
$t->fail('->offsetGet() thrown an \\InvalidArgumentException if the key does not exist');
} catch (\InvalidArgumentException $e) {
$t->pass('->offsetGet() thrown an \\InvalidArgumentException if the key does not exist');
}
// ->hasParameter()
$t->diag('->hasParameter()');
$sc = new Container(array('foo' => 'bar'));
$t->ok($sc->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined');
$t->ok($sc->hasParameter('Foo'), '->hasParameter() converts the key to lowercase');
$t->ok(isset($sc['Foo']), '->offsetExists() converts the key to lowercase');
$t->ok(!$sc->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined');
$t->ok(isset($sc['foo']), '->offsetExists() returns true if a parameter is defined');
示例2: LimeTest
$t = new LimeTest(5);
$stream = fopen('php://memory', 'a', false);
// __construct()
$t->diag('__construct()');
try
{
$output = new StreamOutput('foo');
$t->fail('__construct() throws an \InvalidArgumentException if the first argument is not a stream');
}
catch (\InvalidArgumentException $e)
{
$t->pass('__construct() throws an \InvalidArgumentException if the first argument is not a stream');
}
$output = new StreamOutput($stream, Output::VERBOSITY_QUIET, true);
$t->is($output->getVerbosity(), Output::VERBOSITY_QUIET, '__construct() takes the verbosity as its first argument');
$t->is($output->isDecorated(), true, '__construct() takes the decorated flag as its second argument');
// ->getStream()
$t->diag('->getStream()');
$output = new StreamOutput($stream);
$t->is($output->getStream(), $stream, '->getStream() returns the current stream');
// ->doWrite()
$t->diag('->doWrite()');
$output = new StreamOutput($stream);
$output->writeln('foo');
示例3: 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\Output\NullOutput;
$t = new LimeTest(1);
$output = new NullOutput();
$output->write('foo');
$t->pass('->write() does nothing');
示例4: ProjectLoader
}
}
// ->loadFile()
$t->diag('->loadFile()');
$loader = new ProjectLoader($fixturesPath.'/ini');
try
{
$loader->loadFile('foo.yml');
$t->fail('->load() throws an InvalidArgumentException if the loaded file does not exist');
}
catch (InvalidArgumentException $e)
{
$t->pass('->load() throws an InvalidArgumentException if the loaded file does not exist');
}
try
{
$loader->loadFile('parameters.ini');
$t->fail('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file');
}
catch (InvalidArgumentException $e)
{
$t->pass('->load() throws an InvalidArgumentException if the loaded file is not a valid YAML file');
}
$loader = new ProjectLoader($fixturesPath.'/yaml');
foreach (array('nonvalid1', 'nonvalid2') as $fixture)
示例5: trim
$test = $parser->parse($yaml);
if (isset($test['todo']) && $test['todo']) {
$t->todo($test['test']);
} else {
$expected = var_export(eval('return ' . trim($test['php']) . ';'), true);
$t->is(var_export($parser->parse($test['yaml']), true), $expected, $test['test']);
}
}
}
// test tabs in YAML
$yamls = array("foo:\n\tbar", "foo:\n \tbar", "foo:\n\t bar", "foo:\n \t bar");
foreach ($yamls as $yaml) {
try {
$content = $parser->parse($yaml);
$t->fail('YAML files must not contain tabs');
} catch (ParserException $e) {
$t->pass('YAML files must not contain tabs');
}
}
// objects
$t->diag('Objects support');
class A
{
public $a = 'foo';
}
$a = array('foo' => new A(), 'bar' => 1);
$t->is($parser->parse(<<<EOF
foo: !!php/object:O:1:"A":1:{s:1:"a";s:3:"foo";}
bar: 1
EOF
), $a, '->parse() is able to dump objects');
示例6: ArrayInput
$t->is($input->getArgument('name'), 'foo', '->__construct() takes a Definition as an argument');
// ->getOption() ->setOption() ->getOptions()
$t->diag('->getOption() ->setOption() ->getOptions()');
$input = new ArrayInput(array('--name' => 'foo'), new Definition(array(new Option('name'))));
$t->is($input->getOption('name'), 'foo', '->getOption() returns the value for the given option');
$input->setOption('name', 'bar');
$t->is($input->getOption('name'), 'bar', '->setOption() sets the value for a given option');
$t->is($input->getOptions(), array('name' => 'bar'), '->getOptions() returns all option values');
$input = new ArrayInput(array('--name' => 'foo'), new Definition(array(new Option('name'), new Option('bar', '', Option::PARAMETER_OPTIONAL, '', 'default'))));
$t->is($input->getOption('bar'), 'default', '->getOption() returns the default value for optional options');
$t->is($input->getOptions(), array('name' => 'foo', 'bar' => 'default'), '->getOptions() returns all option values, even optional ones');
try {
$input->setOption('foo', 'bar');
$t->fail('->setOption() throws a \\InvalidArgumentException if the option does not exist');
} catch (\InvalidArgumentException $e) {
$t->pass('->setOption() throws a \\InvalidArgumentException if the option does not exist');
}
try {
$input->getOption('foo');
$t->fail('->getOption() throws a \\InvalidArgumentException if the option does not exist');
} catch (\InvalidArgumentException $e) {
$t->pass('->getOption() throws a \\InvalidArgumentException if the option does not exist');
}
// ->getArgument() ->setArgument() ->getArguments()
$t->diag('->getArgument() ->setArgument() ->getArguments()');
$input = new ArrayInput(array('name' => 'foo'), new Definition(array(new Argument('name'))));
$t->is($input->getArgument('name'), 'foo', '->getArgument() returns the value for the given argument');
$input->setArgument('name', 'bar');
$t->is($input->getArgument('name'), 'bar', '->setArgument() sets the value for a given argument');
$t->is($input->getArguments(), array('name' => 'bar'), '->getArguments() returns all argument values');
$input = new ArrayInput(array('name' => 'foo'), new Definition(array(new Argument('name'), new Argument('bar', Argument::OPTIONAL, '', 'default'))));
示例7: LimeTest
*/
require_once __DIR__ . '/../../../../bootstrap.php';
use Symfony\Components\CLI\Input\Option;
use Symfony\Components\CLI\Exception;
$t = new LimeTest(34);
// __construct()
$t->diag('__construct()');
$option = new Option('foo');
$t->is($option->getName(), 'foo', '__construct() takes a name as its first argument');
$option = new Option('--foo');
$t->is($option->getName(), 'foo', '__construct() removes the leading -- of the option name');
try {
$option = new Option('foo', 'f', Option::PARAMETER_IS_ARRAY);
$t->fail('->setDefault() throws an Exception if PARAMETER_IS_ARRAY option is used when an option does not accept a value');
} catch (\Exception $e) {
$t->pass('->setDefault() throws an Exception if PARAMETER_IS_ARRAY option is used when an option does not accept a value');
}
// shortcut argument
$option = new Option('foo', 'f');
$t->is($option->getShortcut(), 'f', '__construct() can take a shortcut as its second argument');
$option = new Option('foo', '-f');
$t->is($option->getShortcut(), 'f', '__construct() removes the leading - of the shortcut');
// mode argument
$option = new Option('foo', 'f');
$t->is($option->acceptParameter(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default');
$t->is($option->isParameterRequired(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default');
$t->is($option->isParameterOptional(), false, '__construct() gives a "Option::PARAMETER_NONE" mode by default');
$option = new Option('foo', 'f', null);
$t->is($option->acceptParameter(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode');
$t->is($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode');
$t->is($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_NONE" as its mode');
示例8: 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';
require_once __DIR__ . '/../../../../../fixtures/Symfony/Components/DependencyInjection/includes/ProjectExtension.php';
$t = new LimeTest(2);
// ->load()
$t->diag('->load()');
$extension = new ProjectExtension();
try {
$extension->load('foo', array());
$t->fail('->load() throws an InvalidArgumentException if the tag does not exist');
} catch (InvalidArgumentException $e) {
$t->pass('->load() throws an InvalidArgumentException if the tag does not exist');
}
$config = $extension->load('bar', array('foo' => 'bar'));
$t->is($config->getParameters(), array('project.parameter.bar' => 'bar'), '->load() calls the method tied to the given tag');
示例9: TestOutput
$output->write('foo');
$t->is($output->output, '', '->write() outputs nothing if verbosity is set to VERBOSITY_QUIET');
$output = new TestOutput();
$output->write(array('foo', 'bar'));
$t->is($output->output, "foo\nbar\n", '->write() can take an array of messages to output');
$output = new TestOutput();
$output->write('<info>foo</info>', Output::OUTPUT_RAW);
$t->is($output->output, "<info>foo</info>\n", '->write() outputs the raw message if OUTPUT_RAW is specified');
$output = new TestOutput();
$output->write('<info>foo</info>', Output::OUTPUT_PLAIN);
$t->is($output->output, "foo\n", '->write() strips decoration tags if OUTPUT_PLAIN is specified');
$output = new TestOutput();
$output->setDecorated(false);
$output->write('<info>foo</info>');
$t->is($output->output, "foo\n", '->write() strips decoration tags if decoration is set to false');
$output = new TestOutput();
$output->setDecorated(true);
$output->write('<foo>foo</foo>');
$t->is($output->output, "[33;41;5mfoo[0m\n", '->write() decorates the output');
try {
$output->write('<foo>foo</foo>', 24);
$t->fail('->write() throws an \\InvalidArgumentException when the type does not exist');
} catch (\InvalidArgumentException $e) {
$t->pass('->write() throws an \\InvalidArgumentException when the type does not exist');
}
try {
$output->write('<bar>foo</bar>');
$t->fail('->write() throws an \\InvalidArgumentException when a style does not exist');
} catch (\InvalidArgumentException $e) {
$t->pass('->write() throws an \\InvalidArgumentException when a style does not exist');
}
示例10: ArrayInput
// ->hasParameterOption()
$t->diag('->hasParameterOption()');
$input = new ArrayInput(array('name' => 'Fabien', '--foo' => 'bar'));
$t->ok($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
$t->ok(!$input->hasParameterOption('--bar'), '->hasParameterOption() returns false if an option is not present in the passed parameters');
$input = new ArrayInput(array('--foo'));
$t->ok($input->hasParameterOption('--foo'), '->hasParameterOption() returns true if an option is present in the passed parameters');
// ->parse()
$t->diag('->parse()');
$input = new ArrayInput(array('name' => 'foo'), new Definition(array(new Argument('name'))));
$t->is($input->getArguments(), array('name' => 'foo'), '->parse() parses required arguments');
try {
$input = new ArrayInput(array('foo' => 'foo'), new Definition(array(new Argument('name'))));
$t->fail('->parse() throws an \\InvalidArgumentException exception if an invalid argument is passed');
} catch (\RuntimeException $e) {
$t->pass('->parse() throws an \\InvalidArgumentException exception if an invalid argument is passed');
}
$input = new ArrayInput(array('--foo' => 'bar'), new Definition(array(new Option('foo'))));
$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options');
$input = new ArrayInput(array('--foo' => 'bar'), new Definition(array(new Option('foo', 'f', Option::PARAMETER_OPTIONAL, '', 'default'))));
$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a default value');
$input = new ArrayInput(array('--foo' => null), new Definition(array(new Option('foo', 'f', Option::PARAMETER_OPTIONAL, '', 'default'))));
$t->is($input->getOptions(), array('foo' => 'default'), '->parse() parses long options with a default value');
try {
$input = new ArrayInput(array('--foo' => null), new Definition(array(new Option('foo', 'f', Option::PARAMETER_REQUIRED))));
$t->fail('->parse() throws an \\InvalidArgumentException exception if a required option is passed without a value');
} catch (\RuntimeException $e) {
$t->pass('->parse() throws an \\InvalidArgumentException exception if a required option is passed without a value');
}
try {
$input = new ArrayInput(array('--foo' => 'foo'), new Definition());
示例11: array
$t->ok($engine->getRenderers() === array('php' => $renderer), '__construct() can overridde the default PHP renderer');
$engine = new ProjectTemplateEngine($loader, array(), $helperSet = new HelperSet());
$t->ok($engine->getHelperSet() === $helperSet, '__construct() takes a helper set as its third argument');
// ->getHelperSet() ->setHelperSet()
$t->diag('->getHelperSet() ->setHelperSet()');
$engine = new ProjectTemplateEngine($loader);
$engine->setHelperSet(new HelperSet(array('foo' => $helper = new SimpleHelper('bar'))));
$t->is((string) $engine->getHelperSet()->get('foo'), 'bar', '->setHelperSet() sets a helper set');
// __get()
$t->diag('__get()');
$t->is($engine->foo, $helper, '->__get() returns the value of a helper');
try {
$engine->bar;
$t->fail('->__get() throws an InvalidArgumentException if the helper is not defined');
} catch (InvalidArgumentException $e) {
$t->pass('->__get() throws an InvalidArgumentException if the helper is not defined');
}
// ->get() ->set() ->has()
$t->diag('->get() ->set() ->has()');
$engine = new ProjectTemplateEngine($loader);
$engine->set('foo', 'bar');
$t->is($engine->get('foo'), 'bar', '->set() sets a slot value');
$t->is($engine->get('bar', 'bar'), 'bar', '->get() takes a default value to return if the slot does not exist');
$t->ok($engine->has('foo'), '->has() returns true if the slot exists');
$t->ok(!$engine->has('bar'), '->has() returns false if the slot does not exist');
// ->output()
$t->diag('->output()');
ob_start();
$ret = $engine->output('foo');
$output = ob_get_clean();
$t->is($output, 'bar', '->output() outputs the content of a slot');
示例12: array
$t->is($input->getArguments(), array('name' => 'foo'), '->parse() is stateless');
$input = new TestInput(array('cli.php', '--foo'));
$input->bind(new Definition(array(new Option('foo'))));
$t->is($input->getOptions(), array('foo' => true), '->parse() parses long options without parameter');
$input = new TestInput(array('cli.php', '--foo=bar'));
$input->bind(new Definition(array(new Option('foo', 'f', Option::PARAMETER_REQUIRED))));
$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a = separator)');
$input = new TestInput(array('cli.php', '--foo', 'bar'));
$input->bind(new Definition(array(new Option('foo', 'f', Option::PARAMETER_REQUIRED))));
$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses long options with a required parameter (with a space separator)');
try {
$input = new TestInput(array('cli.php', '--foo'));
$input->bind(new Definition(array(new Option('foo', 'f', Option::PARAMETER_REQUIRED))));
$t->fail('->parse() throws a \\RuntimeException if no parameter is passed to an option when it is required');
} catch (\RuntimeException $e) {
$t->pass('->parse() throws a \\RuntimeException if no parameter is passed to an option when it is required');
}
$input = new TestInput(array('cli.php', '-f'));
$input->bind(new Definition(array(new Option('foo', 'f'))));
$t->is($input->getOptions(), array('foo' => true), '->parse() parses short options without parameter');
$input = new TestInput(array('cli.php', '-fbar'));
$input->bind(new Definition(array(new Option('foo', 'f', Option::PARAMETER_REQUIRED))));
$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with no separator)');
$input = new TestInput(array('cli.php', '-f', 'bar'));
$input->bind(new Definition(array(new Option('foo', 'f', Option::PARAMETER_REQUIRED))));
$t->is($input->getOptions(), array('foo' => 'bar'), '->parse() parses short options with a required parameter (with a space separator)');
$input = new TestInput(array('cli.php', '-f', '-b', 'foo'));
$input->bind(new Definition(array(new Argument('name'), new Option('foo', 'f', Option::PARAMETER_OPTIONAL), new Option('bar', 'b'))));
$t->is($input->getOptions(), array('foo' => null, 'bar' => true), '->parse() parses short options with an optional parameter which is not present');
try {
$input = new TestInput(array('cli.php', '-f'));
示例13: LimeTest
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../../bootstrap.php';
require_once __DIR__ . '/../../../../../lib/SymfonyTests/Components/Templating/SimpleHelper.php';
use Symfony\Components\Templating\Helper\HelperSet;
use Symfony\Components\Templating\Engine;
use Symfony\Components\Templating\Loader\FilesystemLoader;
$t = new LimeTest(7);
$engine = new Engine(new FilesystemLoader('/'));
// __construct()
$t->diag('__construct()');
$helperSet = new HelperSet(array('foo' => $helper = new SimpleHelper('foo')));
$t->ok($helperSet->has('foo'), '__construct() takes an array of helpers as its first argument');
// ->setEngine()
$t->diag('->getEngine()');
$helperSet = new HelperSet(array('foo' => $helper = new SimpleHelper('foo')));
$t->ok($helper->getHelperSet() === $helperSet, '->__construct() changes the embedded helper set of the given helpers');
// ->get() ->set() ->has()
$t->diag('->getHelper() ->setHelper() ->has()');
$helperSet = new HelperSet();
$helperSet->set($helper = new SimpleHelper('bar'));
$t->ok($helper->getHelperSet() === $helperSet, '->set() changes the embedded helper set of the helper');
$t->is((string) $helperSet->get('foo'), 'bar', '->set() sets a helper value');
$t->ok($helperSet->has('foo'), '->has() returns true if the helper is defined');
$t->ok(!$helperSet->has('bar'), '->has() returns false if the helper is not defined');
try {
$helperSet->get('bar');
$t->fail('->get() throws an InvalidArgumentException if the helper is not defined');
} catch (InvalidArgumentException $e) {
$t->pass('->get() throws an InvalidArgumentException if the helper is not defined');
}
示例14: LimeTest
$t = new LimeTest(46);
require_once $fixtures.'/TestCommand.php';
$application = new Application();
// __construct()
$t->diag('__construct()');
try
{
$command = new Command();
$t->fail('__construct() throws a \LogicException if the name is null');
}
catch (\LogicException $e)
{
$t->pass('__construct() throws a \LogicException if the name is null');
}
$command = new Command('foo:bar');
$t->is($command->getFullName(), 'foo:bar', '__construct() takes the command name as its first argument');
// ->setApplication()
$t->diag('->setApplication()');
$command = new TestCommand();
$command->setApplication($application);
$t->is($command->getApplication(), $application, '->setApplication() sets the current application');
// ->setDefinition() ->getDefinition()
$t->diag('->setDefinition() ->getDefinition()');
$ret = $command->setDefinition($definition = new InputDefinition());
$t->is($ret, $command, '->setDefinition() implements a fluent interface');
$t->is($command->getDefinition(), $definition, '->setDefinition() sets the current InputDefinition instance');
示例15: 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\DependencyInjection\Builder;
use Symfony\Components\DependencyInjection\Dumper\Dumper;
$t = new LimeTest(1);
class ProjectDumper extends Dumper
{
}
$builder = new Builder();
$dumper = new ProjectDumper($builder);
try {
$dumper->dump();
$t->fail('->dump() returns a LogicException if the dump() method has not been overriden by a children class');
} catch (LogicException $e) {
$t->pass('->dump() returns a LogicException if the dump() method has not been overriden by a children class');
}