|
|
@@ -6492,65 +6492,60 @@ class FormHelperTest extends TestCase
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
- $result = $this->Form->postLink('Delete', '/posts/delete/1', ['confirm' => 'Confirm?']);
|
|
|
- $expected = [
|
|
|
- 'form' => [
|
|
|
- 'method' => 'post', 'action' => '/posts/delete/1',
|
|
|
- 'name' => 'preg:/post_\w+/', 'style' => 'display:none;'
|
|
|
- ],
|
|
|
- 'input' => ['type' => 'hidden', 'name' => '_method', 'value' => 'POST'],
|
|
|
- '/form',
|
|
|
- 'a' => ['href' => '#', 'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'],
|
|
|
- 'Delete',
|
|
|
- '/a'
|
|
|
- ];
|
|
|
- $this->assertHtml($expected, $result);
|
|
|
-
|
|
|
$result = $this->Form->postLink(
|
|
|
'Delete',
|
|
|
'/posts/delete/1',
|
|
|
- ['escape' => false, 'confirm' => '\'Confirm\' this "deletion"?']
|
|
|
+ ['target' => '_blank', 'class' => 'btn btn-danger']
|
|
|
);
|
|
|
$expected = [
|
|
|
'form' => [
|
|
|
- 'method' => 'post', 'action' => '/posts/delete/1',
|
|
|
+ 'method' => 'post', 'target' => '_blank', 'action' => '/posts/delete/1',
|
|
|
'name' => 'preg:/post_\w+/', 'style' => 'display:none;'
|
|
|
],
|
|
|
'input' => ['type' => 'hidden', 'name' => '_method', 'value' => 'POST'],
|
|
|
'/form',
|
|
|
- 'a' => ['href' => '#', 'onclick' => 'preg:/if \(confirm\("'Confirm' this \\\\"deletion\\\\"\?"\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'],
|
|
|
+ 'a' => ['class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/document\.post_\w+\.submit\(\); event\.returnValue = false; return false;/'],
|
|
|
'Delete',
|
|
|
'/a'
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
+ }
|
|
|
|
|
|
- $result = $this->Form->postLink('Delete', '/posts/delete/1', ['target' => '_blank']);
|
|
|
+ /**
|
|
|
+ * Test the confirm option for postLink()
|
|
|
+ *
|
|
|
+ * @return void
|
|
|
+ */
|
|
|
+ public function testPostLinkWithConfirm()
|
|
|
+ {
|
|
|
+ $result = $this->Form->postLink('Delete', '/posts/delete/1', ['confirm' => 'Confirm?']);
|
|
|
$expected = [
|
|
|
'form' => [
|
|
|
- 'method' => 'post', 'target' => '_blank', 'action' => '/posts/delete/1',
|
|
|
+ 'method' => 'post', 'action' => '/posts/delete/1',
|
|
|
'name' => 'preg:/post_\w+/', 'style' => 'display:none;'
|
|
|
],
|
|
|
'input' => ['type' => 'hidden', 'name' => '_method', 'value' => 'POST'],
|
|
|
'/form',
|
|
|
- 'a' => ['href' => '#', 'onclick' => 'preg:/document\.post_\w+\.submit\(\); event\.returnValue = false; return false;/'],
|
|
|
+ 'a' => ['href' => '#', 'onclick' => 'preg:/if \(confirm\("Confirm\?"\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'],
|
|
|
'Delete',
|
|
|
'/a'
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|
|
|
|
|
|
$result = $this->Form->postLink(
|
|
|
- '',
|
|
|
- ['controller' => 'items', 'action' => 'delete', 10],
|
|
|
- ['class' => 'btn btn-danger', 'escape' => false, 'confirm' => 'Confirm thing']
|
|
|
+ 'Delete',
|
|
|
+ '/posts/delete/1',
|
|
|
+ ['escape' => false, 'confirm' => "'Confirm'\nthis \"deletion\"?"]
|
|
|
);
|
|
|
$expected = [
|
|
|
'form' => [
|
|
|
- 'method' => 'post', 'action' => '/items/delete/10',
|
|
|
+ 'method' => 'post', 'action' => '/posts/delete/1',
|
|
|
'name' => 'preg:/post_\w+/', 'style' => 'display:none;'
|
|
|
],
|
|
|
'input' => ['type' => 'hidden', 'name' => '_method', 'value' => 'POST'],
|
|
|
'/form',
|
|
|
- 'a' => ['class' => 'btn btn-danger', 'href' => '#', 'onclick' => 'preg:/if \(confirm\(\"\;Confirm thing\"\;\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/'],
|
|
|
+ 'a' => ['href' => '#', 'onclick' => "preg:/if \(confirm\("'Confirm'\\nthis \\\\"deletion\\\\"\?"\)\) \{ document\.post_\w+\.submit\(\); \} event\.returnValue = false; return false;/"],
|
|
|
+ 'Delete',
|
|
|
'/a'
|
|
|
];
|
|
|
$this->assertHtml($expected, $result);
|