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


PHP dm::loadHelpers方法代码示例

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


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

示例1: dirname

<?php

require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
$t = new lime_test(47);
dm::loadHelpers(array('Dm'));
sfConfig::set('sf_no_script_name', false);
dmDb::table('DmPage')->checkBasicPages();
$sc = $helper->get('service_container');
$sc->mergeParameter('link_tag_record.options', array('current_span' => false))->mergeParameter('link_tag_page.options', array('current_span' => false));
$t->diag('link current_span is false');
$home = dmDb::table('DmPage')->getTree()->fetchRoot();
$helper->get('context')->setPage($home);
$t->diag($home->name . ' is the current page');
$testPage = dmDb::create('DmPage', array('module' => 'main', 'action' => 'test' . dmString::random(12), 'name' => 'I am a root child', 'slug' => dmString::random()));
$testPage->Node->insertAsLastChildOf($home);
$scriptName = $helper->get('request')->getScriptName();
$t->diag('Current cli script name = ' . $scriptName);
$t->is((string) _link('http://c2.com/cgi/wiki?DontRepeatYourself')->text('DRY'), $expected = '<a class="link" href="http://c2.com/cgi/wiki?DontRepeatYourself">DRY</a>', $expected);
$t->like(£link()->render(), '|<a class="link dm_current|', '£link() has class dm_current');
$t->like(£link()->set('current_class', 'my_current')->render(), '|<a class="link my_current|', '£link() has class my_current');
$t->is((string) £link($home), (string) £link(), '£link($home) is £link()');
$t->is((string) £link('@homepage'), (string) £link($home), '£link("@homepage") is £link()');
$t->is((string) £link('main/root'), (string) £link($home), '£link("main/root") is £link()');
$t->is(£link()->getHref(), $scriptName, 'root href is ' . $scriptName);
$t->is(£link()->getText(), $home->name, 'root link text is ' . $home->name);
$expected = $helper->get('controller')->genUrl('dmAuth/signin');
$t->is(£link('+/dmAuth/signin')->getHref(), $expected, '+/dmAuth/signin href is ' . $expected);
$rootLink = sprintf('<a class="%s" href="%s">%s</a>', 'link dm_current', $scriptName, $home->name);
$t->is((string) £link(), $rootLink, 'root link is ' . $rootLink);
开发者ID:theolymp,项目名称:diem,代码行数:31,代码来源:dmFrontLinkTagTest.php

示例2: getcwd

<?php

