Skip to content

Commit

Permalink
Use assertTag for flash_helper element tests
Browse files Browse the repository at this point in the history
  • Loading branch information
bcrowe committed Jun 9, 2014
1 parent f70b72c commit ef108a7
Showing 1 changed file with 42 additions and 5 deletions.
47 changes: 42 additions & 5 deletions tests/TestCase/View/Helper/FlashHelperTest.php
Expand Up @@ -98,9 +98,27 @@ public function testFlash() {
$this->assertEquals($expected, $result);

$result = $this->Flash->render('notification');
$result = str_replace("\r\n", "\n", $result);
$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a test of the emergency broadcasting system</p>\n</div>";
$this->assertEquals($expected, $result);

$children = [
['tag' => 'h1', 'content' => 'Alert!'],
['tag' => 'h3', 'content' => 'Notice!'],
['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system']
];

$expected = [
'tag' => 'div',
'id' => 'notificationLayout',
'child' => []
];

$expected['child'] = ['tag' => 'h1', 'content' => 'Alert!'];
$this->assertTag($expected, $result);

$expected['child'] = ['tag' => 'h3', 'content' => 'Notice!'];
$this->assertTag($expected, $result);

$expected['child'] = ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system'];
$this->assertTag($expected, $result);
}

/**
Expand All @@ -124,8 +142,27 @@ public function testFlashElementInAttrs() {
'element' => 'flash_helper',
'params' => array('title' => 'Notice!', 'name' => 'Alert!')
));
$expected = "<div id=\"notificationLayout\">\n\t<h1>Alert!</h1>\n\t<h3>Notice!</h3>\n\t<p>This is a test of the emergency broadcasting system</p>\n</div>";
$this->assertTextEquals($expected, $result);

$children = [
['tag' => 'h1', 'content' => 'Alert!'],
['tag' => 'h3', 'content' => 'Notice!'],
['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system']
];

$expected = [
'tag' => 'div',
'id' => 'notificationLayout',
'child' => []
];

$expected['child'] = ['tag' => 'h1', 'content' => 'Alert!'];
$this->assertTag($expected, $result);

$expected['child'] = ['tag' => 'h3', 'content' => 'Notice!'];
$this->assertTag($expected, $result);

$expected['child'] = ['tag' => 'p', 'content' => 'This is a test of the emergency broadcasting system'];
$this->assertTag($expected, $result);
}

/**
Expand Down

0 comments on commit ef108a7

Please sign in to comment.