当前位置: 首页>>代码示例>>PHP>>正文


PHP lime_test::like方法代码示例

本文整理汇总了PHP中lime_test::like方法的典型用法代码示例。如果您正苦于以下问题:PHP lime_test::like方法的具体用法?PHP lime_test::like怎么用?PHP lime_test::like使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在lime_test的用法示例。


在下文中一共展示了lime_test::like方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: launchTests

 /**
  * Test launcher
  *
  * @param string $schema Path to schema file
  */
 function launchTests($schema)
 {
     $this->t->diag('->load()');
     $this->load($schema);
     $this->t->diag('->getTables()');
     $tables = $this->tables;
     $this->t->is(count($tables), 2, "->getTables() should return 2 table from fixture.");
     $this->t->ok(in_array('testTable', array_keys($tables)), "->getTables() should return 'testTable' from fixture.");
     $this->t->diag('->classes');
     $this->t->is(count($this->classes), 2, "->classes should have 2 class from fixture");
     $this->t->ok($this->getClass('TestTable'), "->classes should have 'TestTable' from fixture.");
     $this->t->ok($this->getClass('TestTable')->getColumn('dummy_id')->hasRelation(), 'foreign relation is properly imported');
     #$this->t->diag('->asDoctrineYml()');
     #$yml = $this->asDoctrineYml();
     #$this->t->cmp_ok(strlen($yml['source']), '>', 0, "->asDoctrineYml() doctrine YAML shoudl not be empty.");
     $this->t->diag('->findClassByTableName()');
     $this->t->is($this->findClassByTableName('testTable')->getPhpName(), 'TestTable', "->findClassByTableName() returns 'TestTable' class for 'testTable' table.");
     $yml = $this->asDoctrineYml();
     $yml = $yml['source'];
     $this->t->like($yml, '@cascadeDelete: 1@', 'onDelete is generated');
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:26,代码来源:sfDoctrineSchemaPropelLoaderTest.php

示例2: launchTests

 /**
  * Test launcher
  *
  * @param string $schema Path to schema file
  */
 function launchTests($schema)
 {
     $this->t->diag('->load()');
     $this->load($schema);
     $this->process();
     $yml = $this->asDoctrineYml();
     $this->t->diag('->getClasses()');
     $classes = $this->getClasses();
     $nbClasses = 12;
     $this->t->is(count($classes), $nbClasses, "->getClasses() should return {$nbClasses} classes from fixture.");
     $this->t->diag('->getClass()');
     $class = $this->getClass('TestClass');
     #$this->t->ok($class->isTable(),"->getClass() should return return class instance.");
     $this->t->diag('->parentTable()');
     $table = $this->parentTable($class);
     $this->t->is(get_class($table), 'sfDoctrineTableSchema', "->parentTable() should return table instance.");
     $this->t->is($this->getClass('ColAggregation')->getTableName(), 'parent_table', 'inheritance gets the right parent table');
     #$this->t->ok($this->getClass('SeparateTable')->isTable(), '"SeparateTable" is a table-class');
     $this->t->is($this->getClass('BookI18n')->getColumn('culture')->getProperty('type'), 'string', 'culture field is defined (as a string)');
     $rel = $this->getClass('BookI18n')->getRelation('id');
     $this->t->is($rel->get('localName'), 'BookI18n', 'i18n relation name is not a plural');
     $this->t->is($this->getClass('ColAggregation')->getTable()->getColumn('class_key')->getProperty('type'), 'integer', 'inheritance field is defined (as an integer)');
     $c = $this->getClass('SeparateTable');
     $SeparateTablePhp = $c->asPhp();
     $SeparateTableSource = $SeparateTablePhp[0]['source'];
     $this->t->like($SeparateTableSource, '/extends Parent/', 'The class "SeparateTable" extends Parent without having any class key field');
     $this->t->like($SeparateTableSource, '@setTableName\\(\'separate_table\'\\)@', 'class "SeparateTable" has both a table and inheritance');
     $this->t->like($SeparateTableSource, '@parent::setTableDefinition\\(\\);@', 'class "SeparateTable" calls parent::setTableDefinition');
     $colAggregationPhp = $this->getClass('ColAggregation')->asPhp();
     $this->t->like($colAggregationPhp[0]['source'], "@setInheritanceMap\\(array\\('class_key'=>1\\)\\)@", 'setInheritanceMap is properly set');
     $this->t->diag('relationships');
     $yangPhp = $this->getClass('Yin')->asPhp();
     $this->t->like($yangPhp[0]['source'], "#hasOne\\('Yang as Yang', 'Yin.yang_id', 'id'\\)#", 'one to one relationships is properly declared');
     $userPhp = $this->getClass('User')->asPhp();
     $this->t->like($userPhp[0]['source'], "#hasMany\\('Book as Books', 'Book.author_id'\\)#", 'hasMany is properly declared');
     $this->t->like($userPhp[0]['source'], "#hasMany\\('Group as Groups', 'User2Group.group_id'\\)#", 'has many to many properly declared');
     $userGroupPhp = $this->getClass('User2Group')->asPhp();
     $this->t->like($userGroupPhp[0]['source'], "#ownsOne\\('User as User', 'User2Group.group_id', 'id'\\)#", 'has many to many with cascade properly defined');
 }
开发者ID:snouhaud,项目名称:camptocamp.org,代码行数:44,代码来源:sfDoctrineSchemaDoctrineLoaderTest.php

示例3: getStylesheets

        return array('/path/to/a/file.js');
    }
    public function getStylesheets()
    {
        return array('/path/to/a/file.css' => 'all');
    }
}
$w->setOption('renderer_class', 'MyWidget');
$t->is(get_class($w->getRenderer()), 'MyWidget', '->getRenderer() uses the renderer_class as the widget class if provided');
$w->setOption('renderer_class', null);
$w->setOption('renderer', new MyWidget(array('choices' => array())));
$t->is(get_class($w->getRenderer()), 'MyWidget', '->getRenderer() uses the renderer as the widget if provided');
// ->render()
$t->diag('->render()');
$w = new sfWidgetFormChoice(array('choices' => array('foo' => 'bar')));
$t->like($w->render('foo'), '/<select name="foo" id="foo">/', '->render() renders a select tag by default');
$w->setIdFormat('barID_%s');
$t->like($w->render('foo'), '/<select name="foo" id="barID_foo">/', '->render() uses the id format specified');
$w->setIdFormat('%s');
$w->setOption('multiple', true);
$t->like($w->render('foo'), '/<select name="foo\\[\\]" multiple="multiple" id="foo">/', '->render() adds a multiple attribute for multiple selects');
$w->setOption('expanded', true);
$t->like($w->render('foo'), '/<ul class="checkbox_list">/', '->render() uses a checkbox list when expanded and multiple are true');
$w->setOption('multiple', false);
$t->like($w->render('foo'), '/<ul class="radio_list">/', '->render() uses a checkbox list when expanded is true and multiple is false');
// choices are translated
$t->diag('choices are translated');
$ws = new sfWidgetFormSchema();
$ws->addFormFormatter('stub', new FormFormatterStub());
$ws->setFormFormatterName('stub');
$w = new sfWidgetFormChoice(array('choices' => array('foo' => 'bar', 'foobar' => 'foo')));
开发者ID:vcgato29,项目名称:poff,代码行数:31,代码来源:sfWidgetFormChoiceTest.php

