本文整理汇总了PHP中LimeTest::ok方法的典型用法代码示例。如果您正苦于以下问题:PHP LimeTest::ok方法的具体用法?PHP LimeTest::ok怎么用?PHP LimeTest::ok使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LimeTest
的用法示例。
在下文中一共展示了LimeTest::ok方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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\Templating\Storage\Storage;
use Symfony\Components\Templating\Storage\StringStorage;
$t = new LimeTest(2);
$storage = new StringStorage('foo');
$t->ok($storage instanceof Storage, 'StringStorage is an instance of Storage');
// ->getContent()
$t->diag('->getContent()');
$storage = new StringStorage('foo');
$t->is($storage->getContent(), 'foo', '->getContent() returns the content of the template');
示例2: LimeTest
* file that was distributed with this source code.
*/
require_once __DIR__ . '/../../../bootstrap.php';
use Symfony\Components\DependencyInjection\Builder;
use Symfony\Components\DependencyInjection\BuilderConfiguration;
use Symfony\Components\DependencyInjection\Definition;
use Symfony\Components\DependencyInjection\Reference;
$fixturesPath = __DIR__ . '/../../../../fixtures/Symfony/Components/DependencyInjection/';
$t = new LimeTest(61);
// ->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition()
$t->diag('->setDefinitions() ->addDefinitions() ->getDefinitions() ->setDefinition() ->getDefinition() ->hasDefinition()');
$builder = new Builder();
$definitions = array('foo' => new Definition('FooClass'), 'bar' => new Definition('BarClass'));
$builder->setDefinitions($definitions);
$t->is($builder->getDefinitions(), $definitions, '->setDefinitions() sets the service definitions');
$t->ok($builder->hasDefinition('foo'), '->hasDefinition() returns true if a service definition exists');
$t->ok(!$builder->hasDefinition('foobar'), '->hasDefinition() returns false if a service definition does not exist');
$builder->setDefinition('foobar', $foo = new Definition('FooBarClass'));
$t->is($builder->getDefinition('foobar'), $foo, '->getDefinition() returns a service definition if defined');
$t->ok($builder->setDefinition('foobar', $foo = new Definition('FooBarClass')) === $foo, '->setDefinition() implements a fuild interface by returning the service reference');
$builder->addDefinitions($defs = array('foobar' => new Definition('FooBarClass')));
$t->is($builder->getDefinitions(), array_merge($definitions, $defs), '->addDefinitions() adds the service definitions');
try {
$builder->getDefinition('baz');
$t->fail('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
} catch (InvalidArgumentException $e) {
$t->pass('->getDefinition() throws an InvalidArgumentException if the service definition does not exist');
}
// ->register()
$t->diag('->register()');
$builder = new Builder();
示例3: BuilderConfiguration
$t->is($configuration->getParameter('FOO'), 'baz1', '->getParameter() converts the key to lowercase');
try
{
$configuration->getParameter('baba');
$t->fail('->getParameter() throws an \InvalidArgumentException if the key does not exist');
}
catch (\InvalidArgumentException $e)
{
$t->pass('->getParameter() throws an \InvalidArgumentException if the key does not exist');
}
// ->hasParameter()
$t->diag('->hasParameter()');
$configuration = new BuilderConfiguration(array(), array('foo' => 'bar'));
$t->ok($configuration->hasParameter('foo'), '->hasParameter() returns true if a parameter is defined');
$t->ok($configuration->hasParameter('Foo'), '->hasParameter() converts the key to lowercase');
$t->ok(!$configuration->hasParameter('bar'), '->hasParameter() returns false if a parameter is not defined');
// ->addParameters()
$t->diag('->addParameters()');
$configuration = new BuilderConfiguration(array(), array('foo' => 'bar'));
$configuration->addParameters(array('bar' => 'foo'));
$t->is($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'foo'), '->addParameters() adds parameters to the existing ones');
$configuration->addParameters(array('Bar' => 'fooz'));
$t->is($configuration->getParameters(), array('foo' => 'bar', 'bar' => 'fooz'), '->addParameters() converts keys to lowercase');
// ->setAlias() ->getAlias() ->hasAlias() ->getAliases() ->addAliases()
$t->diag('->setAlias() ->getAlias() ->hasAlias()');
$configuration = new BuilderConfiguration();
$configuration->setAlias('bar', 'foo');
示例4: compile
return false;
}
}
class CompilableTemplateLoader extends ProjectTemplateLoaderVar implements CompilableLoaderInterface
{
public function compile($template)
{
return preg_replace('/{{\s*([a-zA-Z0-9_]+)\s*}}/', '<?php echo $$1 ?>', $template);
}
}
// __construct()
$t->diag('__construct()');
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), sys_get_temp_dir());
$t->ok($loader->getLoader() === $varLoader, '__construct() takes a template loader as its first argument');
$t->is($loader->getDir(), sys_get_temp_dir(), '__construct() takes a directory where to store the cache as its second argument');
// ->load()
$t->diag('->load()');
$dir = sys_get_temp_dir().DIRECTORY_SEPARATOR.rand(111111, 999999);
mkdir($dir, 0777, true);
$loader = new ProjectTemplateLoader($varLoader = new ProjectTemplateLoaderVar(), $dir);
$loader->setDebugger($debugger = new ProjectTemplateDebugger());
$t->ok($loader->load('foo') === false, '->load() returns false if the embed loader is not able to load the template');
$loader->load('index');
$t->ok($debugger->hasMessage('Storing template'), '->load() logs a "Storing template" message if the template is found');
$loader->load('index');
$t->ok($debugger->hasMessage('Fetching template'), '->load() logs a "Storing template" message if the template is fetched from cache');
示例5: getTemplatePathPatterns
class ProjectTemplateLoader extends FilesystemLoader
{
public function getTemplatePathPatterns()
{
return $this->templatePathPatterns;
}
static public function isAbsolutePath($path)
{
return parent::isAbsolutePath($path);
}
}
// ->isAbsolutePath()
$t->diag('->isAbsolutePath()');
$t->ok(ProjectTemplateLoader::isAbsolutePath('/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
$t->ok(ProjectTemplateLoader::isAbsolutePath('c:\\\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
$t->ok(ProjectTemplateLoader::isAbsolutePath('c:/foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
$t->ok(ProjectTemplateLoader::isAbsolutePath('\\server\\foo.xml'), '->isAbsolutePath() returns true if the path is an absolute path');
// __construct()
$t->diag('__construct()');
$pathPattern = $fixturesPath.'/templates/%name%.%renderer%';
$path = $fixturesPath.'/templates';
$loader = new ProjectTemplateLoader($pathPattern);
$t->is($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes a path as its second argument');
$loader = new ProjectTemplateLoader(array($pathPattern));
$t->is($loader->getTemplatePathPatterns(), array($pathPattern), '__construct() takes an array of paths as its second argument');
// ->load()
$t->diag('->load()');
示例6: LimeExecutable
$executable = new LimeExecutable(LimeExecutable::php() . ' %file%');
$file = tempnam(sys_get_temp_dir(), 'lime');
$output = $t->mock('LimeOutputInterface');
$input = new LimeInputTap($output);
// @After
$file = null;
$output = null;
$input = null;
// @Test: Successful tests are passed to pass()
// fixtures
$output->pass('A passed test', '', 0, '', '');
$output->replay();
// test
$input->parse("ok 1 - A passed test\n");
// assertions
$t->ok($input->done(), 'The input is done');
// @Test: Successful tests without message are passed to pass()
// fixtures
$output->pass('', '', 0, '', '');
$output->replay();
// test
$input->parse("ok 1\n");
// assertions
$t->ok($input->done(), 'The input is done');
// @Test: Failed tests are passed to fail()
// fixtures
$output->fail('A failed test', '', 0, '', '');
$output->replay();
// test
$input->parse("not ok 1 - A failed test\n");
// assertions
示例7: getName
<?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\Templating\Helper\Helper;
use Symfony\Components\Templating\Helper\HelperSet;
$t = new LimeTest(1);
class ProjectTemplateHelper extends Helper
{
public function getName()
{
return 'foo';
}
}
// ->getHelperSet() ->setHelperSet()
$t->diag('->getHelperSet() ->setHelperSet()');
$helper = new ProjectTemplateHelper();
$helper->setHelperSet($helperSet = new HelperSet(array($helper)));
$t->ok($helperSet === $helper->getHelperSet(), '->setHelperSet() sets the helper set related to this helper');
示例8: catch
$t->is($event->getSubject(), $subject, '->getSubject() returns the event subject');
// ->getName()
$t->diag('->getName()');
$t->is($event->getName(), 'name', '->getName() returns the event name');
// ->getParameters()
$t->diag('->getParameters()');
$t->is($event->getParameters(), $parameters, '->getParameters() returns the event parameters');
// ->getReturnValue() ->setReturnValue()
$t->diag('->getReturnValue() ->setReturnValue()');
$event->setReturnValue('foo');
$t->is($event->getReturnValue(), 'foo', '->getReturnValue() returns the return value of the event');
// ->setProcessed() ->isProcessed()
$t->diag('->setProcessed() ->isProcessed()');
$event->setProcessed(true);
$t->is($event->isProcessed(), true, '->isProcessed() returns true if the event has been processed');
$event->setProcessed(false);
$t->is($event->isProcessed(), false, '->setProcessed() changes the processed status');
// ArrayAccess interface
$t->diag('ArrayAccess interface');
$t->is($event['foo'], 'bar', 'Event implements the ArrayAccess interface');
$event['foo'] = 'foo';
$t->is($event['foo'], 'foo', 'Event implements the ArrayAccess interface');
try {
$event['foobar'];
$t->fail('::offsetGet() throws an \\InvalidArgumentException exception when the parameter does not exist');
} catch (\InvalidArgumentException $e) {
$t->pass('::offsetGet() throws an \\InvalidArgumentException exception when the parameter does not exist');
}
$t->ok(isset($event['foo']), 'Event implements the ArrayAccess interface');
unset($event['foo']);
$t->ok(!isset($event['foo']), 'Event implements the ArrayAccess interface');
示例9: getLoaders
$t = new LimeTest(5);
class ProjectTemplateLoader extends ChainLoader
{
public function getLoaders()
{
return $this->loaders;
}
}
$loader1 = new FilesystemLoader($fixturesPath.'/null/%name%');
$loader2 = new FilesystemLoader($fixturesPath.'/templates/%name%.%renderer%');
// __construct()
$t->diag('__construct()');
$loader = new ProjectTemplateLoader(array($loader1, $loader2));
$t->is($loader->getLoaders(), array($loader1, $loader2), '__construct() takes an array of template loaders as its second argument');
// ->addLoader()
$t->diag('->addLoader()');
$loader = new ProjectTemplateLoader(array($loader1));
$loader->addLoader($loader2);
$t->is($loader->getLoaders(), array($loader1, $loader2), '->addLoader() adds a template loader at the end of the loaders');
// ->load()
$t->diag('->load()');
$loader = new ProjectTemplateLoader(array($loader1, $loader2));
$t->ok($loader->load('bar') === false, '->load() returns false if the template is not found');
$t->ok($loader->load('foo', array('renderer' => 'xml')) === false, '->load() returns false if the template does not exists for the given renderer');
$t->ok($loader->load('foo') instanceof FileStorage, '->load() returns a FileStorage if the template exists');
示例10: Event
// ->getSubject()
$t->diag('->getSubject()');
$t->is($event->getSubject(), $subject, '->getSubject() returns the event subject');
// ->getName()
$t->diag('->getName()');
$t->is($event->getName(), 'name', '->getName() returns the event name');
// ->getParameters() ->setParameter() ->hasParameter() ->getParameter()
$t->diag('->getParameters()');
$t->is($event->getParameters(), $parameters, '->getParameters() returns the event parameters');
$t->is($event->getParameter('foo'), 'bar', '->getParameter() returns the value of a parameter');
$event->setParameter('foo', 'foo');
$t->is($event->getParameter('foo'), 'foo', '->setParameter() changes the value of a parameter');
$t->ok($event->hasParameter('foo'), '->hasParameter() returns true if the parameter is defined');
unset($event['foo']);
$t->ok(!$event->hasParameter('foo'), '->hasParameter() returns false if the parameter is not defined');
try
{
$event->getParameter('foobar');
$t->fail('->getParameter() throws an \InvalidArgumentException exception when the parameter does not exist');
}
catch (\InvalidArgumentException $e)
{
$t->pass('->getParameter() throws an \InvalidArgumentException exception when the parameter does not exist');
}
$event = new Event($subject, 'name', $parameters);
// ->getReturnValue() ->setReturnValue()
示例11: catch
$loader->getFilesAsArray(array('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) {
try {
$loader->getFilesAsArray(array($fixture . '.yml'));
$t->fail('->load() throws an InvalidArgumentException if the loaded file does not validate');
} catch (InvalidArgumentException $e) {
$t->pass('->load() throws an InvalidArgumentException if the loaded file does not validate');
}
}
$yamls = $loader->getFilesAsArray(array('services1.yml'));
$t->ok(is_array($yamls), '->getFilesAsArray() returns an array');
$t->is(key($yamls), realpath($fixturesPath . '/yaml/services1.yml'), '->getFilesAsArray() returns an array where the keys are absolutes paths to the original YAML file');
// ->load() # parameters
$t->diag('->load() # parameters');
$loader = new ProjectLoader($fixturesPath . '/yaml');
$config = $loader->load(array('services2.yml'));
$t->is($config->getParameters(), array('foo' => 'bar', 'values' => array(true, false, 0, 1000.3), 'bar' => 'foo', 'foo_bar' => new Reference('foo_bar')), '->load() converts YAML keys to lowercase');
$loader = new ProjectLoader($fixturesPath . '/yaml');
$config = $loader->load(array('services2.yml', 'services3.yml'));
$t->is($config->getParameters(), array('foo' => 'foo', 'values' => array(true, false), 'bar' => 'foo', 'foo_bar' => new Reference('foo_bar')), '->load() merges the first level of arguments when multiple files are loaded');
// ->load() # imports
$t->diag('->load() # imports');
$config = $loader->load(array('services4.yml'));
$t->is($config->getParameters(), array('foo' => 'bar', 'bar' => '%foo%', 'values' => array(true, false), 'foo_bar' => new Reference('foo_bar')), '->load() imports and merges imported files');
// ->load() # services
$t->diag('->load() # services');
示例12: Option
$t->is($option->isParameterRequired(), true, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode');
$t->is($option->isParameterOptional(), false, '__construct() can take "Option::PARAMETER_REQUIRED" as its mode');
$option = new Option('foo', 'f', Option::PARAMETER_OPTIONAL);
$t->is($option->acceptParameter(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode');
$t->is($option->isParameterRequired(), false, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode');
$t->is($option->isParameterOptional(), true, '__construct() can take "Option::PARAMETER_OPTIONAL" as its mode');
try {
$option = new Option('foo', 'f', 'ANOTHER_ONE');
$t->fail('__construct() throws an Exception if the mode is not valid');
} catch (\Exception $e) {
$t->pass('__construct() throws an Exception if the mode is not valid');
}
// ->isArray()
$t->diag('->isArray()');
$option = new Option('foo', null, Option::PARAMETER_OPTIONAL | Option::PARAMETER_IS_ARRAY);
$t->ok($option->isArray(), '->isArray() returns true if the option can be an array');
$option = new Option('foo', null, Option::PARAMETER_NONE);
$t->ok(!$option->isArray(), '->isArray() returns false if the option can not be an array');
// ->getDescription()
$t->diag('->getDescription()');
$option = new Option('foo', 'f', null, 'Some description');
$t->is($option->getDescription(), 'Some description', '->getDescription() returns the description message');
// ->getDefault()
$t->diag('->getDefault()');
$option = new Option('foo', null, Option::PARAMETER_OPTIONAL, '', 'default');
$t->is($option->getDefault(), 'default', '->getDefault() returns the default value');
$option = new Option('foo', null, Option::PARAMETER_REQUIRED, '', 'default');
$t->is($option->getDefault(), 'default', '->getDefault() returns the default value');
$option = new Option('foo', null, Option::PARAMETER_REQUIRED);
$t->ok(is_null($option->getDefault()), '->getDefault() returns null if no default value is configured');
$option = new Option('foo', null, Option::PARAMETER_OPTIONAL | Option::PARAMETER_IS_ARRAY);
示例13: getEngine
use Symfony\Components\Templating\Engine;
use Symfony\Components\Templating\Renderer\Renderer;
use Symfony\Components\Templating\Storage\Storage;
use Symfony\Components\Templating\Loader\FilesystemLoader;
$t = new LimeTest(1);
class ProjectTemplateRenderer extends Renderer
{
public function getEngine()
{
return $this->engine;
}
public function evaluate(Storage $template, array $parameters = array())
{
}
}
$loader = new FilesystemLoader(array(__DIR__.'/fixtures/templates/%name%.%renderer%'));
$engine = new Engine($loader);
$engine->set('foo', 'bar');
$engine->getHelperSet()->set(new SimpleHelper('foo'), 'bar');
// ->setEngine()
$t->diag('->setEngine()');
$renderer = new ProjectTemplateRenderer();
$renderer->setEngine($engine);
$t->ok($renderer->getEngine() === $engine, '->setEngine() sets the engine instance tied to this renderer');
示例14: LimeTest
use Symfony\Components\CLI\Input\Definition;
use Symfony\Components\CLI\Input\Argument;
use Symfony\Components\CLI\Input\Option;
$t = new LimeTest(15);
// ->getFirstArgument()
$t->diag('->getFirstArgument()');
$input = new ArrayInput(array());
$t->is($input->getFirstArgument(), null, '->getFirstArgument() returns null if no argument were passed');
$input = new ArrayInput(array('name' => 'Fabien'));
$t->is($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument');
$input = new ArrayInput(array('--foo' => 'bar', 'name' => 'Fabien'));
$t->is($input->getFirstArgument(), 'Fabien', '->getFirstArgument() returns the first passed argument');
// ->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');
示例15: getContent
* (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\Templating\Storage\Storage;
use Symfony\Components\Templating\Renderer\PhpRenderer;
$t = new LimeTest(2);
class TestStorage extends Storage
{
public function getContent()
{
}
}
// __construct() __toString()
$t->diag('__construct() __toString()');
$storage = new TestStorage('foo');
$t->is((string) $storage, 'foo', '__toString() returns the template name');
// ->getRenderer()
$t->diag('->getRenderer()');
$storage = new TestStorage('foo', $renderer = new PhpRenderer());
$t->ok($storage->getRenderer() === $renderer, '->getRenderer() returns the renderer');