Adding tests for getCrumbs

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5632 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-09-13 23:19:48 +00:00
parent 7ba8247a53
commit 2e2f20ab82
2 changed files with 28 additions and 3 deletions

View file

@ -799,9 +799,6 @@ class FormHelperTest extends CakeTestCase {
$this->assertPattern('/^<form\s+id="ContactAddForm"\s+method="post"\s+action="\/contacts\/add\/"\s*>$/', $result);
$this->assertNoPattern('/^<form[^<>]+[^id|method|action]=[^<>]*>/', $result);
/*
* This is how you write tests for tag-based output.
*/
$result = $this->Form->input('name');
$this->assertPattern('/^<div[^<>]+><label[^<>]+>Name<\/label><input [^<>]+ \/><\/div>$/', $result);
$this->assertPattern('/^<div[^<>]+class="input">/', $result);

View file

@ -71,7 +71,35 @@ class HtmlHelperTest extends UnitTestCase {
$result = $this->Html->style(array('display'=> 'none', 'margin'=>'10px'), false);
$expected = "display:none;\nmargin:10px;";
$this->assertEqual($expected, $result);
}
function testBreadcrumb() {
$this->Html->addCrumb('First', '#first');
$this->Html->addCrumb('Second', '#second');
$this->Html->addCrumb('Third', '#third');
$result = $this->Html->getCrumbs();
$this->assertPattern('/^<a[^<>]+>First<\/a>&raquo;<a[^<>]+>Second<\/a>&raquo;<a[^<>]+>Third<\/a>$/', $result);
$this->assertPattern('/<a\s+href=["\']+\#first["\']+[^<>]*>First<\/a>/', $result);
$this->assertPattern('/<a\s+href=["\']+\#second["\']+[^<>]*>Second<\/a>/', $result);
$this->assertPattern('/<a\s+href=["\']+\#third["\']+[^<>]*>Third<\/a>/', $result);
$this->assertNoPattern('/<a[^<>]+[^href]=[^<>]*>/', $result);
$result = $this->Html->getCrumbs(' &gt; ');
$this->assertPattern('/^<a[^<>]+>First<\/a> &gt; <a[^<>]+>Second<\/a> &gt; <a[^<>]+>Third<\/a>$/', $result);
$this->assertPattern('/<a\s+href=["\']+\#first["\']+[^<>]*>First<\/a>/', $result);
$this->assertPattern('/<a\s+href=["\']+\#second["\']+[^<>]*>Second<\/a>/', $result);
$this->assertPattern('/<a\s+href=["\']+\#third["\']+[^<>]*>Third<\/a>/', $result);
$this->assertNoPattern('/<a[^<>]+[^href]=[^<>]*>/', $result);
$this->Html->addCrumb('Fourth', null);
$result = $this->Html->getCrumbs();
$this->assertPattern('/^<a[^<>]+>First<\/a>&raquo;<a[^<>]+>Second<\/a>&raquo;<a[^<>]+>Third<\/a>&raquo;Fourth$/', $result);
$this->assertPattern('/<a\s+href=["\']+\#first["\']+[^<>]*>First<\/a>/', $result);
$this->assertPattern('/<a\s+href=["\']+\#second["\']+[^<>]*>Second<\/a>/', $result);
$this->assertPattern('/<a\s+href=["\']+\#third["\']+[^<>]*>Third<\/a>/', $result);
$this->assertNoPattern('/<a[^<>]+[^href]=[^<>]*>/', $result);
}
function tearDown() {