$config = getcwd() . '/config/ProjectConfiguration.class.php';
require_once $config;
require_once dm::getDir() . '/dmCorePlugin/test/unit/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
$t = new lime_test(50);
dm::loadHelpers(array('Dm', 'I18N'));
$menu = $helper->get('menu')->name('Test Menu');
$root1 = $menu->getChild('Root 1');
$root1->addChild('Child 1');
$last = $root1->addChild('Child 2');
$root2 = $menu->getChild('Root 2');
$child1 = $root2->addChild('Child 1');
$child2 = $child1->addChild('Child 2');
$t->is($root1->getLevel(), 0, 'Test root level is 0');
$t->is($root2->getLevel(), 0, 'Test root level is 0');
$t->is($child1->getLevel(), 1, 'Test level is 1');
$t->is($child2->getLevel(), 2, 'Test level is 2');
$t->is($child2->getPathAsString(), 'Test Menu > Root 2 > Child 1 > Child 2', 'Test getPathAsString()');
$t->is(get_class($root1), get_class($menu), 'Test children are created as same class as parent');
// array access
$t->is($menu['Root 1']['Child 1']->getName(), 'Child 1', 'Test name()');
// countable
$t->is(count($menu), $menu->count(), 'Test sfSympalMenu Countable interface');
$t->is(count($root1), 2, 'Test sfSympalMenu Countable interface');
$count = 0;
foreach ($root1 as $key => $value) {
    $count++;
    $t->is($key, 'Child ' . $count, 'Test iteratable');
开发者ID:jdart,项目名称:diem,代码行数:31,代码来源:dmMenuTest.php

示例3: getcwd

<?php

$config = getcwd() . '/config/ProjectConfiguration.class.php';
require_once $config;
require_once dm::getDir() . '/dmCorePlugin/test/unit/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
// load both standard and alternative helpers
dm::loadHelpers(array('Dm', 'DmAlternative', 'I18N'));
$t = new lime_test(30);
/*
* $helper is the test helper. It acts as a service container
* and can provide you all services with its get() method.
* so here we get the 'helper' service which is the template helper instance
*/
$templateHelper = $helper->get('helper');
// £ function
$t->is(£('div', 'content'), _tag('div', 'content'), '£ == _tag');
// £ method
$t->is($templateHelper->£('div', 'content'), $templateHelper->tag('div', 'content'), '£ == _tag');
$t->is(£('div', 'content'), _tag('div', 'content'), '£ == _tag');
// £link method
$t->is((string) $templateHelper->£link()->text('home'), (string) $templateHelper->link()->text('home'), '£link == _link');
$t->is((string) £link()->text('home'), (string) _link()->text('home'), '£link == _link');
$openDiv = '<div>';
$t->is(£o('div'), _tagO('div'), $openDiv);
$openDiv = '<div class="test_class">';
$t->is(£o('div.test_class'), _tagO('div.test_class'), $openDiv);
$openDiv = '<div id="test_id" class="test_class other_class">';
$t->is(£o('div#test_id.test_class.other_class'), _tagO('div#test_id.test_class.other_class'), $openDiv);
$openDiv = '<div class="test_class other_class" id="test_id">';
开发者ID:jdart,项目名称:diem,代码行数:31,代码来源:dmAlternativeHelperTest.php

示例4: dmUnitTestHelper

$helper = new dmUnitTestHelper();
$helper->boot('front');
$t = new lime_test(76);
$pageTable = dmDb::table('DmPage');
$root = $pageTable->getTree()->fetchRoot();
$testModule = dmString::random();
$pages = array($root);
for ($it = 1; $it <= 2; $it++) {
    $pages[] = $p = dmDb::table('DmPage')->create(array('module' => $testModule, 'action' => 'test' . $it, 'name' => dmString::random(), 'slug' => dmString::random()));
    $p->Node->insertAsLastChildOf($pages[$it - 1]);
    $pages[$it - 1]->refresh();
    $p->refresh();
    $t->ok($p->exists(), $p . ' exists');
    $t->is($p->nodeParentId, (string) $pages[$it - 1]->id, $p . ' is child of ' . $pages[$it - 1]);
}
dm::loadHelpers(array('DmFront'));
foreach ($pages as $index => $page) {
    $helper->get('context')->setPage($page);
    $t->comment('Testing ->isSource for ' . $page);
    foreach ($pages as $_page) {
        $ok = $page === $_page;
        $t->is($page->isSource($_page), $ok, '$page->isSource($page) ' . ($ok ? 'TRUE' : 'FALSE'));
        $t->is($page->isSource("page:" . $_page->id), $ok, '$page->isSource("page:".$page->id) ' . ($ok ? 'TRUE' : 'FALSE'));
        $t->is($page->isSource($_page->module . "/" . $_page->action), $ok, '$page->isSource($page->module."/".$page->action) ' . ($ok ? 'TRUE' : 'FALSE'));
        $t->is(dm_current($_page), $ok, 'dm_current($page) ' . ($ok ? 'TRUE' : 'FALSE'));
    }
    if ($index) {
        $t->comment('Testing ->isDescendantOfSource for ' . $page);
        for ($i = 0; $i < $index; $i++) {
            $t->ok($page->isDescendantOfSource($pages[$i]), '$page->isDescendantOfSource($pages[$i])');
            $t->ok($page->isDescendantOfSource("page:" . $pages[$i]->id), '$page->isDescendantOfSource("page:".$pages[$i]->id)');
开发者ID:theolymp,项目名称:diem,代码行数:31,代码来源:dmPageTest.php

示例5: dirname

<?php

require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
$t = new lime_test();
dm::loadHelpers('DmFront');
$title = dm_get_widget('dmWidgetContent', 'title', array('tag' => 'h1', 'text' => 'The title text'));
$expected = '<div class="dm_widget content_title"><div class="dm_widget_inner"><h1>The title text</h1></div></div>';
$t->is($title, $expected, 'rendered title H1');
$title = dm_get_widget('dmWidgetContent', 'title', array('tag' => 'h2', 'text' => 'The title text', 'css_class' => 'custom_class'));
$expected = '<div class="dm_widget content_title custom_class"><div class="dm_widget_inner"><h2>The title text</h2></div></div>';
$t->is($title, $expected, 'rendered title H2 with CSS class');
$title = dm_get_widget('main', 'header', array('name' => 'Thibault', 'css_class' => 'custom_class'));
$expected = '<div class="dm_widget main_header custom_class"><div class="dm_widget_inner">name: Thibault</div></div>';
$t->is($title, $expected, 'rendered main header with component param and CSS class');
开发者ID:theolymp,项目名称:diem,代码行数:16,代码来源:dmFrontHelperGetWidgetTest.php

示例6: dirname

<?php

require_once dirname(__FILE__) . '/helper/dmUnitTestHelper.php';
$helper = new dmUnitTestHelper();
$helper->boot('front');
class DummyTestForm extends dmForm
{
    public function getStylesheets()
    {
        return array('lib.ui-tabs', 'lib.ui-core' => 'all');
    }
    public function getJavascripts()
    {
        return array('core.tabForm');
    }
}
$t = new lime_test();
$form = new DummyTestForm();
dm::loadHelpers(array('Asset', 'Tag', 'Dm'));
$stylesheets = dm_get_stylesheets_for_form($form);
$t->like($stylesheets, '#' . preg_quote('/dmCorePlugin/lib/jquery-ui/css/jquery-ui-tabs.css', '#') . '#');
$t->like($stylesheets, '#' . preg_quote('/fancyTheme/css/lib.ui-core.css', '#') . '#');
$javascripts = dm_get_javascripts_for_form($form);
$t->like($javascripts, '#' . preg_quote('/dmCorePlugin/js/dmCoreTabForm.js', '#') . '#');
开发者ID:theolymp,项目名称:diem,代码行数:24,代码来源:dmAssetForFormTest.php


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