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">'; $t->is(£o('div', array('id' => 'test_id', 'class' => 'test_class other_class')), _tagO('div', array('id' => 'test_id', 'class' => 'test_class other_class')), $openDiv); $div = '<div></div>'; $t->is(£('div'), _tag('div'), $div); $div = '<div class="' . htmlentities('{"attr":"value"}') . '">div content</div>'; $t->is($templateHelper->£('div', array('json' => array('attr' => 'value')), 'div content'), _tag('div', array('json' => array('attr' => 'value')), 'div content'), $div); $t->is(£('div', array('json' => array('attr' => 'value')), 'div content'), _tag('div', array('json' => array('attr' => 'value')), 'div content'), $div); $a = '<a href="an_href#with_anchor" id="test_id" class="test_class">a content</a>'; $t->is($templateHelper->£('a#test_id.test_class href="an_href#with_anchor"', 'a content'), _tag('a#test_id.test_class href="an_href#with_anchor"', 'a content'), $a);
$t->is($errorLink, $errorLink, $errorLink); $media->delete(); $t->is((string) £link('mailto:test@mail.com')->text('email'), $html = '<a class="link" href="mailto:test@mail.com">email</a>', 'mailto: ' . $html); $t->comment('Test use_beaf'); $helper->getServiceContainer()->mergeParameter('link_tag_uri.options', array('use_beaf' => true)); $expected = sprintf('<a class="link beafh" href="%s"><span class="beafore"></span><span class="beafin">%s</span><span class="beafter"></span></span></a>', 'http://diem-project.org', 'http://diem-project.org'); $t->is((string) £link('http://diem-project.org')->set('.beafh'), $expected, 'beafh link is ' . $expected); $expected = sprintf('<a class="link beafv" href="%s"><span class="beafore"></span><span class="beafin">%s</span><span class="beafter"></span></span></a>', 'http://diem-project.org', 'http://diem-project.org'); $t->is((string) £link('http://diem-project.org')->set('.beafv'), $expected, 'beafh link is ' . $expected); $expected = sprintf('<a class="link beafh myclass" href="%s"><span class="beafore"></span><span class="beafin">%s</span><span class="beafter"></span></span></a>', 'http://diem-project.org', 'http://diem-project.org'); $t->is((string) £link('http://diem-project.org')->set('.beafh.myclass'), $expected, 'beafh link is ' . $expected); $expected = sprintf('<a class="link beafv myclass" href="%s"><span class="beafore"></span><span class="beafin">%s</span><span class="beafter"></span></span></a>', 'http://diem-project.org', 'http://diem-project.org'); $t->is((string) £link('http://diem-project.org')->set('.beafv.myclass'), $expected, 'beafh link is ' . $expected); $expected = sprintf('<a class="link" href="%s">%s</a>', $helper->getContext()->getRequest()->getPathInfoPrefix() . '/simple-url', 'simple route url'); $t->is((string) £link('@link_test_route_1')->text('simple route url'), $expected, 'route link is ' . $expected); $expected = sprintf('<a class="link" href="%s">%s</a>', $helper->getContext()->getRequest()->getPathInfoPrefix() . '/simple-url?var1=value1', 'simple route url with extra query string'); $t->is((string) £link('@link_test_route_1')->param('var1', 'value1')->text('simple route url with extra query string'), $expected, 'route link is ' . $expected); $expected = sprintf('<a class="link" href="%s">%s</a>', $helper->getContext()->getRequest()->getPathInfoPrefix() . '/advanced-parametered-url/value1/value2', 'advanced parametered route url'); $t->is((string) £link('@link_test_route_2')->params(array('var1' => 'value1', 'var2' => 'value2'))->text('advanced parametered route url'), $expected, 'route link is ' . $expected); $expected = sprintf('<a class="link" href="%s">%s</a>', $helper->getContext()->getRequest()->getPathInfoPrefix() . '/advanced-parametered-url/value1/value2?var3=value3', 'advanced parametered route url with extrauery string'); $t->is((string) £link('@link_test_route_2')->params(array('var1' => 'value1', 'var2' => 'value2'))->param('var3', 'value3')->text('advanced parametered route url with extrauery string'), $expected, 'route link is ' . $expected); sfConfig::set('sf_debug', true); $expected = 'The "/advanced-parametered-url/:var1/:var2" route has some missing mandatory parameters (:var1, :var2).'; $t->is((string) £link('@link_test_route_2')->text('advanced parametered route url'), $expected, 'route link is ' . $expected); sfConfig::set('sf_debug', false); $t->comment('Nofollow attribute'); $expected = '<a class="link" href="http://site.com" nofollow="1">Site</a>'; $t->is((string) £link('http://site.com')->text('Site')->set('nofollow', true), $expected, '->set("nofollow", true)'); $expected = '<a class="link nofollow" href="http://site.com" nofollow="1">Site</a>'; $t->is((string) £link('http://site.com')->text('Site')->set('.nofollow'), $expected, '->set(".nofollow")');
<?php // Vars: $articlePager echo $dmUserPager->renderNavigationTop(); echo _open('ul.elements'); foreach ($dmUserPager as $dmUser) { echo _open('li.element'); echo £link($dmUser); echo _close('li'); } echo _close('ul'); echo $dmUserPager->renderNavigationBottom();