本文整理汇总了PHP中lime_test::skip方法的典型用法代码示例。如果您正苦于以下问题:PHP lime_test::skip方法的具体用法?PHP lime_test::skip怎么用?PHP lime_test::skip使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类lime_test
的用法示例。
在下文中一共展示了lime_test::skip方法的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: __toString
$dispatcher = $configuration->getEventDispatcher();
$cache = new sfNoCache();
// ->initialize()
$t->diag('->initialize()');
$i18n = new sfI18N($configuration, $cache);
$dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' => 'fr')));
$t->is($i18n->getCulture(), 'fr', '->initialize() connects to the user.change_culture event');
// passing a "culture" option to initialize() should set PHP locale
if (class_exists('Locale') && ($en = Locale::lookup(array('en-US'), 'en-US', true)) && ($fr = Locale::lookup(array('fr-FR'), 'fr-FR', true))) {
$i18n = new sfI18N($configuration, $cache, array('culture' => $fr));
$frLocale = localeconv();
$i18n = new sfI18N($configuration, $cache, array('culture' => $en));
$enLocale = localeconv();
$t->isnt(serialize($frLocale), serialize($enLocale), '->initialize() sets the PHP locale when a "culture" option is provided');
} else {
$t->skip('Locale class or English and French locales are not installed');
}
// ->getCulture() ->setCulture()
$t->diag('->getCulture() ->setCulture()');
$i18n = new sfI18N($configuration, $cache);
$t->is($i18n->getCulture(), 'en', '->getCulture() returns the current culture');
$i18n->setCulture('fr');
$t->is($i18n->getCulture(), 'fr', '->setCulture() sets the current culture');
// ->__()
$t->diag('->__()');
sfConfig::set('sf_charset', 'UTF-8');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->__('an english sentence'), 'une phrase en français', '->__() translates a string');
class EnglishSentence
{
public function __toString()
示例3: dirname
<?php
require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot();
$t = new lime_test(33);
$v = new dmValidatorCssIdAndClasses();
$t->diag('->clean()');
foreach (array('a', 'a_b', 'a-c', 'qieurgfbqoiuzbfvoqiuzZFZGPSOZDNZKFjflzkh986875OoihzyfvbxoquyfvxqozufyxqzUEFV', '9', '_', ' bla rebla ', '- _ 8', '.class', '.a b.c.d', '#myid.a b.c.d', '#myid class1 class2', 'class1 class2 #myid', '.a b#myid.c.d', '.a b#myid.c.d#myid', '.a b#myid.c.d #myid', '#my_id', '#my-id', ' #my-id ') as $classes) {
try {
$t->comment('"' . $classes . '" -> "' . $v->clean($classes) . '"');
$t->pass('->clean() checks that the value is a valid css class name + id');
} catch (sfValidatorError $e) {
$t->fail('->clean() checks that the value is a valid css class name + id');
}
}
foreach (array('.zegze$g.zegf', '/', 'a/f', 'a^', 'a # @', 'é', '-{') as $nonClass) {
$t->comment($nonClass);
try {
$v->clean($nonClass);
$t->fail('->clean() throws an sfValidatorError if the value is not a valid css class name + id');
$t->skip('', 1);
} catch (sfValidatorError $e) {
$t->pass('->clean() throws an sfValidatorError if the value is not a valid css class name + id');
$t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError');
}
}
示例4: sfMemcacheCache
/*
* This file is part of the symfony package.
* (c) 2004-2006 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');
$plan = 73;
$t = new lime_test($plan);
if (!class_exists('Memcache'))
{
$t->skip('Memcache needed to run these tests', $plan);
return;
}
require_once(dirname(__FILE__).'/sfCacheDriverTests.class.php');
// setup
sfConfig::set('sf_logging_enabled', false);
// ->initialize()
$t->diag('->initialize()');
try
{
$cache = new sfMemcacheCache(array('storeCacheInfo' => true));
}
catch (sfInitializationException $e)
示例5: sfPDODatabase
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 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/unit.php';
ob_start();
$plan = 14;
$t = new lime_test($plan);
if (!extension_loaded('SQLite') && !extension_loaded('pdo_SQLite')) {
$t->skip('SQLite needed to run these tests', $plan);
return;
}
// initialize the storage
$database = new sfPDODatabase(array('dsn' => 'sqlite::memory:'));
$connection = $database->getConnection();
$connection->exec('CREATE TABLE session (sess_id, sess_data, sess_time)');
ini_set('session.use_cookies', 0);
$session_id = "1";
$storage = new sfPDOSessionStorage(array('db_table' => 'session', 'session_id' => $session_id, 'database' => $database));
$t->ok($storage instanceof sfStorage, 'sfPDOSessionStorage is an instance of sfStorage');
$t->ok($storage instanceof sfDatabaseSessionStorage, 'sfPDOSessionStorage is an instance of sfDatabaseSessionStorage');
// regenerate()
$oldSessionData = 'foo:bar';
$storage->sessionWrite($session_id, $oldSessionData);
$storage->regenerate(false);
$newSessionData = 'foo:bar:baz';
示例6:
$t->is(truncate_text($text), $truncated, 'text_truncate() adds ... to truncated text');
$text = str_repeat('A', 35);
$truncated = str_repeat('A', 22) . '...';
$t->is(truncate_text($text, 25), $truncated, 'text_truncate() takes the max length as its second argument');
$text = str_repeat('A', 35);
$truncated = str_repeat('A', 21) . 'BBBB';
$t->is(truncate_text($text, 25, 'BBBB'), $truncated, 'text_truncate() takes the ... text as its third argument');
$text = str_repeat('A', 10) . str_repeat(' ', 10) . str_repeat('A', 10);
$truncated_true = str_repeat('A', 10) . '...';
$truncated_false = str_repeat('A', 10) . str_repeat(' ', 2) . '...';
$t->is(truncate_text($text, 15, '...', false), $truncated_false, 'text_truncate() accepts a truncate lastspace boolean as its fourth argument');
$t->is(truncate_text($text, 15, '...', true), $truncated_true, 'text_truncate() accepts a truncate lastspace boolean as its fourth argument');
if (extension_loaded('mbstring')) {
$t->is(truncate_text('P?�li? ?lu?ou?k? k?? �p?l ?�belsk� �dy!', 11), 'P?�li? ?...', 'text_truncate() handles unicode characters using mbstring if available');
} else {
$t->skip('mbstring extension is not enabled');
}
// highlight_text()
$t->diag('highlight_text()');
$t->is(highlight_text("This is a beautiful morning", "beautiful"), "This is a <strong class=\"highlight\">beautiful</strong> morning", 'text_highlighter() highlights a word given as its second argument');
$t->is(highlight_text("This is a beautiful morning, but also a beautiful day", "beautiful"), "This is a <strong class=\"highlight\">beautiful</strong> morning, but also a <strong class=\"highlight\">beautiful</strong> day", 'text_highlighter() highlights all occurrences of a word given as its second argument');
$t->is(highlight_text("This is a beautiful morning, but also a beautiful day", "beautiful", '<b>\\1</b>'), "This is a <b>beautiful</b> morning, but also a <b>beautiful</b> day", 'text_highlighter() takes a pattern as its third argument');
$t->is(highlight_text('', 'beautiful'), '', 'text_highlighter() returns an empty string if input is empty');
$t->is(highlight_text('', ''), '', 'text_highlighter() returns an empty string if input is empty');
$t->is(highlight_text('foobar', 'beautiful'), 'foobar', 'text_highlighter() does nothing is string to highlight is not present');
$t->is(highlight_text('foobar', ''), 'foobar', 'text_highlighter() returns input if string to highlight is not present');
$t->is(highlight_text("This is a beautiful! morning", "beautiful!"), "This is a <strong class=\"highlight\">beautiful!</strong> morning", 'text_highlighter() escapes search string to be safe in a regex');
$t->is(highlight_text("This is a beautiful! morning", "beautiful! morning"), "This is a <strong class=\"highlight\">beautiful! morning</strong>", 'text_highlighter() escapes search string to be safe in a regex');
$t->is(highlight_text("This is a beautiful? morning", "beautiful? morning"), "This is a <strong class=\"highlight\">beautiful? morning</strong>", 'text_highlighter() escapes search string to be safe in a regex');
$t->is(highlight_text("The http://www.google.com/ website is great", "http://www.google.com/"), "The <strong class=\"highlight\">http://www.google.com/</strong> website is great", 'text_highlighter() escapes search string to be safe in a regex');
// excerpt_text()
示例7: sfSQLiteCache
* This file is part of the symfony package.
* (c) 2004-2006 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');
require_once(dirname(__FILE__).'/sfCacheDriverTests.class.php');
$plan = 129;
$t = new lime_test($plan);
if (!extension_loaded('SQLite') && !extension_loaded('pdo_SQLite'))
{
$t->skip('SQLite extension not loaded, skipping tests', $plan);
return;
}
try
{
new sfSQLiteCache(array('database' => ':memory:'));
}
catch (sfInitializationException $e)
{
$t->skip($e->getMessage(), $plan);
return;
}
// ->initialize()
$t->diag('->initialize()');
示例8: get_fixture_content
chdir($this->tmp_dir);
$symfony = file_exists('symfony') ? 'symfony' : dirname(__FILE__) . '/../../data/bin/symfony';
ob_start();
passthru(sprintf('%s "%s" %s 2>&1', $this->php_cli, $symfony, $cmd), $return);
$content = ob_get_clean();
$this->t->cmp_ok($return, '==', $awaited_return, sprintf('"symfony %s" returns awaited value (%d)', $cmd, $awaited_return));
return $content;
}
public function get_fixture_content($file)
{
return str_replace("\r\n", "\n", file_get_contents(dirname(__FILE__) . '/fixtures/' . $file));
}
}
$t = new lime_test(40, new lime_output_color());
if (!extension_loaded('SQLite')) {
$t->skip('You need SQLite to run these tests', $t->plan);
return;
}
$c = new sf_test_project();
$c->initialize($t);
// generate:*
$content = $c->execute_command('generate:project myproject');
$t->ok(file_exists($c->tmp_dir . DS . 'symfony'), '"generate:project" installs the symfony CLI in root project directory');
$content = $c->execute_command('generate:app frontend --escaping-strategy=on');
$t->ok(is_dir($c->tmp_dir . DS . 'apps' . DS . 'frontend'), '"generate:app" creates a "frontend" directory under "apps" directory');
$t->like(file_get_contents($c->tmp_dir . '/apps/frontend/config/settings.yml'), '/escaping_strategy: +true/', '"generate:app" switches escaping_strategy "on"');
$content = $c->execute_command('generate:app backend');
$t->like(file_get_contents($c->tmp_dir . '/apps/backend/config/settings.yml'), '/escaping_strategy: +false/', '"generate:app" switches escaping_strategy "off"');
// failing
$content = $c->execute_command('generate:module wrongapp foo', 1);
$content = $c->execute_command('generate:module frontend foo');
示例9: dirname
<?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 dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(5);
$v1 = new sfValidatorString(array('min_length' => 3));
// __construct()
$t->diag('__construct()');
$v = new sfValidatorSchemaForEach($v1, 3);
$t->is($v->getFields(), array($v1, $v1, $v1), '->__construct() takes a sfValidator object as its first argument');
$v = new sfValidatorSchemaForEach($v1, 6);
$t->is($v->getFields(), array($v1, $v1, $v1, $v1, $v1, $v1), '->__construct() takes a number of times to duplicate the validator');
// ->clean()
$t->diag('->clean()');
try {
$v->clean(array('f', 'a', 'b', 'i', 'e', 'n'));
$t->fail('->clean() throws an sfValidatorError');
$t->skip('', 2);
} catch (sfValidatorError $e) {
$t->pass('->clean() throws an sfValidatorError');
$t->is(count($e->getGlobalErrors()), 0, '->clean() does not throw global errors');
$t->is(count($e->getNamedErrors()), 6, '->clean() throws named errors');
}
示例10: configure
{
protected function configure($options = array(), $attributes = array())
{
$this->addRequiredOption('foo');
}
}
// __construct()
$t->diag('__construct()');
$w = new MyWidget();
$t->is($w->getAttributes(), array(), '->__construct() can take no argument');
$w = new MyWidget(array(), array('class' => 'foo'));
$t->is($w->getAttributes(), array('class' => 'foo'), '->__construct() can take an array of default HTML attributes');
try {
new MyWidget(array('nonexistant' => false));
$t->fail('__construct() throws an InvalidArgumentException if you pass some non existant options');
$t->skip();
} catch (InvalidArgumentException $e) {
$t->pass('__construct() throws an InvalidArgumentException if you pass some non existant options');
$t->like($e->getMessage(), '/ \'nonexistant\'/', 'The exception contains the non existant option names');
}
$t->diag('getRequiredOptions');
$w = new MyWidgetWithRequired(array('foo' => 'bar'));
$t->is($w->getRequiredOptions(), array('foo'), '->getRequiredOptions() returns an array of required option names');
try {
new MyWidgetWithRequired();
$t->fail('__construct() throws an RuntimeException if you don\'t pass a required option');
} catch (RuntimeException $e) {
$t->pass('__construct() throws an RuntimeException if you don\'t pass a required option');
}
$w = new MyWidget();
// ->getOption() ->setOption() ->setOptions() ->getOptions() ->hasOption()
示例11: dirname
<?php
/*
* This file is part of the symfony package.
* (c) 2004-2006 Fabien Potencier <fabien.potencier@symfony-project.com>
* (c) 2008 Dejan Spasic <spasic.dejan@yahoo.de>
*
* 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';
ob_start();
$plan = 12;
$t = new lime_test($plan, new lime_output_color());
if (!extension_loaded('mysqli')) {
$t->skip('Mysqli extension must be loaded', $plan);
return;
}
// Configure your database with the settings below in order to run the test
$mysqli_config = array('host' => 'localhost', 'username' => 'root', 'password' => '');
if (!isset($mysqli_config)) {
$t->skip('Mysql credentials needed to run these tests', $plan);
return;
}
try {
// Creating mysql database connection
$database = new sfMySQLiDatabase($mysqli_config);
$connection = $database->getResource();
} catch (sfDatabaseException $e) {
$t->diag($e->getMessage());
$t->skip('Unable to connect to MySQL database, skipping', $plan);
示例12: __toString
$dispatcher = $configuration->getEventDispatcher();
$cache = new sfNoCache();
// ->initialize()
$t->diag('->initialize()');
$i18n = new sfI18N($configuration, $cache);
$dispatcher->notify(new sfEvent(null, 'user.change_culture', array('culture' => 'fr')));
$t->is($i18n->getCulture(), 'fr', '->initialize() connects to the user.change_culture event');
// passing a "culture" option to initialize() should set PHP locale
if (version_compare(PHP_VERSION, '5.3', '<') && class_exists('Locale') && ($en = Locale::lookup(array('en-US'), 'en-US', true)) && ($fr = Locale::lookup(array('fr-FR'), 'fr-FR', true))) {
$i18n = new sfI18N($configuration, $cache, array('culture' => $fr));
$frLocale = localeconv();
$i18n = new sfI18N($configuration, $cache, array('culture' => $en));
$enLocale = localeconv();
$t->isnt(serialize($frLocale), serialize($enLocale), '->initialize() sets the PHP locale when a "culture" option is provided');
} else {
$t->skip('PHP version > 5.2 or Locale class or English and French locales are not installed');
}
// ->getCulture() ->setCulture()
$t->diag('->getCulture() ->setCulture()');
$i18n = new sfI18N($configuration, $cache);
$t->is($i18n->getCulture(), 'en', '->getCulture() returns the current culture');
$i18n->setCulture('fr');
$t->is($i18n->getCulture(), 'fr', '->setCulture() sets the current culture');
// ->__()
$t->diag('->__()');
sfConfig::set('sf_charset', 'UTF-8');
$i18n = new sfI18N($configuration, $cache, array('culture' => 'fr'));
$t->is($i18n->__('an english sentence'), 'une phrase en français', '->__() translates a string');
class EnglishSentence
{
public function __toString()
示例13: dirname
<?php
require_once dirname(__FILE__).'/../bootstrap/unit.php';
$t = new lime_test(9);
$t->is(Swingmachine::slugify('LindyHop'), 'lindyhop', '::slugify() converts all characters to lower case');
$t->is(Swingmachine::slugify('lindy hop'), 'lindy-hop', '::slugify() replaces a white space by a -');
$t->is(Swingmachine::slugify('lindy hop'), 'lindy-hop', '::slugify() replaces several white spaces by a single -');
$t->is(Swingmachine::slugify('lindy,balboa'), 'lindy-balboa', '::slugify() removes - at the beginning of a string');
$t->is(Swingmachine::slugify(' lindy'), 'lindy', '::slugify() removes - at the end of a string');
$t->is(Swingmachine::slugify('lindy '), 'lindy', '::slugify() replaces non-ASCII characters by a -');
$t->is(Swingmachine::slugify(''), 'n-a', '::slugify() converts the empty string to n-a');
$t->is(Swingmachine::slugify(' - '), 'n-a', '::slugify() converts a string that only contains non-ASCII characters to n-a');
if (function_exists('iconv'))
{
$t->is(Swingmachine::slugify('Cours Réguliers'), 'cours-reguliers', '::slugify() removes accents');
}
else
{
$t->skip('::slugify() removes accents - iconv not installed');
}
示例14: ValidatorIdentity
}
}
// ->configure()
$t->diag('->configure()');
$v = new ValidatorIdentity();
$t->is($v->getOption('foo'), 'bar', '->configure() can add some options');
$v = new ValidatorIdentity(array('foo' => 'foobar'));
$t->is($v->getOption('foo'), 'foobar', '->configure() takes an options array as its first argument and values override default option values');
$v = new ValidatorIdentity();
$t->is($v->getMessage('foo'), 'bar', '->configure() can add some message');
$v = new ValidatorIdentity(array(), array('foo' => 'foobar'));
$t->is($v->getMessage('foo'), 'foobar', '->configure() takes a messages array as its second argument and values override default message values');
try {
new ValidatorIdentity(array('nonexistant' => false, 'foo' => 'foobar', 'anothernonexistant' => 'bar', 'required' => true));
$t->fail('__construct() throws an InvalidArgumentException if you pass some non existant options');
$t->skip();
} catch (InvalidArgumentException $e) {
$t->pass('__construct() throws an InvalidArgumentException if you pass some non existant options');
$t->like($e->getMessage(), '/ \'nonexistant\', \'anothernonexistant\'/', 'The exception contains the non existant option names');
}
try {
new ValidatorIdentity(array(), array('required' => 'This is required.', 'nonexistant' => 'foo', 'anothernonexistant' => false));
$t->fail('__construct() throws an InvalidArgumentException if you pass some non existant error codes');
$t->skip();
} catch (InvalidArgumentException $e) {
$t->pass('__construct() throws an InvalidArgumentException if you pass some non existant error codes');
$t->like($e->getMessage(), '/ \'nonexistant\', \'anothernonexistant\'/', 'The exception contains the non existant error codes');
}
// ->getRequiredOptions()
$t->diag('getRequiredOptions');
$v = new ValidatorIdentityWithRequired(array('foo' => 'bar'));
示例15: die
$id1 = DbFinder::from('DArticle')->where('Title', 'foo')->leftJoin('Category')->withColumn('DCategory.Name')->getUniqueIdentifier();
$id2 = DbFinder::from('DArticle')->where('Title', 'foo')->withColumn('DCategory.Name')->getUniqueIdentifier();
$t->isnt($id1, $id2, 'unique identifier takes joins into account');
$id1 = DbFinder::from('DArticle')->where('Title', 'foo')->where('DCategory.Id', 1)->getUniqueIdentifier();
$id2 = DbFinder::from('DArticle')->where('Title', 'foo')->orWhere('DCategory.Id', 1)->getUniqueIdentifier();
$t->isnt($id1, $id2, 'unique identifier takes logic combinators into account');
$id1 = DbFinder::from('DArticle')->where('Title', 'foo')->where('Id', '=', 1, 'temp')->getUniqueIdentifier();
$id2 = DbFinder::from('DArticle')->where('Title', 'foo')->getUniqueIdentifier();
$t->is($id1, $id2, 'unique identifier does not take uncombined conditions into account');
if (Doctrine::VERSION == '0.11.0')
{
$t->skip('Query cache does not work with Doctrine 0.11', 13);
die();
}
$cache = new Doctrine_Cache_Apc();
$t->diag('useCache()');
// Simple queries
apc_clear_cache('user');
$finder = DbFinder::from('DArticle')->where('Title', 'foo')->useCache($cache, 10);
$finder->findOne();
$SQL1 = $finder->getLatestQuery(); // SELECT * FROM article WHERE article.title = 'foo' LIMIT 1
$finder = DbFinder::from('DArticle')->where('Title', 'bar')->useCache($cache, 10);