示例4: getPropelConfiguration

    }
}
class sfWebDebugPanelPropelTestDifferentGlue extends sfWebDebugPanelPropel
{
    protected function getPropelConfiguration()
    {
        $config = new PropelConfiguration(array());
        $config->setParameter('debugpdo.logging.outerglue', 'xx');
        $config->setParameter('debugpdo.logging.innerglue', '/ ');
        $config->setParameter('debugpdo.logging.details.slow.enabled', true);
        $config->setParameter('debugpdo.logging.details.slow.threshold', 5);
        return $config;
    }
}
// ->getPanelContent()
$t->diag('->getPanelContent()');
$dispatcher = new sfEventDispatcher();
$logger = new sfVarLogger($dispatcher);
$logger->log('{sfPropelLogger} SELECT * FROM foo WHERE bar<1');
$logger->log('{sfPropelLogger} time: 3.42 sec | mem: 2.8 MB | SELECT * FROM foo WHERE aText like \' | foo\'');
$panel = new sfWebDebugPanelPropelTest(new sfWebDebug($dispatcher, $logger));
$content = $panel->getPanelContent();
$t->like($content, '/bar&lt;1/', '->getPanelContent() returns escaped queries');
$t->like($content, '/aText like &#039; | foo&#039;/', '->getPanelContent() works with glue string in SQL');
$t->like($content, '/sfWebDebugWarning/', '->getPanelContent() contains a slow query warning');
$logger = new sfVarLogger($dispatcher);
$logger->log('{sfPropelLogger} time/ 3.42 secxxmem/ 2.8 MBxxSELECT * FROM foo WHERE bar == 42');
$panel = new sfWebDebugPanelPropelTestDifferentGlue(new sfWebDebug($dispatcher, $logger));
$content = $panel->getPanelContent();
$t->like($content, '/time\\/ 3.42 sec, mem\\/ 2.8 MB/', '->getPanelContent() works with strange glue strings');
$t->unlike($content, '/sfWebDebugWarning/', '->getPanelContent() should not contain a slow warning');
开发者ID:cuongnv540,项目名称:jobeet,代码行数:31,代码来源:sfWebDebugPanelPropelTest.php

