From b61f559030d3491f3962570fbaa9f21443edb70c Mon Sep 17 00:00:00 2001 From: nate Date: Sun, 14 Oct 2007 22:55:37 +0000 Subject: [PATCH] Adding FormHelper test for multiple select elements git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5757 3807eeeb-6ff5-0310-8944-8be069107fe0 --- .../cases/libs/view/helpers/form.test.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index 67ab89fe7..67f04e8b0 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -856,6 +856,28 @@ class FormHelperTest extends CakeTestCase { $this->assertNoPattern('/]+[^id|name|type|value]=[^<>]*>$/', $result); } + function testEditFormWithData() { + $this->Form->data = array('Person' => array( + 'id' => 1, + 'first_name' => 'Nate', + 'last_name' => 'Abele', + 'email' => 'nate@cakephp.org' + )); + $this->Form->params = array( + 'models' => array('Person'), + 'controller' => 'people' + ); + $options = array(1 => 'Nate', 2 => 'Garrett', 3 => 'Larry'); + + $this->Form->create(); + $result = $this->Form->select('People.People', $options, null, array('multiple' => true)); + $this->assertPattern('/^]+>\s*(]+>.+<\/option>\s*){3}<\/select>$/', $result); + $this->assertPattern('/^]+name="data\[People\]\[People\]\[\]"[^<>]*>/', $result); + $this->assertPattern('/^]+multiple="multiple"[^<>]*>/', $result); + $this->assertPattern('/^]+id="PeoplePeople"[^<>]*>/', $result); + $this->assertNoPattern('/]+[^id|name|multiple]=[^<>]*>$/', $result); + } + function testFormMagicInput() { $result = $this->Form->create('Contact'); $this->assertPattern('/^$/', $result);