From 5874916ccbeb15256ca41ccfefe869ff4b3456af Mon Sep 17 00:00:00 2001 From: mark_story Date: Fri, 15 Aug 2008 01:12:31 +0000 Subject: [PATCH] Adding Tests to cover 'in' when doing finds, and making multi record forms with loops. git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7468 3807eeeb-6ff5-0310-8944-8be069107fe0 --- .../libs/model/datasources/dbo_source.test.php | 3 +++ cake/tests/cases/libs/model/model.test.php | 4 +++- cake/tests/cases/libs/view/helpers/form.test.php | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/cake/tests/cases/libs/model/datasources/dbo_source.test.php b/cake/tests/cases/libs/model/datasources/dbo_source.test.php index 774aa9ae9..46f30bdb7 100644 --- a/cake/tests/cases/libs/model/datasources/dbo_source.test.php +++ b/cake/tests/cases/libs/model/datasources/dbo_source.test.php @@ -2299,6 +2299,9 @@ class DboSourceTest extends CakeTestCase { * @return void */ function testArrayConditionsParsing() { + $result = $this->testDb->conditions(array('Stereo.type' => 'in dash speakers')); + $this->assertPattern("/^\s+WHERE\s+`Stereo`.`type`\s+=\s+'in dash speakers'/", $result); + $result = $this->testDb->conditions(array('Candy.name LIKE' => 'a', 'HardCandy.name LIKE' => 'c')); $this->assertPattern("/^\s+WHERE\s+`Candy`.`name` LIKE\s+'a'\s+AND\s+`HardCandy`.`name`\s+LIKE\s+'c'/", $result); diff --git a/cake/tests/cases/libs/model/model.test.php b/cake/tests/cases/libs/model/model.test.php index 29d668181..0eee34296 100644 --- a/cake/tests/cases/libs/model/model.test.php +++ b/cake/tests/cases/libs/model/model.test.php @@ -4761,11 +4761,13 @@ class ModelTest extends CakeTestCase { $this->loadFixtures('DataTest'); $TestModel =& new DataTest(); - $TestModel->create(array()) && $TestModel->save(); + $TestModel->create(array()); + $TestModel->save(); $result = $TestModel->findById($TestModel->id); $this->assertIdentical($result['DataTest']['count'], '0'); $this->assertIdentical($result['DataTest']['float'], '0'); } + /** * testNonNumericHabtmJoinKey method * diff --git a/cake/tests/cases/libs/view/helpers/form.test.php b/cake/tests/cases/libs/view/helpers/form.test.php index e1fee85ed..75e1daa16 100644 --- a/cake/tests/cases/libs/view/helpers/form.test.php +++ b/cake/tests/cases/libs/view/helpers/form.test.php @@ -1399,6 +1399,20 @@ class FormHelperTest extends CakeTestCase { '/div' ); $this->assertTags($result, $expected); + + for ($i = 1; $i < 5; $i++) { + $result = $this->Form->input("Contact.{$i}.email", array('type' => 'checkbox', 'value' => $i)); + $expected = array( + 'div' => array('class' => 'input checkbox'), + 'input' => array('type' => 'hidden', 'name' => "data[Contact][{$i}][email]", 'value' => '0', 'id' => "Contact{$i}Email_"), + array('input' => array('type' => 'checkbox', 'name' => "data[Contact][{$i}][email]", 'value' => $i, 'id' => "Contact{$i}Email")), + 'label' => array('for' => "Contact{$i}Email"), + 'Email', + '/label', + '/div' + ); + $this->assertTags($result, $expected); + } } /** * testFormInputs method