示例5: catch

EOF;
$t->is($child['name']->renderError(), fix_linebreaks($output), '->renderRow() renders errors as HTML when the widget has a parent');
try {
    $parent->renderError();
    $t->fail('->renderError() throws an LogicException if the form field has no parent');
} catch (LogicException $e) {
    $t->pass('->renderError() throws an LogicException if the form field has no parent');
}
// global errors
$authorErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'name error'), 'name');
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'non existent field error'), 'non_existent_field');
$authorErrorSchema->addError(new sfValidatorError(new sfValidatorString(), 'hidden field error'), 'id');
$articleErrorSchema = new sfValidatorErrorSchema(new sfValidatorString());
$articleErrorSchema->addError($titleError = new sfValidatorError(new sfValidatorString(), 'title error'), 'title');
$articleErrorSchema->addError($authorErrorSchema, 'author');
$parent = new sfFormFieldSchema($schema, null, 'article', array('title' => 'symfony', 'author' => array('name' => 'Fabien')), $articleErrorSchema);
$child = $parent['author'];
$output = <<<EOF
  <ul class="error_list">
    <li>non existent field error</li>
    <li>Id: hidden field error</li>
  </ul>

EOF;
$t->is($child->renderError(), fix_linebreaks($output), '->renderError() renders global errors as expected (global errors, hidden field errors, non existent field errors)');
// id format
$schema->setIdFormat('%s_id_format_test');
$parent = new sfFormFieldSchema($schema, null, 'article', array('title' => 'symfony', 'author' => array('name' => 'Fabien')), $articleErrorSchema);
$t->like($parent['author']->render(), '/_id_format_test/', '->render() uses the parent id format');
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:30,代码来源:sfFormFieldTest.php

示例6: getNum

