Permalink
Browse files

Adding some tests around invalidFields() and fieldList options.

Closes #1534
  • Loading branch information...
1 parent 42c2f30 commit 63caf566fb82df7b4f9ddd2019773e92827637ec @markstory markstory committed Feb 13, 2011
Showing with 6 additions and 5 deletions.
  1. +6 −5 cake/tests/cases/libs/model/model_validation.test.php
View
11 cake/tests/cases/libs/model/model_validation.test.php
@@ -131,13 +131,14 @@ function testInvalidFieldsWithFieldListParams() {
$TestModel =& new ValidationTest1();
$TestModel->validate = $validate = array(
'title' => array(
- 'rule' => 'customValidator',
+ 'rule' => 'alphaNumeric',
'required' => true
),
'name' => array(
- 'rule' => 'allowEmpty',
+ 'rule' => 'alphaNumeric',
'required' => true
));
+ $TestModel->set(array('title' => '$$', 'name' => '##'));
$TestModel->invalidFields(array('fieldList' => array('title')));
$expected = array(
'title' => 'This field cannot be left blank'
@@ -175,9 +176,9 @@ function testInvalidFieldsWithFieldListParams() {
*/
function testInvalidFieldsWhitelist() {
$TestModel =& new ValidationTest1();
- $TestModel->validate = $validate = array(
+ $TestModel->validate = array(
'title' => array(
- 'rule' => 'customValidator',
+ 'rule' => 'alphaNumeric',
'required' => true
),
'name' => array(
@@ -186,7 +187,7 @@ function testInvalidFieldsWhitelist() {
));
$TestModel->whitelist = array('name');
- $TestModel->save(array('name' => '#$$#'));
+ $TestModel->save(array('name' => '#$$#', 'title' => '$$$$'));
$expected = array('name' => 'This field cannot be left blank');
$this->assertEqual($TestModel->validationErrors, $expected);

0 comments on commit 63caf56

Please sign in to comment.