|
|
@@ -1258,135 +1258,141 @@ class HtmlHelperTest extends TestCase
|
|
|
/**
|
|
|
* testGetCrumb and addCrumb method
|
|
|
*
|
|
|
+ * @group deprecated
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testBreadcrumb()
|
|
|
{
|
|
|
- $this->assertNull($this->Html->getCrumbs());
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $this->assertNull($this->Html->getCrumbs());
|
|
|
|
|
|
- $this->Html->addCrumb('First', '#first');
|
|
|
- $this->Html->addCrumb('Second', '#second');
|
|
|
- $this->Html->addCrumb('Third', '#third');
|
|
|
+ $this->Html->addCrumb('First', '#first');
|
|
|
+ $this->Html->addCrumb('Second', '#second');
|
|
|
+ $this->Html->addCrumb('Third', '#third');
|
|
|
|
|
|
- $result = $this->Html->getCrumbs();
|
|
|
- $expected = [
|
|
|
- ['a' => ['href' => '#first']],
|
|
|
- 'First',
|
|
|
- '/a',
|
|
|
- '»',
|
|
|
- ['a' => ['href' => '#second']],
|
|
|
- 'Second',
|
|
|
- '/a',
|
|
|
- '»',
|
|
|
- ['a' => ['href' => '#third']],
|
|
|
- 'Third',
|
|
|
- '/a',
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $result = $this->Html->getCrumbs();
|
|
|
+ $expected = [
|
|
|
+ ['a' => ['href' => '#first']],
|
|
|
+ 'First',
|
|
|
+ '/a',
|
|
|
+ '»',
|
|
|
+ ['a' => ['href' => '#second']],
|
|
|
+ 'Second',
|
|
|
+ '/a',
|
|
|
+ '»',
|
|
|
+ ['a' => ['href' => '#third']],
|
|
|
+ 'Third',
|
|
|
+ '/a',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
|
|
|
- $result = $this->Html->getCrumbs(' > ');
|
|
|
- $expected = [
|
|
|
- ['a' => ['href' => '#first']],
|
|
|
- 'First',
|
|
|
- '/a',
|
|
|
- ' > ',
|
|
|
- ['a' => ['href' => '#second']],
|
|
|
- 'Second',
|
|
|
- '/a',
|
|
|
- ' > ',
|
|
|
- ['a' => ['href' => '#third']],
|
|
|
- 'Third',
|
|
|
- '/a',
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $result = $this->Html->getCrumbs(' > ');
|
|
|
+ $expected = [
|
|
|
+ ['a' => ['href' => '#first']],
|
|
|
+ 'First',
|
|
|
+ '/a',
|
|
|
+ ' > ',
|
|
|
+ ['a' => ['href' => '#second']],
|
|
|
+ 'Second',
|
|
|
+ '/a',
|
|
|
+ ' > ',
|
|
|
+ ['a' => ['href' => '#third']],
|
|
|
+ 'Third',
|
|
|
+ '/a',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
|
|
|
- $this->Html->addCrumb('Fourth', null);
|
|
|
+ $this->Html->addCrumb('Fourth', null);
|
|
|
|
|
|
- $result = $this->Html->getCrumbs();
|
|
|
- $expected = [
|
|
|
- ['a' => ['href' => '#first']],
|
|
|
- 'First',
|
|
|
- '/a',
|
|
|
- '»',
|
|
|
- ['a' => ['href' => '#second']],
|
|
|
- 'Second',
|
|
|
- '/a',
|
|
|
- '»',
|
|
|
- ['a' => ['href' => '#third']],
|
|
|
- 'Third',
|
|
|
- '/a',
|
|
|
- '»',
|
|
|
- 'Fourth'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $result = $this->Html->getCrumbs();
|
|
|
+ $expected = [
|
|
|
+ ['a' => ['href' => '#first']],
|
|
|
+ 'First',
|
|
|
+ '/a',
|
|
|
+ '»',
|
|
|
+ ['a' => ['href' => '#second']],
|
|
|
+ 'Second',
|
|
|
+ '/a',
|
|
|
+ '»',
|
|
|
+ ['a' => ['href' => '#third']],
|
|
|
+ 'Third',
|
|
|
+ '/a',
|
|
|
+ '»',
|
|
|
+ 'Fourth'
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
|
|
|
- $this->Html->addCrumb('Fifth', [
|
|
|
- 'plugin' => false,
|
|
|
- 'controller' => 'controller',
|
|
|
- 'action' => 'action',
|
|
|
- ]);
|
|
|
- $result = $this->Html->getCrumbs('-', 'Start');
|
|
|
- $expected = [
|
|
|
- ['a' => ['href' => '/']],
|
|
|
- 'Start',
|
|
|
- '/a',
|
|
|
- '-',
|
|
|
- ['a' => ['href' => '#first']],
|
|
|
- 'First',
|
|
|
- '/a',
|
|
|
- '-',
|
|
|
- ['a' => ['href' => '#second']],
|
|
|
- 'Second',
|
|
|
- '/a',
|
|
|
- '-',
|
|
|
- ['a' => ['href' => '#third']],
|
|
|
- 'Third',
|
|
|
- '/a',
|
|
|
- '-',
|
|
|
- 'Fourth',
|
|
|
- '-',
|
|
|
- ['a' => ['href' => '/controller/action']],
|
|
|
- 'Fifth',
|
|
|
- '/a',
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $this->Html->addCrumb('Fifth', [
|
|
|
+ 'plugin' => false,
|
|
|
+ 'controller' => 'controller',
|
|
|
+ 'action' => 'action',
|
|
|
+ ]);
|
|
|
+ $result = $this->Html->getCrumbs('-', 'Start');
|
|
|
+ $expected = [
|
|
|
+ ['a' => ['href' => '/']],
|
|
|
+ 'Start',
|
|
|
+ '/a',
|
|
|
+ '-',
|
|
|
+ ['a' => ['href' => '#first']],
|
|
|
+ 'First',
|
|
|
+ '/a',
|
|
|
+ '-',
|
|
|
+ ['a' => ['href' => '#second']],
|
|
|
+ 'Second',
|
|
|
+ '/a',
|
|
|
+ '-',
|
|
|
+ ['a' => ['href' => '#third']],
|
|
|
+ 'Third',
|
|
|
+ '/a',
|
|
|
+ '-',
|
|
|
+ 'Fourth',
|
|
|
+ '-',
|
|
|
+ ['a' => ['href' => '/controller/action']],
|
|
|
+ 'Fifth',
|
|
|
+ '/a',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Test the array form of $startText
|
|
|
*
|
|
|
+ * @group deprecated
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testGetCrumbFirstLink()
|
|
|
{
|
|
|
- $result = $this->Html->getCrumbList([], 'Home');
|
|
|
- $expected = [
|
|
|
- '<ul',
|
|
|
- ['li' => ['class' => 'first']],
|
|
|
- ['a' => ['href' => '/']], 'Home', '/a',
|
|
|
- '/li',
|
|
|
- '/ul'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $result = $this->Html->getCrumbList([], 'Home');
|
|
|
+ $expected = [
|
|
|
+ '<ul',
|
|
|
+ ['li' => ['class' => 'first']],
|
|
|
+ ['a' => ['href' => '/']], 'Home', '/a',
|
|
|
+ '/li',
|
|
|
+ '/ul'
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
|
|
|
- $this->Html->addCrumb('First', '#first');
|
|
|
- $this->Html->addCrumb('Second', '#second');
|
|
|
+ $this->Html->addCrumb('First', '#first');
|
|
|
+ $this->Html->addCrumb('Second', '#second');
|
|
|
|
|
|
- $result = $this->Html->getCrumbs(' - ', ['url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false]);
|
|
|
- $expected = [
|
|
|
- ['a' => ['href' => '/home']],
|
|
|
- 'img' => ['src' => '/home.png'],
|
|
|
- '/a',
|
|
|
- ' - ',
|
|
|
- ['a' => ['href' => '#first']],
|
|
|
- 'First',
|
|
|
- '/a',
|
|
|
- ' - ',
|
|
|
- ['a' => ['href' => '#second']],
|
|
|
- 'Second',
|
|
|
- '/a',
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $result = $this->Html->getCrumbs(' - ', ['url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false]);
|
|
|
+ $expected = [
|
|
|
+ ['a' => ['href' => '/home']],
|
|
|
+ 'img' => ['src' => '/home.png'],
|
|
|
+ '/a',
|
|
|
+ ' - ',
|
|
|
+ ['a' => ['href' => '#first']],
|
|
|
+ 'First',
|
|
|
+ '/a',
|
|
|
+ ' - ',
|
|
|
+ ['a' => ['href' => '#second']],
|
|
|
+ 'Second',
|
|
|
+ '/a',
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -2096,140 +2102,152 @@ class HtmlHelperTest extends TestCase
|
|
|
/**
|
|
|
* testCrumbList method
|
|
|
*
|
|
|
+ * @group deprecated
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testCrumbList()
|
|
|
{
|
|
|
- $this->assertNull($this->Html->getCrumbList());
|
|
|
-
|
|
|
- $this->Html->addCrumb('Home', '/', ['class' => 'home']);
|
|
|
- $this->Html->addCrumb('Some page', '/some_page');
|
|
|
- $this->Html->addCrumb('Another page');
|
|
|
- $result = $this->Html->getCrumbList(
|
|
|
- ['class' => 'breadcrumbs']
|
|
|
- );
|
|
|
- $expected = [
|
|
|
- ['ul' => ['class' => 'breadcrumbs']],
|
|
|
- ['li' => ['class' => 'first']],
|
|
|
- ['a' => ['class' => 'home', 'href' => '/']], 'Home', '/a',
|
|
|
- '/li',
|
|
|
- '<li',
|
|
|
- ['a' => ['href' => '/some_page']], 'Some page', '/a',
|
|
|
- '/li',
|
|
|
- ['li' => ['class' => 'last']],
|
|
|
- 'Another page',
|
|
|
- '/li',
|
|
|
- '/ul'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $this->assertNull($this->Html->getCrumbList());
|
|
|
+
|
|
|
+ $this->Html->addCrumb('Home', '/', ['class' => 'home']);
|
|
|
+ $this->Html->addCrumb('Some page', '/some_page');
|
|
|
+ $this->Html->addCrumb('Another page');
|
|
|
+ $result = $this->Html->getCrumbList(
|
|
|
+ ['class' => 'breadcrumbs']
|
|
|
+ );
|
|
|
+ $expected = [
|
|
|
+ ['ul' => ['class' => 'breadcrumbs']],
|
|
|
+ ['li' => ['class' => 'first']],
|
|
|
+ ['a' => ['class' => 'home', 'href' => '/']], 'Home', '/a',
|
|
|
+ '/li',
|
|
|
+ '<li',
|
|
|
+ ['a' => ['href' => '/some_page']], 'Some page', '/a',
|
|
|
+ '/li',
|
|
|
+ ['li' => ['class' => 'last']],
|
|
|
+ 'Another page',
|
|
|
+ '/li',
|
|
|
+ '/ul'
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Test getCrumbList startText
|
|
|
*
|
|
|
+ * @group deprecated
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testCrumbListFirstLink()
|
|
|
{
|
|
|
- $this->Html->addCrumb('First', '#first');
|
|
|
- $this->Html->addCrumb('Second', '#second');
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $this->Html->addCrumb('First', '#first');
|
|
|
+ $this->Html->addCrumb('Second', '#second');
|
|
|
|
|
|
- $result = $this->Html->getCrumbList([], 'Home');
|
|
|
- $expected = [
|
|
|
- '<ul',
|
|
|
- ['li' => ['class' => 'first']],
|
|
|
- ['a' => ['href' => '/']], 'Home', '/a',
|
|
|
- '/li',
|
|
|
- '<li',
|
|
|
- ['a' => ['href' => '#first']], 'First', '/a',
|
|
|
- '/li',
|
|
|
- ['li' => ['class' => 'last']],
|
|
|
- ['a' => ['href' => '#second']], 'Second', '/a',
|
|
|
- '/li',
|
|
|
- '/ul'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $result = $this->Html->getCrumbList([], 'Home');
|
|
|
+ $expected = [
|
|
|
+ '<ul',
|
|
|
+ ['li' => ['class' => 'first']],
|
|
|
+ ['a' => ['href' => '/']], 'Home', '/a',
|
|
|
+ '/li',
|
|
|
+ '<li',
|
|
|
+ ['a' => ['href' => '#first']], 'First', '/a',
|
|
|
+ '/li',
|
|
|
+ ['li' => ['class' => 'last']],
|
|
|
+ ['a' => ['href' => '#second']], 'Second', '/a',
|
|
|
+ '/li',
|
|
|
+ '/ul'
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
|
|
|
- $result = $this->Html->getCrumbList([], ['url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false]);
|
|
|
- $expected = [
|
|
|
- '<ul',
|
|
|
- ['li' => ['class' => 'first']],
|
|
|
- ['a' => ['href' => '/home']], 'img' => ['src' => '/home.png'], '/a',
|
|
|
- '/li',
|
|
|
- '<li',
|
|
|
- ['a' => ['href' => '#first']], 'First', '/a',
|
|
|
- '/li',
|
|
|
- ['li' => ['class' => 'last']],
|
|
|
- ['a' => ['href' => '#second']], 'Second', '/a',
|
|
|
- '/li',
|
|
|
- '/ul'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $result = $this->Html->getCrumbList([], ['url' => '/home', 'text' => '<img src="/home.png" />', 'escape' => false]);
|
|
|
+ $expected = [
|
|
|
+ '<ul',
|
|
|
+ ['li' => ['class' => 'first']],
|
|
|
+ ['a' => ['href' => '/home']], 'img' => ['src' => '/home.png'], '/a',
|
|
|
+ '/li',
|
|
|
+ '<li',
|
|
|
+ ['a' => ['href' => '#first']], 'First', '/a',
|
|
|
+ '/li',
|
|
|
+ ['li' => ['class' => 'last']],
|
|
|
+ ['a' => ['href' => '#second']], 'Second', '/a',
|
|
|
+ '/li',
|
|
|
+ '/ul'
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* test getCrumbList() in Twitter Bootstrap style.
|
|
|
*
|
|
|
+ * @group deprecated
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testCrumbListBootstrapStyle()
|
|
|
{
|
|
|
- $this->Html->addCrumb('Home', '/', ['class' => 'home']);
|
|
|
- $this->Html->addCrumb('Library', '/lib');
|
|
|
- $this->Html->addCrumb('Data');
|
|
|
- $result = $this->Html->getCrumbList([
|
|
|
- 'class' => 'breadcrumb',
|
|
|
- 'separator' => '<span class="divider">-</span>',
|
|
|
- 'firstClass' => false,
|
|
|
- 'lastClass' => 'active'
|
|
|
- ]);
|
|
|
- $expected = [
|
|
|
- ['ul' => ['class' => 'breadcrumb']],
|
|
|
- '<li',
|
|
|
- ['a' => ['class' => 'home', 'href' => '/']], 'Home', '/a',
|
|
|
- ['span' => ['class' => 'divider']], '-', '/span',
|
|
|
- '/li',
|
|
|
- '<li',
|
|
|
- ['a' => ['href' => '/lib']], 'Library', '/a',
|
|
|
- ['span' => ['class' => 'divider']], '-', '/span',
|
|
|
- '/li',
|
|
|
- ['li' => ['class' => 'active']], 'Data', '/li',
|
|
|
- '/ul'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $this->Html->addCrumb('Home', '/', ['class' => 'home']);
|
|
|
+ $this->Html->addCrumb('Library', '/lib');
|
|
|
+ $this->Html->addCrumb('Data');
|
|
|
+ $result = $this->Html->getCrumbList([
|
|
|
+ 'class' => 'breadcrumb',
|
|
|
+ 'separator' => '<span class="divider">-</span>',
|
|
|
+ 'firstClass' => false,
|
|
|
+ 'lastClass' => 'active'
|
|
|
+ ]);
|
|
|
+ $expected = [
|
|
|
+ ['ul' => ['class' => 'breadcrumb']],
|
|
|
+ '<li',
|
|
|
+ ['a' => ['class' => 'home', 'href' => '/']], 'Home', '/a',
|
|
|
+ ['span' => ['class' => 'divider']], '-', '/span',
|
|
|
+ '/li',
|
|
|
+ '<li',
|
|
|
+ ['a' => ['href' => '/lib']], 'Library', '/a',
|
|
|
+ ['span' => ['class' => 'divider']], '-', '/span',
|
|
|
+ '/li',
|
|
|
+ ['li' => ['class' => 'active']], 'Data', '/li',
|
|
|
+ '/ul'
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* Test GetCrumbList using style of Zurb Foundation.
|
|
|
*
|
|
|
+ * @group deprecated
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testCrumbListZurbStyle()
|
|
|
{
|
|
|
- $this->Html->addCrumb('Home', '#');
|
|
|
- $this->Html->addCrumb('Features', '#');
|
|
|
- $this->Html->addCrumb('Gene Splicing', '#');
|
|
|
- $this->Html->addCrumb('Home', '#');
|
|
|
- $result = $this->Html->getCrumbList(
|
|
|
- ['class' => 'breadcrumbs', 'firstClass' => false, 'lastClass' => 'current']
|
|
|
- );
|
|
|
- $expected = [
|
|
|
- ['ul' => ['class' => 'breadcrumbs']],
|
|
|
- '<li',
|
|
|
- ['a' => ['href' => '#']], 'Home', '/a',
|
|
|
- '/li',
|
|
|
- '<li',
|
|
|
- ['a' => ['href' => '#']], 'Features', '/a',
|
|
|
- '/li',
|
|
|
- '<li',
|
|
|
- ['a' => ['href' => '#']], 'Gene Splicing', '/a',
|
|
|
- '/li',
|
|
|
- ['li' => ['class' => 'current']],
|
|
|
- ['a' => ['href' => '#']], 'Home', '/a',
|
|
|
- '/li',
|
|
|
- '/ul'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result, true);
|
|
|
+ $this->deprecated(function () {
|
|
|
+ $this->Html->addCrumb('Home', '#');
|
|
|
+ $this->Html->addCrumb('Features', '#');
|
|
|
+ $this->Html->addCrumb('Gene Splicing', '#');
|
|
|
+ $this->Html->addCrumb('Home', '#');
|
|
|
+ $result = $this->Html->getCrumbList(
|
|
|
+ ['class' => 'breadcrumbs', 'firstClass' => false, 'lastClass' => 'current']
|
|
|
+ );
|
|
|
+ $expected = [
|
|
|
+ ['ul' => ['class' => 'breadcrumbs']],
|
|
|
+ '<li',
|
|
|
+ ['a' => ['href' => '#']], 'Home', '/a',
|
|
|
+ '/li',
|
|
|
+ '<li',
|
|
|
+ ['a' => ['href' => '#']], 'Features', '/a',
|
|
|
+ '/li',
|
|
|
+ '<li',
|
|
|
+ ['a' => ['href' => '#']], 'Gene Splicing', '/a',
|
|
|
+ '/li',
|
|
|
+ ['li' => ['class' => 'current']],
|
|
|
+ ['a' => ['href' => '#']], 'Home', '/a',
|
|
|
+ '/li',
|
|
|
+ '/ul'
|
|
|
+ ];
|
|
|
+ $this->assertHtml($expected, $result, true);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|