$t->is($last->getNum(), 3, 'Test getNum()');
class dmMyMenu extends dmMenu
{
}
$menu = $helper->get('menu', 'dmMyMenu')->name('My menu');
$t->isa_ok($menu, 'dmMyMenu', 'Got a dmMyMenu instance');
$menu->addChild('Home', '@homepage')->end()->addChild('Sites')->ulClass('my_ul_class')->addChild('Diem', 'http://diem-project.org')->showId(true)->end()->addChild('Symfony', 'http://symfony-project.org')->end();
$html = _tag('ul', _tag('li.first', _link('@homepage')->text($helper->get('i18n')->__('Home'))) . _tag('li.last', 'Sites' . _tag('ul.my_ul_class', _tag('li#my-menu-diem.first', _link('http://diem-project.org')->text('Diem')) . _tag('li.last', _link('http://symfony-project.org')->text('Symfony')))));
$t->is($menu->render(), $html, $html);
$t->comment('Test getRoot');
$t->is($menu['Home']->getRoot(), $menu, 'Home root is $menu');
$t->is($menu['Sites']['Diem']->getRoot(), $menu, 'Diem root is menu');
$sitemap = $helper->get('sitemap_menu')->build();
$t->isa_ok($sitemap, 'dmSitemapMenu', 'Got a dmSitemapMenu');
$t->is($sitemap->getFirstChild()->renderLink(), (string) _link(), 'Sitemap first child is Home');
$t->like((string) $sitemap, '|^' . preg_quote('<ul><li class="first last"><a class="link" href="', '|') . '.*|', 'Sitemap html is valid');
$t->comment('Test current page');
$homePage = dmDb::table('DmPage')->getTree()->fetchRoot();
$helper->getContext()->setPage($homePage);
$menu = $helper->get('menu')->addChild('Home', '@homepage')->end();
$html = _tag('ul', _tag('li.first.last.dm_current', _link()->text($helper->get('i18n')->__('Home'))));
$t->is($menu->render(), $html, 'Current li has the dm_current class');
$helper->getContext()->setPage(dmDb::table('DmPage')->findOneByModuleAndAction('main', 'signin'));
$menu = $helper->get('menu')->addChild('Home', '@homepage')->end();
$html = _tag('ul', _tag('li.first.last.dm_parent', _link()->text($helper->get('i18n')->__('Home'))));
$t->is($menu->render(), $html, 'Parent li has the dm_parent class');
$menu = $helper->get('menu')->addChild('Home')->end()->addChild('Sites')->addChild('Diem')->end()->addChild('Symfony')->end()->end();
$html = _tag('ul', _tag('li.first', 'Home') . _tag('li.last', 'Sites' . _tag('ul', _tag('li.first', 'Diem') . _tag('li.last', 'Symfony'))));
$t->is($menu->render(), $html, $html);
$t->comment('->getSiblings()');
$t->is_deeply($menu['Home']->getSiblings(), array('Sites' => $menu['Sites']), '->getSiblings() works');
开发者ID:jdart,项目名称:diem,代码行数:31,代码来源:dmMenuTest.php

示例7:

try
{
  $controller->convertUrlStringToParameters('@test?foobar');
  $t->fail('->convertUrlStringToParameters() throw a sfParseException if it cannot parse the query string');
}
catch (sfParseException $e)
{
  $t->pass('->convertUrlStringToParameters() throw a sfParseException if it cannot parse the query string');
}

// ->redirect()
$t->diag('->redirect()');
$controller->redirect('module/action?id=1#photos');
$response = $context->getResponse();
$t->like($response->getContent(), '~http\://localhost/index.php/\?module=module&amp;action=action&amp;id=1#photos~', '->redirect() adds a refresh meta in the content');
$t->like($response->getHttpHeader('Location'), '~http\://localhost/index.php/\?module=module&action=action&id=1#photos~', '->redirect() adds a Location HTTP header');

