mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-19 02:56:15 +00:00
Adding some tests around invalidFields() and fieldList options.
Closes #1534
This commit is contained in:
parent
42c2f3011b
commit
63caf566fb
1 changed files with 6 additions and 5 deletions
|
@ -131,13 +131,14 @@ class ModelValidationTest extends BaseModelTest {
|
|||
$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 @@ class ModelValidationTest extends BaseModelTest {
|
|||
*/
|
||||
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 @@ class ModelValidationTest extends BaseModelTest {
|
|||
));
|
||||
|
||||
$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);
|
||||
|
|
Loading…
Add table
Reference in a new issue