本文整理汇总了PHP中lime_test::pass方法的典型用法代码示例。如果您正苦于以下问题:PHP lime_test::pass方法的具体用法?PHP lime_test::pass怎么用?PHP lime_test::pass使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lime_test
的用法示例。
在下文中一共展示了lime_test::pass方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: fail
/**
* Tests that this input fails
*
* @param string $input
* @param string $message
*/
public function fail($input, $message = null, $encoding = 'utf-8')
{
$this->lime->diag($input);
try {
$this->lexer->tokenize($input, $encoding);
$this->lime->fail('exception not thrown');
if ($message) {
$this->lime->skip('');
}
} catch (Exception $e) {
$this->lime->pass('exception caught: ' . $e->getMessage());
if ($message) {
$this->lime->is($e->getMessage(), $message, 'exception message matches');
}
}
}
示例2: _createTmpGitRepo
/**
*
* @param lime_test $t
* @return PHPGit_Repository the git repo
*/
function _createTmpGitRepo(lime_test $t, array $options = array())
{
$repoDir = sys_get_temp_dir() . '/php-git-repo/' . uniqid();
$t->ok(!is_dir($repoDir . '/.git'), $repoDir . ' is not a Git repo');
try {
new PHPGit_Repository($repoDir, true, $options);
$t->fail($repoDir . ' is not a valid git repository');
} catch (InvalidArgumentException $e) {
$t->pass($repoDir . ' is not a valid git repository');
}
$t->comment('Create Git repo');
exec('git init ' . escapeshellarg($repoDir));
$t->ok(is_dir($repoDir . '/.git'), $repoDir . ' is a Git repo');
$repo = new PHPGit_Repository($repoDir, true, $options);
$t->isa_ok($repo, 'PHPGit_Repository', $repoDir . ' is a valid git repo');
$originalRepoDir = dirname(__FILE__) . '/repo';
foreach (array('README.markdown', 'index.php') as $file) {
copy($originalRepoDir . '/' . $file, $repoDir . '/' . $file);
}
return $repo;
}
示例3: php_html_writer_run_tests
function php_html_writer_run_tests(lime_test $t, array $tests, $callable)
{
foreach ($tests as $test) {
$parameters = $test['params'];
$expectedResult = isset($test['result']) ? $test['result'] : null;
try {
$result = call_user_func_array($callable, $parameters);
if (isset($test['throws'])) {
$t->fail($parameters[0] . ' throws a ' . $test['throws']);
} else {
$t->is_deeply($result, $expectedResult, '"' . str_replace('"', '\'', $parameters[0]) . '" ' . str_replace("\n", '', var_export($expectedResult, true)));
}
} catch (Exception $exception) {
$exceptionClass = get_class($exception);
$message = sprintf('"%s" throws a %s: %s', isset($parameters[0]) ? str_replace('"', '\'', (string) $parameters[0]) : 'NULL', $exceptionClass, $exception->getMessage());
if (isset($test['throws']) && $test['throws'] == $exceptionClass) {
$t->pass($message);
} else {
$t->fail($message);
}
}
}
}
示例4: dirname
<?php
require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
clearstatcache(true);
$isSqlite = Doctrine_Manager::getInstance()->getConnection('doctrine') instanceof Doctrine_Connection_Sqlite;
$t = new lime_test(16 + ($isSqlite ? 0 : 1) + 3 * count($helper->get('i18n')->getCultures()));
$user = $helper->get('user');
try {
$index = $helper->get('search_index');
$t->fail('Can\'t create index without dir');
} catch (dmSearchIndexException $e) {
$t->pass('Can\'t create index without dir');
}
$engine = $helper->get('search_engine');
$t->isa_ok($engine, 'dmSearchEngine', 'Got a dmSearchEngine instance');
$expected = dmProject::rootify(dmArray::get($helper->get('service_container')->getParameter('search_engine.options'), 'dir'));
$t->is($engine->getFullPath(), $expected, 'Current engine full path is ' . $expected);
$t->ok(!file_exists(dmProject::rootify('segments.gen')), 'There is no segments.gen in project root dir');
$engine->setDir('cache/testIndex');
foreach ($helper->get('i18n')->getCultures() as $culture) {
$user->setCulture($culture);
$currentIndex = $engine->getCurrentIndex();
$t->is($currentIndex->getName(), 'dm_page_' . $culture, 'Current index name is ' . $currentIndex->getName());
$t->is($currentIndex->getCulture(), $culture, 'Current index culture is ' . $culture);
$t->is($currentIndex->getFullPath(), dmProject::rootify('cache/testIndex/' . $currentIndex->getName()), 'Current index full path is ' . $currentIndex->getFullPath());
}
$user->setCulture(sfConfig::get('sf_default_culture'));
$currentIndex = $engine->getCurrentIndex();
$t->isa_ok($currentIndex->getLuceneIndex(), 'Zend_Search_Lucene_Proxy', 'The current index is instanceof Zend_Search_Lucene_Proxy');
示例5: sfValidatorString
$v1 = new sfValidatorString(array('max_length' => 3));
$v2 = new sfValidatorString(array('min_length' => 3));
$v = new sfValidatorOr(array($v1, $v2));
// __construct()
$t->diag('__construct()');
$v = new sfValidatorOr();
$t->is($v->getValidators(), array(), '->__construct() can take no argument');
$v = new sfValidatorOr($v1);
$t->is($v->getValidators(), array($v1), '->__construct() can take a validator as its first argument');
$v = new sfValidatorOr(array($v1, $v2));
$t->is($v->getValidators(), array($v1, $v2), '->__construct() can take an array of validators as its first argument');
try {
$v = new sfValidatorOr('string');
$t->fail('_construct() throws an exception when passing a non supported first argument');
} catch (InvalidArgumentException $e) {
$t->pass('_construct() throws an exception when passing a non supported first argument');
}
// ->addValidator()
$t->diag('->addValidator()');
$v = new sfValidatorOr();
$v->addValidator($v1);
$v->addValidator($v2);
$t->is($v->getValidators(), array($v1, $v2), '->addValidator() adds a validator');
// ->clean()
$t->diag('->clean()');
$t->is($v->clean('foo'), 'foo', '->clean() returns the string unmodified');
try {
$v->setOption('required', true);
$v->clean(null);
$t->fail('->clean() throws an sfValidatorError exception if the input value is required');
$t->skip('', 1);
示例6: dirname
*/
require_once dirname(__FILE__) . '/../lib/lime/lime.php';
require_once dirname(__FILE__) . '/../../lib/sfServiceContainerAutoloader.php';
sfServiceContainerAutoloader::register();
require_once dirname(__FILE__) . '/../lib/yaml/sfYaml.php';
$t = new lime_test(4);
$dir = dirname(__FILE__) . '/fixtures/yaml';
// ->dump()
$t->diag('->dump()');
$dumper = new sfServiceContainerDumperYaml($container = new sfServiceContainerBuilder());
$t->is($dumper->dump(), file_get_contents($dir . '/services1.yml'), '->dump() dumps an empty container as an empty YAML file');
$container = new sfServiceContainerBuilder();
$dumper = new sfServiceContainerDumperYaml($container);
// ->addParameters()
$t->diag('->addParameters()');
$container = (include dirname(__FILE__) . '/fixtures/containers/container8.php');
$dumper = new sfServiceContainerDumperYaml($container);
$t->is($dumper->dump(), file_get_contents($dir . '/services8.yml'), '->dump() dumps parameters');
// ->addService()
$t->diag('->addService()');
$container = (include dirname(__FILE__) . '/fixtures/containers/container9.php');
$dumper = new sfServiceContainerDumperYaml($container);
$t->is($dumper->dump(), str_replace('%path%', dirname(__FILE__) . '/fixtures/includes', file_get_contents($dir . '/services9.yml')), '->dump() dumps services');
$dumper = new sfServiceContainerDumperYaml($container = new sfServiceContainerBuilder());
$container->register('foo', 'FooClass')->addArgument(new stdClass());
try {
$dumper->dump();
$t->fail('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
} catch (RuntimeException $e) {
$t->pass('->dump() throws a RuntimeException if the container to be dumped has reference to objects or resources');
}
示例7: dirname
<?php
require_once dirname(__FILE__) . '/vendor/lime.php';
require_once dirname(__FILE__) . '/../lib/phpHtmlWriter.php';
require_once dirname(__FILE__) . '/phpHtmlWriterTestHelper.php';
$t = new lime_test(3);
$view = new phpHtmlWriter();
$nbTests = 500;
$nbTags = 10;
$t->is($view->tag('div'), '<div></div>', 'Writer is ready');
$startTime = microtime(true);
for ($iterator = 0; $iterator < $nbTests; ++$iterator) {
$view->tag('div#my_id' . $iterator, $view->tag('ul.my_class' . $iterator, $view->tag('li.li_class', 'some content ' . $iterator) . $view->tag('li.li_class', $view->tag('input value="my value ' . $iterator . '"')) . $view->tag('li', array('id' => 'my_id'), $view->tag('p', array('lang' => 'fr'), 'du contenu'))) . $view->open('div') . 'some text' . $view->tag('br') . $view->close('div'));
}
$time = 1000 * (microtime(true) - $startTime);
$t->pass(sprintf('Time to render %d nested tags: %0.2f milliseconds', $nbTests * $nbTags, $time));
$t->pass(sprintf('Time per tag: %0.3f milliseconds', $time / ($nbTests * $nbTags)));
示例8: dirname
require_once dirname(__FILE__) . '/../bootstrap.php';
use Bundle\sfFormBundle\Validator\SchemaFilter;
use Bundle\sfFormBundle\Validator\String;
use Bundle\sfFormBundle\Validator\Error;
use Bundle\sfFormBundle\Validator\ErrorSchema;
$t = new lime_test(6);
$v1 = new String(array('min_length' => 2, 'trim' => true));
$v = new SchemaFilter('first_name', $v1);
// ->clean()
$t->diag('->clean()');
$t->is($v->clean(array('first_name' => ' foo ')), array('first_name' => 'foo'), '->clean() executes the embedded validator');
try {
$v->clean('string');
$t->fail('->clean() throws a \\InvalidArgumentException if the input value is not an array');
} catch (\InvalidArgumentException $e) {
$t->pass('->clean() throws a \\InvalidArgumentException if the input value is not an array');
}
try {
$v->clean(null);
$t->fail('->clean() throws a Error if the embedded validator failed');
$t->skip('', 1);
} catch (Error $e) {
$t->pass('->clean() throws a Error if the embedded validator failed');
$t->is($e->getCode(), 'first_name [required]', '->clean() throws a Error');
}
try {
$v->clean(array('first_name' => 'f'));
$t->fail('->clean() throws a Error if the embedded validator failed');
$t->skip('', 1);
} catch (Error $e) {
$t->pass('->clean() throws a Error if the embedded validator failed');
示例9: dirname
<?php
require_once dirname(__FILE__) . '/../../vendor/lime/lime.php';
require_once dirname(__FILE__) . '/../../lib/TwitterBot.class.php';
$t = new lime_test(12, new lime_output_color());
// Sample data
$xmlTweet = DOMDocument::load(dirname(__FILE__) . '/xml/server/statuses/show/2043091669.xml');
// createFromXml()
$t->diag('createFromXML()');
try {
$tweet = Tweet::createFromXML($xmlTweet);
$t->pass('createFromXml() creates a Tweet instance from an XML element without throwing an exception');
} catch (Exception $e) {
$t->fail('createFromXml() creates a Tweet instance from an XML element without throwing an exception');
$t->diag(sprintf(' %s: %s', get_class($e), $e->getMessage()));
}
$t->isa_ok($tweet, 'Tweet', 'createFromXML() creates a Tweet instance');
$t->is($tweet->created_at, 'Fri Jun 05 14:21:23 +0000 2009', 'createFromXML() can retrieve created_at property');
$t->is($tweet->id, 2043091669, 'createFromXML() can retrieve id property');
$t->is($tweet->text, 'foo', 'createFromXML() can retrieve text property');
$t->is($tweet->source, '<a href="http://www.nambu.com">Nambu</a>', 'createFromXML() can retrieve source property');
$t->is($tweet->truncated, false, 'createFromXML() can retrieve truncated property');
$t->is($tweet->in_reply_to_status_id, 2043033723, 'createFromXML() can retrieve in_reply_to_status_id property');
$t->is($tweet->in_reply_to_user_id, 14587759, 'createFromXML() can retrieve in_reply_to_user_id property');
$t->is($tweet->favorited, false, 'createFromXML() can retrieve favorited property');
$t->is($tweet->in_reply_to_screen_name, 'fvsch', 'createFromXML() can retrieve in_reply_to_screen_name property');
$t->isa_ok($tweet->user, 'TwitterUser', 'createFromXML() imports TwitterUser');
示例10: array
$number = 12;
$error = null;
$t->ok($v->execute($number, $error), '->execute() returns true if you don\'t define any parameter');
foreach (array('not a number', '0xFE') as $number) {
$error = null;
$t->ok(!$v->execute($number, $error), '->execute() returns "nan_error" if value is not a number');
$t->is($error, 'Input is not a number', '->execute() changes "$error" with a default message if it returns false');
}
foreach (array('any', 'decimal', 'float', 'int', 'integer') as $type) {
$t->ok($v->initialize($context, array('type' => $type)), sprintf('->execute() can take "%s" as a type argument', $type));
}
try {
$v->initialize($context, array('type' => 'another type'));
$t->fail('->initialize() throws an sfValidatorException if "type" is invalid');
} catch (sfValidatorException $e) {
$t->pass('->initialize() throws an sfValidatorException if "type" is invalid');
}
$h = new sfValidatorTestHelper($context, $t);
// min
$t->diag('->execute() - min parameter');
$h->launchTests($v, 6, true, 'min', null, array('min' => 5));
$h->launchTests($v, 5, true, 'min', null, array('min' => 5));
$h->launchTests($v, 4, false, 'min', 'min_error', array('min' => 5));
// max
$t->diag('->execute() - max parameter');
$h->launchTests($v, 4, true, 'max', null, array('max' => 5));
$h->launchTests($v, 5, true, 'max', null, array('max' => 5));
$h->launchTests($v, 6, false, 'max', 'max_error', array('max' => 5));
// type is integer
$t->diag('->execute() - type is integer');
$h->launchTests($v, 4, true, 'type', null, array('type' => 'integer'));
示例11: FormTest
$w3->setParent($schema);
$t->ok($f->getWidget('name') == $w3, '->setWidget() sets a widget for a field');
// ArrayAccess interface
$t->diag('ArrayAccess interface');
$f = new FormTest();
$f->setWidgetSchema(new sfWidgetFormSchema(array('first_name' => new sfWidgetFormInputText(array('default' => 'Fabien')), 'last_name' => new sfWidgetFormInputText(), 'image' => new sfWidgetFormInputFile())));
$f->setValidatorSchema(new sfValidatorSchema(array('first_name' => new sfValidatorPass(), 'last_name' => new sfValidatorPass(), 'image' => new sfValidatorPass())));
$f->setDefaults(array('image' => 'default.gif'));
$f->embedForm('embedded', new sfForm());
$t->ok($f['first_name'] instanceof sfFormField, '"sfForm" implements the ArrayAccess interface');
$t->is($f['first_name']->render(), '<input type="text" name="first_name" value="Fabien" id="first_name" />', '"sfForm" implements the ArrayAccess interface');
try {
$f['image'] = 'image';
$t->fail('"sfForm" ArrayAccess implementation does not permit to set a form field');
} catch (LogicException $e) {
$t->pass('"sfForm" ArrayAccess implementation does not permit to set a form field');
}
$t->ok(isset($f['image']), '"sfForm" implements the ArrayAccess interface');
unset($f['image']);
$t->ok(!isset($f['image']), '"sfForm" implements the ArrayAccess interface');
$t->ok(!array_key_exists('image', $f->getDefaults()), '"sfForm" ArrayAccess implementation removes form defaults');
$v = $f->getValidatorSchema();
$t->ok(!isset($v['image']), '"sfForm" ArrayAccess implementation removes the widget and the validator');
$w = $f->getWidgetSchema();
$t->ok(!isset($w['image']), '"sfForm" ArrayAccess implementation removes the widget and the validator');
try {
$f['nonexistant'];
$t->fail('"sfForm" ArrayAccess implementation throws a LogicException if the form field does not exist');
} catch (LogicException $e) {
$t->pass('"sfForm" ArrayAccess implementation throws a LogicException if the form field does not exist');
}
示例12: dirname
/*
* 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 dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(5);
// __construct()
$t->diag('__construct()');
try {
new sfValidatorCSRFToken();
$t->fail('__construct() throws an RuntimeException if you don\'t pass a token option');
} catch (RuntimeException $e) {
$t->pass('__construct() throws an RuntimeException if you don\'t pass a token option');
}
$v = new sfValidatorCSRFToken(array('token' => 'symfony'));
// ->clean()
$t->diag('->clean()');
$t->is($v->clean('symfony'), 'symfony', '->clean() checks that the token is valid');
try {
$v->clean('another');
$t->fail('->clean() throws an sfValidatorError if the token is not valid');
$t->skip('', 1);
} catch (sfValidatorError $e) {
$t->pass('->clean() throws an sfValidatorError if the token is not valid');
$t->is($e->getCode(), 'csrf_attack', '->clean() throws a sfValidatorError');
}
// ->asString()
$t->diag('->asString()');
示例13: trim
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 (InvalidArgumentException $e) {
$t->pass('YAML files must not contain tabs');
}
}
$yaml = <<<EOF
--- %YAML:1.0
foo
...
EOF;
$t->is('foo', $parser->parse($yaml));
// objects
$t->diag('Objects support');
class A
{
public $a = 'foo';
}
$a = array('foo' => new A(), 'bar' => 1);
示例14: sfCommandOption
$t->is($option->acceptParameter(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode');
$t->is($option->isParameterRequired(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode');
$t->is($option->isParameterOptional(), false, '__construct() can take "sfCommandOption::PARAMETER_NONE" as its mode');
$option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_REQUIRED);
$t->is($option->acceptParameter(), true, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode');
$t->is($option->isParameterRequired(), true, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode');
$t->is($option->isParameterOptional(), false, '__construct() can take "sfCommandOption::PARAMETER_REQUIRED" as its mode');
$option = new sfCommandOption('foo', 'f', sfCommandOption::PARAMETER_OPTIONAL);
$t->is($option->acceptParameter(), true, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode');
$t->is($option->isParameterRequired(), false, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode');
$t->is($option->isParameterOptional(), true, '__construct() can take "sfCommandOption::PARAMETER_OPTIONAL" as its mode');
try {
$option = new sfCommandOption('foo', 'f', 'ANOTHER_ONE');
$t->fail('__construct() throws an sfCommandException if the mode is not valid');
} catch (sfCommandException $e) {
$t->pass('__construct() throws an sfCommandException if the mode is not valid');
}
// ->isArray()
$t->diag('->isArray()');
$option = new sfCommandOption('foo', null, sfCommandOption::IS_ARRAY);
$t->ok($option->isArray(), '->isArray() returns true if the option can be an array');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE | sfCommandOption::IS_ARRAY);
$t->ok($option->isArray(), '->isArray() returns true if the option can be an array');
$option = new sfCommandOption('foo', null, sfCommandOption::PARAMETER_NONE);
$t->ok(!$option->isArray(), '->isArray() returns false if the option can not be an array');
// ->getHelp()
$t->diag('->getHelp()');
$option = new sfCommandOption('foo', 'f', null, 'Some help');
$t->is($option->getHelp(), 'Some help', '->getHelp() returns the help message');
// ->getDefault()
$t->diag('->getDefault()');
示例15: setup
{
public function setup()
{
$this->enablePlugins(array('sfAutoloadPlugin', 'sfConfigPlugin'));
$this->setPluginPath('sfConfigPlugin', $this->rootDir . '/lib/plugins/sfConfigPlugin');
}
}
$configuration = new ProjectConfiguration(__DIR__ . '/../../functional/fixtures');
// ->setPlugins() ->disablePlugins() ->enablePlugins() ->enableAllPluginsExcept()
$t->diag('->setPlugins() ->disablePlugins() ->enablePlugins() ->enableAllPluginsExcept()');
foreach (array('setPlugins', 'disablePlugins', 'enablePlugins', 'enableAllPluginsExcept') as $method) {
try {
$configuration->{$method}(array());
$t->fail('->' . $method . '() throws an exception if called too late');
} catch (Exception $e) {
$t->pass('->' . $method . '() throws an exception if called too late');
}
}
class ProjectConfiguration2 extends sfProjectConfiguration
{
public function setup()
{
$this->enablePlugins('sfAutoloadPlugin', 'sfConfigPlugin');
}
}
$configuration = new ProjectConfiguration2(__DIR__ . '/../../functional/fixtures');
$t->is_deeply($configuration->getPlugins(), array('sfAutoloadPlugin', 'sfConfigPlugin'), '->enablePlugins() can enable plugins passed as arguments instead of array');
// ->__construct()
$t->diag('->__construct()');
class ProjectConfiguration3 extends sfProjectConfiguration
{