// Test null url argument for ->redirect()
try
{
  $controller->redirect(null);
  $t->fail('->redirect() throw an InvalidArgumentException when the url argument is null');
}
catch (InvalidArgumentException $iae)
{
  $t->pass('->redirect() throw an InvalidArgumentException when the url argument is null');
}
catch(Exception $e)
{
  $t->fail('->redirect() throw an InvalidArgumentException when the url argument is null. '.get_class($e).' was received');
开发者ID:nationalfield,项目名称:symfony,代码行数:30,代码来源:sfWebControllerTest.php

示例8: sfAggregateLogger

// ->initialize()
$t->diag('->initialize()');
$logger = new sfAggregateLogger($dispatcher, array('loggers' => $fileLogger));
$t->is($logger->getLoggers(), array($fileLogger), '->initialize() can take a "loggers" parameter');

$logger = new sfAggregateLogger($dispatcher, array('loggers' => array($fileLogger, $streamLogger)));
$t->is($logger->getLoggers(), array($fileLogger, $streamLogger), '->initialize() can take a "loggers" parameter');

// ->log()
$t->diag('->log()');
$logger->log('foo');
rewind($buffer);
$content = stream_get_contents($buffer);
$lines = explode("\n", file_get_contents($file));
$t->like($lines[0], '/foo/', '->log() logs a message to all loggers');
$t->is($content, 'foo'.PHP_EOL, '->log() logs a message to all loggers');

// ->getLoggers() ->addLoggers() ->addLogger()
$logger = new sfAggregateLogger($dispatcher);
$logger->addLogger($fileLogger);
$t->is($logger->getLoggers(), array($fileLogger), '->addLogger() adds a new sfLogger instance');

$logger = new sfAggregateLogger($dispatcher);
$logger->addLoggers(array($fileLogger, $streamLogger));
$t->is($logger->getLoggers(), array($fileLogger, $streamLogger), '->addLoggers() adds an array of sfLogger instances');

// ->shutdown()
$t->diag('->shutdown()');
$logger->shutdown();
开发者ID:nationalfield,项目名称:symfony,代码行数:29,代码来源:sfAggregateLoggerTest.php

示例9: check_attribute

function check_attribute(lime_test $t, $result, $attribute, $value)
{
    $str = sprintf('%s="%s"', $attribute, $value);
    $t->like($result, '/' . preg_quote($str) . '/', sprintf('->result contains attribute %s="%s"', $attribute, $value));
}
开发者ID:kimbrelas,项目名称:ioEditableContentPlugin,代码行数:5,代码来源:ioEditableContentTest.php

示例10: __construct

require_once dirname(__FILE__) . '/../../bootstrap/unit.php';
$t = new lime_test(null);
class sfWebDebugTest extends sfWebDebug
{
    public function __construct()
    {
        $this->options['image_root_path'] = '';
        $this->options['request_parameters'] = array();
    }
}
$debug = new sfWebDebugTest();
// ->injectToolbar()
$t->diag('->injectToolbar()');
$before = '<html><head></head><body></body></html>';
$after = $debug->injectToolbar($before);
$t->like($after, '/<style type="text\\/css">/', '->injectToolbar() adds styles');
$t->like($after, '/<div id="sfWebDebug">/', '->injectToolbar() adds the toolbar');
$before = '';
$after = $debug->injectToolbar($before);
$t->unlike($after, '/<style type="text\\/css">/', '->injectToolbar() does not add styles if there is no head');
$t->like($after, '/<div id="sfWebDebug">/', '->injectToolbar() adds the toolbar if there is no body');
$before = <<<HTML
<html>
<head></head>
<body>
<textarea><html><head></head><body></body></html></textarea>
</body>
</html>
HTML;
$after = $debug->injectToolbar($before);
$t->is(substr_count($after, '<style type="text/css">'), 1, '->injectToolbar() adds styles once');
开发者ID:nelsonlrp,项目名称:Acad-mico,代码行数:31,代码来源:sfWebDebugTest.php

示例11: sprintf

        return sprintf('translation[%s]', $subject);
    }
}
$t = new lime_test(22);
$dom = new DomDocument('1.0', 'utf-8');
$dom->validateOnParse = true;
// ->render()
$t->diag('->render()');
$w = new sfWidgetFormSelect(array('choices' => array('foo' => 'bar', 'foobar' => 'foo')));
$dom->loadHTML($w->render('foo', 'foobar'));
$css = new sfDomCssSelector($dom);
$t->is($css->matchSingle('#foo option[value="foobar"][selected="selected"]')->getValue(), 'foo', '->render() renders a select tag with the value selected');
$t->is(count($css->matchAll('#foo option')->getNodes()), 2, '->render() renders all choices as option tags');
// value attribute is always mandatory
$w = new sfWidgetFormSelect(array('choices' => array('' => 'bar')));
$t->like($w->render('foo', 'foobar'), '/<option value="">/', '->render() always generate a value attribute, even for empty keys');
// other attributes are removed is empty
$w = new sfWidgetFormSelect(array('choices' => array('' => 'bar')));
$t->like($w->render('foo', 'foobar', array('class' => '', 'style' => null)), '/<option value="">/', '->render() always generate a value attribute, even for empty keys');
// multiple select
$t->diag('multiple select');
$w = new sfWidgetFormSelect(array('multiple' => true, 'choices' => array('foo' => 'bar', 'foobar' => 'foo')));
$dom->loadHTML($w->render('foo', array('foo', 'foobar')));
$css = new sfDomCssSelector($dom);
$t->is(count($css->matchAll('select[multiple="multiple"]')->getNodes()), 1, '->render() automatically adds a multiple HTML attributes if multiple is true');
$t->is(count($css->matchAll('select[name="foo[]"]')->getNodes()), 1, '->render() automatically adds a [] at the end of the name if multiple is true');
$t->is($css->matchSingle('#foo option[value="foobar"][selected="selected"]')->getValue(), 'foo', '->render() renders a select tag with the value selected');
$t->is($css->matchSingle('#foo option[value="foo"][selected="selected"]')->getValue(), 'bar', '->render() renders a select tag with the value selected');
$dom->loadHTML($w->render('foo[]', array('foo', 'foobar')));
$css = new sfDomCssSelector($dom);
$t->is(count($css->matchAll('select[name="foo[]"]')->getNodes()), 1, '->render() automatically does not add a [] at the end of the name if multiple is true and the name already has one');
开发者ID:Phennim,项目名称:symfony1,代码行数:31,代码来源:sfWidgetFormSelectTest.php

