ソースを参照

Add test for #6237

Add test to for postLink() using the data that is supplied to it.

Refs #6237
Mark Story 11 年 前
コミット
460476170c
1 ファイル変更21 行追加3 行削除
  1. 21 3
      tests/TestCase/View/Helper/FormHelperTest.php

+ 21 - 3
tests/TestCase/View/Helper/FormHelperTest.php

@@ -6141,9 +6141,6 @@ class FormHelperTest extends TestCase
         ];
         $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' => [
@@ -6177,6 +6174,27 @@ class FormHelperTest extends TestCase
     }
 
     /**
+     * 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.
      *
      * @return void