Skip to content

Commit

Permalink
Add test for #6237
Browse files Browse the repository at this point in the history
Add test to for postLink() using the data that is supplied to it.

Refs #6237
  • Loading branch information
markstory committed Apr 1, 2015
1 parent 6662fae commit 4604761
Showing 1 changed file with 21 additions and 3 deletions.
24 changes: 21 additions & 3 deletions tests/TestCase/View/Helper/FormHelperTest.php
Expand Up @@ -6141,9 +6141,6 @@ public function testPostLink()
];
$this->assertHtml($expected, $result);

$result = $this->Form->postLink('Delete', '/posts/delete', ['data' => ['id' => 1]]);
$this->assertContains('<input type="hidden" name="id" value="1"', $result);

$result = $this->Form->postLink('Delete', '/posts/delete/1', ['target' => '_blank']);
$expected = [
'form' => [
Expand Down Expand Up @@ -6176,6 +6173,27 @@ public function testPostLink()
$this->assertHtml($expected, $result);
}

/**
* Test postLink with additional data.
*
* @return void
*/
public function testPostLinkWithData()
{
$result = $this->Form->postLink('Delete', '/posts/delete', ['data' => ['id' => 1]]);
$this->assertContains('<input type="hidden" name="id" value="1"', $result);

$entity = new Entity(['name' => 'no show'], ['source' => 'Articles']);
$this->Form->create($entity);
$this->Form->end();
$result = $this->Form->postLink('Delete', '/posts/delete', ['data' => ['name' => 'show']]);
$this->assertContains(
'<input type="hidden" name="name" value="show"',
$result,
'should not contain entity data.'
);
}

/**
* Test that security hashes for postLink include the url.
*
Expand Down

0 comments on commit 4604761

Please sign in to comment.