示例12: dirname

 * 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(8);
$handler = new sfFilterConfigHandler();
$handler->initialize();
$dir = dirname(__FILE__) . DIRECTORY_SEPARATOR . 'fixtures' . DIRECTORY_SEPARATOR . 'sfFilterConfigHandler' . DIRECTORY_SEPARATOR;
// parse errors
$t->diag('parse errors');
$files = array($dir . 'no_class.yml');
try {
    $data = $handler->execute($files);
    $t->fail('filters.yml must have a "class" section for each filter entry');
} catch (sfParseException $e) {
    $t->like($e->getMessage(), '/with missing class key/', 'filters.yml must have a "class" section for each filter entry');
}
// no execution/rendering filter
foreach (array('execution', 'rendering') as $key) {
    $files = array($dir . sprintf('no_%s.yml', $key));
    try {
        $data = $handler->execute($files);
        $t->fail(sprintf('filters.yml must have a filter of type "%s"', $key));
    } catch (sfParseException $e) {
        $t->like($e->getMessage(), sprintf('/must register a filter of type "%s"/', $key), sprintf('filters.yml must have a filter of type "%s"', $key));
    }
}
// filter inheritance
$t->diag('filter inheritance');
$files = array($dir . 'default_filters.yml', $dir . 'not_disabled.yml');
try {
开发者ID:hunde,项目名称:bsc,代码行数:31,代码来源:sfFilterConfigHandlerTest.php

示例13: dirname

<?php

include dirname(__FILE__) . '/../bootstrap/doctrine.php';
// Initialize the test object
$t = new lime_test(24, new lime_output_color());
$valid_test_song = array('artist_name' => 'Gorillaz', 'album_name' => 'Gorillaz Compilation', 'genre_name' => 'Electronic', 'song_name' => 'Clint Eastwood', 'song_length' => '2:05', 'accurate_length' => '125000', 'filesize' => 3000024, 'bitrate' => 128, 'yearpublished' => 2010, 'tracknumber' => 7, 'label' => 'EMI', 'mtime' => 1293300000, 'atime' => 1293300011, 'filename' => 'file://localhost/home/notroot/music/test.mp3');
$utf8_test_song = array('artist_name' => 'Sigur Rós', 'album_name' => 'með suð í eyrum við spilum endalaust', 'genre_name' => 'Русский', 'song_name' => 'dót widget', 'song_length' => '3:05', 'accurate_length' => 185000, 'filesize' => 3002332, 'bitrate' => 128, 'yearpublished' => 2005, 'tracknumber' => 1, 'label' => 'ンスの映像を世界に先がけて', 'mtime' => 1293300023, 'atime' => 1293300011, 'filename' => 'file://localhost/home/notroot/music/Fließgewässer.mp3');
$media_scan = new MediaScan();
$t->comment('->construct()');
$t->like($media_scan->get_last_scan_id(), '/\\d+/', 'Entered a new scan id successfully.');
$t->comment('->is_scanned()');
$t->is($media_scan->is_scanned('file://localhost/home/notroot/music/test.mp3', '1293300000'), false, 'Song should not exist yet');
$first_insert_id = $media_scan->add_song($valid_test_song);
$t->like($first_insert_id, '/\\d+/', 'Successfully added a song to the database');
$t->comment('->add_song()');
$media_scan = new MediaScan();
$second_insert_id = $media_scan->add_song($utf8_test_song);
$t->like($second_insert_id, '/\\d+/', 'Successfully added a UTF-8 Song entry.');
$t->is($media_scan->is_scanned('file://localhost/home/notroot/music/test.mp3', '1293300000'), true, 'Updated old record to new scan id number');
$media_scan = new MediaScan();
$second_insert_id = $media_scan->add_song($utf8_test_song);
//Test Data Integrity after add
$song_integrity_test = Doctrine_Core::getTable('Song')->find(2);
$artist_integrity_test = Doctrine_Core::getTable('Artist')->find(2);
$album_integrity_test = Doctrine_Core::getTable('Album')->find(2);
$genre_integrity_test = Doctrine_Core::getTable('Genre')->find(127);
$t->is($song_integrity_test->id, 2, 'integrity: primary id');
$t->is($song_integrity_test->scan_id, 2, 'integrity: last_scan_id id');
$t->is($song_integrity_test->artist_id, 2, 'integrity: artist_id');
$t->is($artist_integrity_test->name, 'Sigur Rós', 'integrity: artist_name');
$t->is($song_integrity_test->album_id, 2, 'integrity: album_id');
开发者ID:Alenpiera,项目名称:streeme,代码行数:31,代码来源:MediaScanTest.php

示例14: getTimeFormat

}
$dispatcher = new sfEventDispatcher();
// ->initialize()
$t->diag('->initialize()');
try {
    $logger = new sfFileLogger($dispatcher);
    $t->fail('->initialize() parameters must contains a "file" parameter');
} catch (sfConfigurationException $e) {
    $t->pass('->initialize() parameters must contains a "file" parameter');
}
// ->log()
$t->diag('->log()');
$logger = new sfFileLogger($dispatcher, array('file' => $file));
$logger->log('foo');
$lines = explode("\n", file_get_contents($file));
$t->like($lines[0], '/foo/', '->log() logs a message to the file');
$logger->log('bar');
$lines = explode("\n", file_get_contents($file));
$t->like($lines[1], '/bar/', '->log() logs a message to the file');
class TestLogger extends sfFileLogger
{
    public function getTimeFormat()
    {
        return $this->timeFormat;
    }
    protected function getPriority($priority)
    {
        return '*' . $priority . '*';
    }
}
// option: format
开发者ID:mediasadc,项目名称:alba,代码行数:31,代码来源:sfFileLoggerTest.php

