本文整理汇总了PHP中lime_test类的典型用法代码示例。如果您正苦于以下问题:PHP lime_test类的具体用法?PHP lime_test怎么用?PHP lime_test使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了lime_test类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: check_test_tree
function check_test_tree(lime_test $t, ioMenuItem $menu)
{
$t->info('### Running checks on the integrity of the test tree.');
$t->is(count($menu), 2, 'count(rt) returns 2 children');
$t->is(count($menu['Parent 1']), 3, 'count(pt1) returns 3 children');
$t->is(count($menu['Parent 2']), 1, 'count(pt2) returns 1 child');
$t->is(count($menu['Parent 2']['Child 4']), 1, 'count(ch4) returns 1 child');
$t->is_deeply($menu['Parent 2']['Child 4']['Grandchild 1']->getName(), 'Grandchild 1', 'gc1 has the name "Grandchild 1"');
}
示例2: 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);
}
}
}
}
示例3: checkEachFolder
protected function checkEachFolder(lime_test $t)
{
$errors = 0;
if (!($root = $this->folderTable->getTree()->fetchRoot())) {
$t->diag('Tree has no root !');
$errors++;
} elseif ($root->relPath != '') {
$t->diag(sprintf('Root relPath != "" (%s)', $root->relPath));
$errors++;
} elseif ($root->getNodeParentId() !== null) {
$t->diag(sprintf('Root->getNodeParentId() = %d', $root->getNodeParentId()));
$errors++;
}
$folders = $this->folderTable->findAll();
foreach ($folders as $folder) {
$folder->refresh();
if ($folder->getNode()->isRoot()) {
continue;
}
if (!($parent = $folder->getNode()->getParent())) {
$t->diag(sprintf('$folder->getNode()->getParent() == NULL (folder : %s)', $folder));
$errors++;
} elseif ($parent->id != $folder->getNodeParentId()) {
$t->diag(sprintf('$folder->getNode()->getParent()->id != $folder->getNodeParentId() (%d, %d) (folder : %s)', $folder->getNode()->getParent()->id, $folder->getNodeParentId(), $folder));
$errors++;
if ($parent->lft >= $folder->lft || $parent->rgt <= $folder->rgt) {
$t->diag(sprintf('bad folder / parent lft|rgt (folder %d : %d, %d) (parent %d : %d, %d)', $folder->id, $folder->lft, $folder->rgt, $parent->id, $parent->lft, $parent->rgt));
$errors++;
}
}
if ($folder->lft >= $folder->rgt) {
$t->diag(sprintf('$folder->lft >= $folder->rgt (%d, %d) (folder : %s)', $folder->lft, $folder->rgt, $folder));
$errors++;
}
if (!$folder->lft || !$folder->rgt) {
$t->diag(sprintf('!$folder->lft || !$folder->rgt (%d, %d) (folder : %s)', $folder->lft, $folder->rgt, $folder));
$errors++;
}
}
$t->is($errors, 0, "All folders are sane ({$errors} errors)");
}
示例4: _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;
}
示例5: dirname
<?php
include dirname(__FILE__) . '/../../bootstrap/unit.php';
include dirname(__FILE__) . '/../../bootstrap/database.php';
sfContext::createInstance($configuration);
$t = new lime_test(1, new lime_output_color());
$conn = Doctrine::getTable('ApplicationInvite')->getConnection();
$conn->beginTransaction();
$invite = Doctrine::getTable('ApplicationInvite')->find(1);
$memberApplication = $invite->accept();
$t->isa_ok($memberApplication, 'MemberApplication', '->accept() returns object of MemberApplication');
$conn->rollback();
示例6: error_reporting
<?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.
*/
error_reporting(error_reporting() & ~E_STRICT);
require_once __DIR__ . '/../../bootstrap/unit.php';
$t = new lime_test(5);
@(include_once 'PEAR.php');
if (!class_exists('PEAR')) {
$t->skip('PEAR must be installed', 5);
return;
}
require_once __DIR__ . '/sfPearDownloaderTest.class.php';
require_once __DIR__ . '/sfPearRestTest.class.php';
require_once __DIR__ . '/sfPluginTestHelper.class.php';
// setup
$temp = tempnam('/tmp/sf_plugin_test', 'tmp');
unlink($temp);
mkdir($temp, 0777, true);
define('SF_PLUGIN_TEST_DIR', $temp);
$options = array('plugin_dir' => $temp . '/plugins', 'cache_dir' => $temp . '/cache', 'preferred_state' => 'stable', 'rest_base_class' => 'sfPearRestTest', 'downloader_base_class' => 'sfPearDownloaderTest');
$dispatcher = new sfEventDispatcher();
$environment = new sfPearEnvironment($dispatcher, $options);
$environment->registerChannel('pear.example.com', true);
$rest = $environment->getRest();
// ->getPluginVersions()
示例7: dirname
<?php
require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
$t = new lime_test();
$pageHelper = $helper->get('page_helper');
$t->is($pageHelper->getOption('widget_css_class_pattern'), dmArray::get($helper->get('service_container')->getParameter('page_helper.options'), 'widget_css_class_pattern'), 'widget_css_class_pattern : ' . $pageHelper->getOption('widget_css_class_pattern'));
$widget = array('id' => 9999, 'module' => 'dmWidgetContent', 'action' => 'breadCrumb', 'value' => json_encode(array('text' => 'test title', 'tag' => 'h1')), 'css_class' => 'custom_class');
$pageHelper->setOption('widget_css_class_pattern', '');
$expected = array('dm_widget custom_class', 'dm_widget_inner');
$t->is($pageHelper->getWidgetContainerClasses($widget), $expected, 'widgetContainerClasses for breadCrumb : ' . implode(', ', $expected));
$widget['action'] = 'title';
$expected = array('dm_widget custom_class', 'dm_widget_inner');
$t->is($pageHelper->getWidgetContainerClasses($widget), $expected, 'widgetContainerClasses for title : ' . implode(', ', $expected));
$pageHelper->setOption('widget_css_class_pattern', '%module%_%action%');
$expected = array('dm_widget content_title custom_class', 'dm_widget_inner');
$t->is($pageHelper->getWidgetContainerClasses($widget), $expected, 'widgetContainerClasses for title : ' . implode(', ', $expected));
$pageHelper->setOption('widget_css_class_pattern', 'module_%module% action_%action%');
$expected = array('dm_widget module_content action_title custom_class', 'dm_widget_inner');
$t->is($pageHelper->getWidgetContainerClasses($widget), $expected, 'widgetContainerClasses for title : ' . implode(', ', $expected));
示例8: 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(1, new lime_output_color());
$dom = new DomDocument('1.0', 'utf-8');
$dom->validateOnParse = true;
// ->configure()
$t->diag('->configure()');
$w = new sfWidgetFormI18nDateTime(array('culture' => 'fr'));
$t->is($w->getOption('format'), '%date% %time%', '->configure() automatically changes the date format for the given culture');
示例9: dirname
<?php
require_once dirname(__FILE__) . '/../../../../../test/bootstrap/unit.php';
$t = new lime_test(23);
$serviceContainer->pluginLoader->loadPlugins(array('nbVisualStudioPlugin'));
$t->comment('nbVisualStudioClientTest - Test default compiler line for LIB DEBUG project');
$client = new nbVisualStudioClient('outputFile');
$t->is($client->getCompilerCmdLine(), 'cl /c /nologo /EHsc /Gd /TP /Od /RTC1 /MDd /DUNICODE /D_UNICODE /DWIN32 /D_DEBUG', '->getCompilerCmdLine() has all default flags for LIB + DEBUG configuration');
$t->is($client->getLinkerCmdLine(), 'lib /nologo /OUT:outputFile obj/Debug/*.obj', '->getLinkerCmdLine() has all default flags for LIB + DEBUG configuration');
$t->comment('nbVisualStudioClientTest - Test default compiler line for LIB RELEASE project');
$client = new nbVisualStudioClient('outputFile', nbVisualStudioClient::LIB, nbVisualStudioClient::RELEASE);
$t->is($client->getCompilerCmdLine(), 'cl /c /nologo /EHsc /Gd /TP /O2 /Oi /GL /MD /Gy /DUNICODE /D_UNICODE /DWIN32 /DNDEBUG', '->getCompilerCmdLine() has all default flags for LIB + RELEASE configuration');
$t->is($client->getLinkerCmdLine(), 'lib /nologo /OUT:outputFile obj/Release/*.obj', '->getLinkerCmdLine() has all default flags for LIB + RELEASE configuration');
$t->comment('nbVisualStudioClientTest - Test default compiler line for APP DEBUG project');
$client = new nbVisualStudioClient('outputFile', nbVisualStudioClient::APP);
$t->is($client->getCompilerCmdLine(), 'cl /c /nologo /EHsc /Gd /TP /Od /RTC1 /MDd /DUNICODE /D_UNICODE /DWIN32 /D_DEBUG', '->getCompilerCmdLine() has all default flags for APP + DEBUG configuration');
$t->is($client->getLinkerCmdLine(), 'link /nologo /OUT:outputFile obj/Debug/*.obj', '->getLinkerCmdLine() has all default flags for APP + DEBUG configuration');
$t->comment('nbVisualStudioClientTest - Test default compiler line for APP RELEASE project');
$client = new nbVisualStudioClient('outputFile', nbVisualStudioClient::APP, nbVisualStudioClient::RELEASE);
$t->is($client->getCompilerCmdLine(), 'cl /c /nologo /EHsc /Gd /TP /O2 /Oi /GL /MD /Gy /DUNICODE /D_UNICODE /DWIN32 /DNDEBUG', '->getCompilerCmdLine() has all default flags for APP + RELEASE configuration');
$t->is($client->getLinkerCmdLine(), 'link /nologo /OUT:outputFile obj/Release/*.obj', '->getLinkerCmdLine() has all default flags for APP + RELEASE configuration');
$t->comment('nbVisualStudioClientTest - Test set additional defines to compiler');
$client = new nbVisualStudioClient('outputFile', nbVisualStudioClient::APP);
$client->setProjectDefines(array('CUSTOM'));
$t->is($client->getCompilerCmdLine(), 'cl /c /nologo /EHsc /Gd /TP /Od /RTC1 /MDd /DUNICODE /D_UNICODE /DWIN32 /D_DEBUG /DCUSTOM', '->setProjectDefines() sets one additional define to compiler command line');
$client->setProjectDefines(array('CUSTOM1', 'CUSTOM2'));
$t->is($client->getCompilerCmdLine(), 'cl /c /nologo /EHsc /Gd /TP /Od /RTC1 /MDd /DUNICODE /D_UNICODE /DWIN32 /D_DEBUG /DCUSTOM1 /DCUSTOM2', '->setProjectDefines() sets all additional defines to compiler command line');
$t->comment('nbVisualStudioClientTest - Test set additional includes to compiler');
$client = new nbVisualStudioClient('outputFile');
$client->setProjectIncludes(array('include1'));
$t->is($client->getCompilerCmdLine(), 'cl /c /nologo /EHsc /Gd /TP /Od /RTC1 /MDd /DUNICODE /D_UNICODE /DWIN32 /D_DEBUG /I"include1"', '->setProjectIncludes() sets one additional include to compiler command line');
示例10: to_xml
public function to_xml()
{
return lime_test::to_xml($this->to_array());
}
示例11: dirname
<?php
/**
* This file is part of the sfSearch package.
* (c) Carl Vondrick <carl.vondrick@symfony-project.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
require dirname(__FILE__) . '/../../bootstrap/unit.php';
require 'criteria/xfCriterion.interface.php';
require 'criteria/xfCriterionTerm.class.php';
require 'criteria/xfCriterionDecorator.class.php';
require 'criteria/xfCriterionRequired.class.php';
require 'criteria/xfCriterionTranslator.interface.php';
require 'criteria/xfCriterionTranslatorString.class.php';
$t = new lime_test(3, new lime_output_color());
$c = new xfCriterionRequired(new xfCriterionTerm('foo'));
$t->is($c->toString(), 'REQUIRED {foo}', '->toString() works');
$trans = new xfCriterionTranslatorString();
$c->translate($trans);
$t->is($trans->getString(), '+foo', '->translate() translates the query');
$t->is($c->optimize(), $c, '->optimize() does nothing');
示例12: dirname
<?php
$app = 'frontend';
include dirname(__FILE__) . '/../../bootstrap/functional.php';
$t = new lime_test(13);
// ->__construct()
$t->diag('->__construct()');
class NumericFieldForm extends ArticleForm
{
public function configure()
{
$this->widgetSchema[1] = new sfWidgetFormInputText();
$this->validatorSchema[1] = new sfValidatorPass();
$this->setDefault(1, '==DEFAULT_VALUE==');
}
}
$form = new NumericFieldForm();
$defaults = $form->getDefaults();
$t->is($defaults[1], '==DEFAULT_VALUE==', '->__construct() allows ->configure() to set defaults on numeric fields');
class DefaultValuesForm extends AuthorForm
{
public function configure()
{
$this->setDefault('name', 'John Doe');
}
}
$author = new Author();
$form = new DefaultValuesForm($author);
$t->is($form->getDefault('name'), 'John Doe', '->__construct() uses form defaults for new objects');
$author = new Author();
$author->name = 'Jacques Doe';
示例13: 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');
}
}
示例14: require_once
<?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(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));
示例15: define
<?php
// test/unit/renderer/sympal/mySympalMarkdownRendererTest.php
// あらかじめパーサー定数を変更しておく
define('MARKDOWN_PARSER_CLASS', 'myMarkdownExtra_Parser');
require_once dirname(__FILE__) . '/../../../bootstrap/unit.php';
$t = new lime_test(3);
// markdownテスト
$t->diag('markdown機能自体をテスト');
$data = "test";
$t->is(mySympalMarkdownRenderer::enhanceHtml(Markdown($data), $data), "<p>test</p>\n", 'markdownレンダリング');
$data = "# test\n## test2";
$t->is(mySympalMarkdownRenderer::enhanceHtml(Markdown($data), $data), "<h1 id=\"" . md5('test') . "\">test</h1>\n\n<h2 id=\"" . md5('test2') . "\">test2</h2>\n", 'markdownレンダリング');
$data = <<<EOT
[php]
echo "Hello, World!";
EOT;
$t->is(mySympalMarkdownRenderer::enhanceHtml(Markdown($data), $data), "<pre class=\"php\"><span class=\"kw3\">echo</span> <span class=\"st0\">"Hello, World!"</span>;\n </pre>\n", 'markdownレンダリング(php)');