示例15: catch

    $t->skip('', 1);
} catch (sfValidatorError $e) {
    $t->pass('->clean() throws a sfValidatorError if the date is not valid');
    $t->is($e->getCode(), 'invalid', '->clean() throws a sfValidatorError');
}
// validate regex
$t->diag('validate regex');
$v->setOption('date_format', '~(?P<day>\\d{2})/(?P<month>\\d{2})/(?P<year>\\d{4})~');
$t->is($v->clean('18/10/2005'), '2005-10-18', '->clean() accepts a regular expression to match dates');
try {
    $v->clean('2005-10-18');
    $t->fail('->clean() throws a sfValidatorError if the date does not match the regex');
    $t->skip('', 2);
} catch (sfValidatorError $e) {
    $t->pass('->clean() throws a sfValidatorError if the date does not match the regex');
    $t->like($e->getMessage(), '/' . preg_quote(htmlspecialchars($v->getOption('date_format'), ENT_QUOTES, 'UTF-8'), '/') . '/', '->clean() returns the expected date format in the error message');
    $t->is($e->getCode(), 'bad_format', '->clean() throws a sfValidatorError');
}
$v->setOption('date_format_error', 'dd/mm/YYYY');
try {
    $v->clean('2005-10-18');
    $t->skip('', 1);
} catch (sfValidatorError $e) {
    $t->like($e->getMessage(), '/' . preg_quote('dd/mm/YYYY', '/') . '/', '->clean() returns the expected date format error if provided');
}
$v->setOption('date_format', null);
// option with_time
$t->diag('option with_time');
$v->setOption('with_time', true);
$t->is($v->clean(array('year' => 2005, 'month' => 10, 'day' => 15, 'hour' => 12, 'minute' => 10, 'second' => 15)), '2005-10-15 12:10:15', '->clean() accepts an array as an input');
$t->is($v->clean(array('year' => '2005', 'month' => '10', 'day' => '15', 'hour' => '12', 'minute' => '10', 'second' => '15')), '2005-10-15 12:10:15', '->clean() accepts an array as an input');
开发者ID:bigcalm,项目名称:urlcatcher,代码行数:31,代码来源:sfValidatorDateTest.php


注:本文中的lime_test::like方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。