mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Adjust bake, docblocks and tests for notBlank.
This commit is contained in:
parent
866242643f
commit
4f3602ad5f
14 changed files with 182 additions and 182 deletions
|
@ -443,9 +443,9 @@ class ModelTask extends BakeTask {
|
||||||
} elseif ($metaData['type'] === 'string' && $metaData['length'] == 36) {
|
} elseif ($metaData['type'] === 'string' && $metaData['length'] == 36) {
|
||||||
$guess = $methods['uuid'];
|
$guess = $methods['uuid'];
|
||||||
} elseif ($metaData['type'] === 'string') {
|
} elseif ($metaData['type'] === 'string') {
|
||||||
$guess = $methods['notEmpty'];
|
$guess = $methods['notBlank'];
|
||||||
} elseif ($metaData['type'] === 'text') {
|
} elseif ($metaData['type'] === 'text') {
|
||||||
$guess = $methods['notEmpty'];
|
$guess = $methods['notBlank'];
|
||||||
} elseif ($metaData['type'] === 'integer') {
|
} elseif ($metaData['type'] === 'integer') {
|
||||||
$guess = $methods['numeric'];
|
$guess = $methods['numeric'];
|
||||||
} elseif ($metaData['type'] === 'float') {
|
} elseif ($metaData['type'] === 'float') {
|
||||||
|
|
|
@ -134,7 +134,7 @@ class Model extends Object implements CakeEventListener {
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* public $validate = array(
|
* public $validate = array(
|
||||||
* 'name' => 'notEmpty'
|
* 'name' => 'notBlank'
|
||||||
* );
|
* );
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
|
|
@ -537,7 +537,7 @@ class ModelValidator implements ArrayAccess, IteratorAggregate, Countable {
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* $validator
|
* $validator
|
||||||
* ->add('title', 'required', array('rule' => 'notEmpty', 'required' => true))
|
* ->add('title', 'required', array('rule' => 'notBlank', 'required' => true))
|
||||||
* ->add('user_id', 'valid', array('rule' => 'numeric', 'message' => 'Invalid User'))
|
* ->add('user_id', 'valid', array('rule' => 'numeric', 'message' => 'Invalid User'))
|
||||||
*
|
*
|
||||||
* $validator->add('password', array(
|
* $validator->add('password', array(
|
||||||
|
|
|
@ -185,7 +185,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* $set
|
* $set
|
||||||
* ->setRule('required', array('rule' => 'notEmpty', 'required' => true))
|
* ->setRule('required', array('rule' => 'notBlank', 'required' => true))
|
||||||
* ->setRule('between', array('rule' => array('lengthBetween', 4, 10))
|
* ->setRule('between', array('rule' => array('lengthBetween', 4, 10))
|
||||||
* ```
|
* ```
|
||||||
*
|
*
|
||||||
|
@ -227,7 +227,7 @@ class CakeValidationSet implements ArrayAccess, IteratorAggregate, Countable {
|
||||||
*
|
*
|
||||||
* ```
|
* ```
|
||||||
* $set->setRules(array(
|
* $set->setRules(array(
|
||||||
* 'required' => array('rule' => 'notEmpty', 'required' => true),
|
* 'required' => array('rule' => 'notBlank', 'required' => true),
|
||||||
* 'inRange' => array('rule' => array('between', 4, 10)
|
* 'inRange' => array('rule' => array('between', 4, 10)
|
||||||
* ));
|
* ));
|
||||||
* ```
|
* ```
|
||||||
|
|
|
@ -268,7 +268,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testInitValidations() {
|
public function testInitValidations() {
|
||||||
$result = $this->Task->initValidations();
|
$result = $this->Task->initValidations();
|
||||||
$this->assertTrue(in_array('notEmpty', $result));
|
$this->assertTrue(in_array('notBlank', $result));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -282,7 +282,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$this->Task->initValidations();
|
$this->Task->initValidations();
|
||||||
|
|
||||||
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
||||||
$expected = array('notEmpty' => 'notEmpty');
|
$expected = array('notBlank' => 'notBlank');
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false));
|
$result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false));
|
||||||
|
@ -318,7 +318,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
->will($this->onConsecutiveCalls('25', 'y', '19', 'n'));
|
->will($this->onConsecutiveCalls('25', 'y', '19', 'n'));
|
||||||
|
|
||||||
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
||||||
$expected = array('notEmpty' => 'notEmpty', 'maxLength' => 'maxLength');
|
$expected = array('notBlank' => 'notBlank', 'maxLength' => 'maxLength');
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -339,7 +339,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
->with($this->stringContains('make a valid'));
|
->with($this->stringContains('make a valid'));
|
||||||
|
|
||||||
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
||||||
$expected = array('notEmpty' => 'notEmpty');
|
$expected = array('notBlank' => 'notBlank');
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -371,7 +371,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
->will($this->onConsecutiveCalls('25', 'y', 's'));
|
->will($this->onConsecutiveCalls('25', 'y', 's'));
|
||||||
|
|
||||||
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
||||||
$expected = array('notEmpty' => 'notEmpty', '_skipFields' => true);
|
$expected = array('notBlank' => 'notBlank', '_skipFields' => true);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -387,7 +387,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
->will($this->onConsecutiveCalls('25', 's'));
|
->will($this->onConsecutiveCalls('25', 's'));
|
||||||
|
|
||||||
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
||||||
$expected = array('notEmpty' => 'notEmpty', '_skipFields' => true);
|
$expected = array('notBlank' => 'notBlank', '_skipFields' => true);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -444,7 +444,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$result = $this->Task->doValidation($Model);
|
$result = $this->Task->doValidation($Model);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'name' => array(
|
'name' => array(
|
||||||
'notEmpty' => 'notEmpty'
|
'notBlank' => 'notBlank'
|
||||||
),
|
),
|
||||||
'email' => array(
|
'email' => array(
|
||||||
'email' => 'email',
|
'email' => 'email',
|
||||||
|
@ -502,7 +502,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$result = $this->Task->doValidation($Model);
|
$result = $this->Task->doValidation($Model);
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'name' => array(
|
'name' => array(
|
||||||
'notEmpty' => 'notEmpty'
|
'notBlank' => 'notBlank'
|
||||||
),
|
),
|
||||||
'email' => array(
|
'email' => array(
|
||||||
'email' => 'email',
|
'email' => 'email',
|
||||||
|
@ -838,7 +838,7 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
public function testBakeValidation() {
|
public function testBakeValidation() {
|
||||||
$validate = array(
|
$validate = array(
|
||||||
'name' => array(
|
'name' => array(
|
||||||
'notempty' => 'notEmpty'
|
'notBlank' => 'notBlank'
|
||||||
),
|
),
|
||||||
'email' => array(
|
'email' => array(
|
||||||
'email' => 'email',
|
'email' => 'email',
|
||||||
|
@ -855,8 +855,8 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$this->assertRegExp('/\$validate \= array\(/', $result);
|
$this->assertRegExp('/\$validate \= array\(/', $result);
|
||||||
$expected = <<< STRINGEND
|
$expected = <<< STRINGEND
|
||||||
array(
|
array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => array('notEmpty'),
|
'rule' => array('notBlank'),
|
||||||
//'message' => 'Your custom message here',
|
//'message' => 'Your custom message here',
|
||||||
//'allowEmpty' => false,
|
//'allowEmpty' => false,
|
||||||
//'required' => false,
|
//'required' => false,
|
||||||
|
|
|
@ -1106,7 +1106,7 @@ class ControllerTest extends CakeTestCase {
|
||||||
$TestController = new TestController();
|
$TestController = new TestController();
|
||||||
|
|
||||||
$Post = new ControllerPost();
|
$Post = new ControllerPost();
|
||||||
$Post->validate = array('title' => 'notEmpty');
|
$Post->validate = array('title' => 'notBlank');
|
||||||
$Post->set('title', '');
|
$Post->set('title', '');
|
||||||
$result = $TestController->validateErrors($Post);
|
$result = $TestController->validateErrors($Post);
|
||||||
|
|
||||||
|
|
|
@ -942,7 +942,7 @@ class TranslateBehaviorTest extends CakeTestCase {
|
||||||
|
|
||||||
$TestModel = new TranslatedItem();
|
$TestModel = new TranslatedItem();
|
||||||
$TestModel->locale = 'eng';
|
$TestModel->locale = 'eng';
|
||||||
$TestModel->validate['title'] = 'notEmpty';
|
$TestModel->validate['title'] = 'notBlank';
|
||||||
$data = array('TranslatedItem' => array(
|
$data = array('TranslatedItem' => array(
|
||||||
'id' => 1,
|
'id' => 1,
|
||||||
'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'),
|
'title' => array('eng' => 'New Title #1', 'deu' => 'Neue Titel #1', 'cze' => 'Novy Titulek #1'),
|
||||||
|
|
|
@ -210,8 +210,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$TestModel->validate = array(
|
$TestModel->validate = array(
|
||||||
'user_id' => 'numeric',
|
'user_id' => 'numeric',
|
||||||
'title' => array('allowEmpty' => false, 'rule' => 'notEmpty'),
|
'title' => array('allowEmpty' => false, 'rule' => 'notBlank'),
|
||||||
'body' => 'notEmpty'
|
'body' => 'notBlank'
|
||||||
);
|
);
|
||||||
|
|
||||||
$data = array('TestValidate' => array(
|
$data = array('TestValidate' => array(
|
||||||
|
@ -380,7 +380,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
),
|
),
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'allowEmpty' => false,
|
'allowEmpty' => false,
|
||||||
'rule' => 'notEmpty'
|
'rule' => 'notBlank'
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = array('TestValidate' => array(
|
$data = array('TestValidate' => array(
|
||||||
|
@ -427,7 +427,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
),
|
),
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'allowEmpty' => false,
|
'allowEmpty' => false,
|
||||||
'rule' => 'notEmpty'
|
'rule' => 'notBlank'
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = array('TestValidate' => array(
|
$data = array('TestValidate' => array(
|
||||||
|
@ -577,7 +577,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$Something = new Something();
|
$Something = new Something();
|
||||||
$JoinThing = $Something->JoinThing;
|
$JoinThing = $Something->JoinThing;
|
||||||
|
|
||||||
$JoinThing->validate = array('doomed' => array('rule' => 'notEmpty'));
|
$JoinThing->validate = array('doomed' => array('rule' => 'notBlank'));
|
||||||
|
|
||||||
$expectedError = array('doomed' => array('This field cannot be left blank'));
|
$expectedError = array('doomed' => array('This field cannot be left blank'));
|
||||||
|
|
||||||
|
@ -620,10 +620,10 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$TestModel = new ValidationTest1();
|
$TestModel = new ValidationTest1();
|
||||||
$TestModel->validate = array(
|
$TestModel->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
),
|
),
|
||||||
'name' => array(
|
'name' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
));
|
));
|
||||||
$TestModel->Behaviors->attach('ValidationRule', array('fields' => array('name')));
|
$TestModel->Behaviors->attach('ValidationRule', array('fields' => array('name')));
|
||||||
|
|
||||||
|
@ -659,7 +659,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$Something = new Something();
|
$Something = new Something();
|
||||||
$JoinThing = $Something->JoinThing;
|
$JoinThing = $Something->JoinThing;
|
||||||
|
|
||||||
$JoinThing->validate = array('doomed' => array('rule' => 'notEmpty'));
|
$JoinThing->validate = array('doomed' => array('rule' => 'notBlank'));
|
||||||
$expectedError = array('doomed' => array('This field cannot be left blank'));
|
$expectedError = array('doomed' => array('This field cannot be left blank'));
|
||||||
|
|
||||||
$Something->create();
|
$Something->create();
|
||||||
|
@ -850,8 +850,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'on' => 'create'
|
'on' => 'create'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -868,8 +868,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
unset($data['Article']['id']);
|
unset($data['Article']['id']);
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'on' => 'update'
|
'on' => 'update'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -903,8 +903,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'create'
|
'required' => 'create'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -921,8 +921,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
unset($data['Article']['id']);
|
unset($data['Article']['id']);
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'update'
|
'required' => 'update'
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -956,8 +956,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'create',
|
'required' => 'create',
|
||||||
'on' => 'create'
|
'on' => 'create'
|
||||||
)
|
)
|
||||||
|
@ -969,8 +969,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'update',
|
'required' => 'update',
|
||||||
'on' => 'create'
|
'on' => 'create'
|
||||||
)
|
)
|
||||||
|
@ -982,8 +982,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'create',
|
'required' => 'create',
|
||||||
'on' => 'update'
|
'on' => 'update'
|
||||||
)
|
)
|
||||||
|
@ -995,8 +995,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'update',
|
'required' => 'update',
|
||||||
'on' => 'update'
|
'on' => 'update'
|
||||||
)
|
)
|
||||||
|
@ -1008,8 +1008,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'create',
|
'required' => 'create',
|
||||||
'on' => 'create'
|
'on' => 'create'
|
||||||
)
|
)
|
||||||
|
@ -1023,8 +1023,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'update',
|
'required' => 'update',
|
||||||
'on' => 'create'
|
'on' => 'create'
|
||||||
)
|
)
|
||||||
|
@ -1036,8 +1036,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'create',
|
'required' => 'create',
|
||||||
'on' => 'update'
|
'on' => 'update'
|
||||||
)
|
)
|
||||||
|
@ -1049,8 +1049,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$Article->validate = array(
|
$Article->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => 'update',
|
'required' => 'update',
|
||||||
'on' => 'update'
|
'on' => 'update'
|
||||||
)
|
)
|
||||||
|
@ -1072,8 +1072,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
||||||
$TestModel->hasAndBelongsToMany = array();
|
$TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty';
|
$TestModel->Comment->Attachment->validate['attachment'] = 'notBlank';
|
||||||
$TestModel->Comment->validate['comment'] = 'notEmpty';
|
$TestModel->Comment->validate['comment'] = 'notBlank';
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'Article' => array('id' => 2),
|
'Article' => array('id' => 2),
|
||||||
|
@ -1400,8 +1400,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
||||||
$TestModel->hasAndBelongsToMany = array();
|
$TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty';
|
$TestModel->Comment->Attachment->validate['attachment'] = 'notBlank';
|
||||||
$TestModel->Comment->validate['comment'] = 'notEmpty';
|
$TestModel->Comment->validate['comment'] = 'notBlank';
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'Article' => array('id' => 2, 'body' => ''),
|
'Article' => array('id' => 2, 'body' => ''),
|
||||||
|
@ -1550,7 +1550,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
public function testValidateAssociated() {
|
public function testValidateAssociated() {
|
||||||
$this->loadFixtures('Comment', 'Attachment', 'Article', 'User');
|
$this->loadFixtures('Comment', 'Attachment', 'Article', 'User');
|
||||||
$TestModel = new Comment();
|
$TestModel = new Comment();
|
||||||
$TestModel->Attachment->validate = array('attachment' => 'notEmpty');
|
$TestModel->Attachment->validate = array('attachment' => 'notBlank');
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'Comment' => array(
|
'Comment' => array(
|
||||||
|
@ -1577,7 +1577,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$this->assertTrue($result);
|
$this->assertTrue($result);
|
||||||
$this->assertEmpty($TestModel->validationErrors);
|
$this->assertEmpty($TestModel->validationErrors);
|
||||||
|
|
||||||
$TestModel->validate = array('comment' => 'notEmpty');
|
$TestModel->validate = array('comment' => 'notBlank');
|
||||||
$record = array(
|
$record = array(
|
||||||
'Comment' => array(
|
'Comment' => array(
|
||||||
'user_id' => 1,
|
'user_id' => 1,
|
||||||
|
@ -1608,7 +1608,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->validate = array('comment' => 'notEmpty');
|
$TestModel->Comment->validate = array('comment' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
'Article' => array('id' => 2),
|
'Article' => array('id' => 2),
|
||||||
'Comment' => array(
|
'Comment' => array(
|
||||||
|
@ -1653,8 +1653,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
|
|
||||||
$model = new Comment();
|
$model = new Comment();
|
||||||
$model->deleteAll(true);
|
$model->deleteAll(true);
|
||||||
$model->validate = array('comment' => 'notEmpty');
|
$model->validate = array('comment' => 'notBlank');
|
||||||
$model->Attachment->validate = array('attachment' => 'notEmpty');
|
$model->Attachment->validate = array('attachment' => 'notBlank');
|
||||||
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
|
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'comment' => array('This field cannot be left blank'),
|
'comment' => array('This field cannot be left blank'),
|
||||||
|
@ -1682,7 +1682,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
*/
|
*/
|
||||||
public function testValidateMany() {
|
public function testValidateMany() {
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->validate = array('title' => 'notEmpty');
|
$TestModel->validate = array('title' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
0 => array('title' => ''),
|
0 => array('title' => ''),
|
||||||
1 => array('title' => 'title 1'),
|
1 => array('title' => 'title 1'),
|
||||||
|
@ -1803,13 +1803,13 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$this->assertEquals('title', $titleValidator->field);
|
$this->assertEquals('title', $titleValidator->field);
|
||||||
$this->assertCount(1, $titleValidator->getRules());
|
$this->assertCount(1, $titleValidator->getRules());
|
||||||
$rule = current($titleValidator->getRules());
|
$rule = current($titleValidator->getRules());
|
||||||
$this->assertEquals('notEmpty', $rule->rule);
|
$this->assertEquals('notBlank', $rule->rule);
|
||||||
|
|
||||||
$titleValidator = $Validator['body'];
|
$titleValidator = $Validator['body'];
|
||||||
$this->assertEquals('body', $titleValidator->field);
|
$this->assertEquals('body', $titleValidator->field);
|
||||||
$this->assertCount(1, $titleValidator->getRules());
|
$this->assertCount(1, $titleValidator->getRules());
|
||||||
$rule = current($titleValidator->getRules());
|
$rule = current($titleValidator->getRules());
|
||||||
$this->assertEquals('notEmpty', $rule->rule);
|
$this->assertEquals('notBlank', $rule->rule);
|
||||||
|
|
||||||
$titleValidator = $Validator['user_id'];
|
$titleValidator = $Validator['user_id'];
|
||||||
$this->assertEquals('user_id', $titleValidator->field);
|
$this->assertEquals('user_id', $titleValidator->field);
|
||||||
|
@ -1996,8 +1996,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$model = new CustomArticle();
|
$model = new CustomArticle();
|
||||||
$model->validate = array(
|
$model->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => true,
|
'required' => true,
|
||||||
'allowEmpty' => false
|
'allowEmpty' => false
|
||||||
)
|
)
|
||||||
|
@ -2050,8 +2050,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$model = new CustomArticle();
|
$model = new CustomArticle();
|
||||||
$model->validate = array(
|
$model->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => true
|
'required' => true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -2203,8 +2203,8 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$model = new CustomArticle();
|
$model = new CustomArticle();
|
||||||
$model->validate = array(
|
$model->validate = array(
|
||||||
'title' => array(
|
'title' => array(
|
||||||
'notempty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => true
|
'required' => true
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
|
@ -2294,7 +2294,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Comment', 'Article', 'User', 'Attachment');
|
$this->loadFixtures('Comment', 'Article', 'User', 'Attachment');
|
||||||
$Attachment = ClassRegistry::init('Attachment');
|
$Attachment = ClassRegistry::init('Attachment');
|
||||||
$Attachment->Comment->validator()->add('comment', array(
|
$Attachment->Comment->validator()->add('comment', array(
|
||||||
array('rule' => 'notEmpty')
|
array('rule' => 'notBlank')
|
||||||
));
|
));
|
||||||
$Attachment->Comment->User->bindModel(array(
|
$Attachment->Comment->User->bindModel(array(
|
||||||
'hasMany' => array(
|
'hasMany' => array(
|
||||||
|
@ -2353,7 +2353,7 @@ class ModelValidationTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Comment', 'Article', 'User');
|
$this->loadFixtures('Comment', 'Article', 'User');
|
||||||
$Article = ClassRegistry::init('Article');
|
$Article = ClassRegistry::init('Article');
|
||||||
$Article->Comment->validator()->add('comment', array(
|
$Article->Comment->validator()->add('comment', array(
|
||||||
array('rule' => 'notEmpty')
|
array('rule' => 'notBlank')
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
|
|
|
@ -879,7 +879,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
// Check if Database supports transactions
|
// Check if Database supports transactions
|
||||||
|
|
||||||
$PostModel->validate = array('title' => 'notEmpty');
|
$PostModel->validate = array('title' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
||||||
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
||||||
|
@ -3413,8 +3413,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$model->Attachment->deleteAll(true);
|
$model->Attachment->deleteAll(true);
|
||||||
$this->assertEquals(array(), $model->Attachment->find('all'));
|
$this->assertEquals(array(), $model->Attachment->find('all'));
|
||||||
|
|
||||||
$model->validate = array('comment' => 'notEmpty');
|
$model->validate = array('comment' => 'notBlank');
|
||||||
$model->Attachment->validate = array('attachment' => 'notEmpty');
|
$model->Attachment->validate = array('attachment' => 'notBlank');
|
||||||
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
|
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
|
||||||
|
|
||||||
$result = $model->saveAll(
|
$result = $model->saveAll(
|
||||||
|
@ -3496,7 +3496,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->assertSame($result, array('Article' => true, 'Comment' => array(true, true)));
|
$this->assertSame($result, array('Article' => true, 'Comment' => array(true, true)));
|
||||||
|
|
||||||
$TestModel->validate = array(
|
$TestModel->validate = array(
|
||||||
'title' => 'notEmpty',
|
'title' => 'notBlank',
|
||||||
'author_id' => 'numeric'
|
'author_id' => 'numeric'
|
||||||
);
|
);
|
||||||
$result = $TestModel->saveAll(array(
|
$result = $TestModel->saveAll(array(
|
||||||
|
@ -3701,7 +3701,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$TestModel->Comment->validate['comment'] = 'notEmpty';
|
$TestModel->Comment->validate['comment'] = 'notBlank';
|
||||||
$result = $TestModel->saveAll($data, array('deep' => true));
|
$result = $TestModel->saveAll($data, array('deep' => true));
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
@ -3744,8 +3744,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
||||||
$TestModel->hasAndBelongsToMany = array();
|
$TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty';
|
$TestModel->Comment->Attachment->validate['attachment'] = 'notBlank';
|
||||||
$TestModel->Comment->validate['comment'] = 'notEmpty';
|
$TestModel->Comment->validate['comment'] = 'notBlank';
|
||||||
|
|
||||||
$result = $TestModel->saveAll(
|
$result = $TestModel->saveAll(
|
||||||
array(
|
array(
|
||||||
|
@ -4155,7 +4155,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
);
|
);
|
||||||
$TestModel->Comment->validate['comment'] = 'notEmpty';
|
$TestModel->Comment->validate['comment'] = 'notBlank';
|
||||||
$result = $TestModel->saveAll($data, array('deep' => false));
|
$result = $TestModel->saveAll($data, array('deep' => false));
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
|
@ -4195,8 +4195,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
$TestModel->hasMany['Comment']['order'] = array('Comment.created' => 'ASC');
|
||||||
$TestModel->hasAndBelongsToMany = array();
|
$TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->Attachment->validate['attachment'] = 'notEmpty';
|
$TestModel->Comment->Attachment->validate['attachment'] = 'notBlank';
|
||||||
$TestModel->Comment->validate['comment'] = 'notEmpty';
|
$TestModel->Comment->validate['comment'] = 'notBlank';
|
||||||
|
|
||||||
$result = $TestModel->saveAll(
|
$result = $TestModel->saveAll(
|
||||||
array(
|
array(
|
||||||
|
@ -4416,7 +4416,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Article', 'Comment');
|
$this->loadFixtures('Article', 'Comment');
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->validate = array('comment' => 'notEmpty');
|
$TestModel->Comment->validate = array('comment' => 'notBlank');
|
||||||
|
|
||||||
$result = $TestModel->saveAll(array(
|
$result = $TestModel->saveAll(array(
|
||||||
'Article' => array('id' => 2),
|
'Article' => array('id' => 2),
|
||||||
|
@ -4457,7 +4457,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
$Post = new TestPost();
|
$Post = new TestPost();
|
||||||
$Post->validate = array(
|
$Post->validate = array(
|
||||||
'title' => array('rule' => array('notEmpty'))
|
'title' => array('rule' => array('notBlank'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// If validation error occurs, rollback() should be called.
|
// If validation error occurs, rollback() should be called.
|
||||||
|
@ -4518,7 +4518,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
$Post = new TestPost();
|
$Post = new TestPost();
|
||||||
$Post->Author->validate = array(
|
$Post->Author->validate = array(
|
||||||
'user' => array('rule' => array('notEmpty'))
|
'user' => array('rule' => array('notBlank'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// If validation error occurs, rollback() should be called.
|
// If validation error occurs, rollback() should be called.
|
||||||
|
@ -4618,7 +4618,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Post', 'Author', 'Comment', 'Attachment');
|
$this->loadFixtures('Post', 'Author', 'Comment', 'Attachment');
|
||||||
$TestModel = new Post();
|
$TestModel = new Post();
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty');
|
$TestModel->validate = array('title' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
||||||
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
||||||
|
@ -4750,7 +4750,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
}
|
}
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty');
|
$TestModel->validate = array('title' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
||||||
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
||||||
|
@ -4878,7 +4878,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric');
|
$TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric');
|
||||||
$data = array(
|
$data = array(
|
||||||
array(
|
array(
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
|
@ -4904,7 +4904,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
$this->assertEquals($errors, $TestModel->validationErrors);
|
$this->assertEquals($errors, $TestModel->validationErrors);
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric');
|
$TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric');
|
||||||
$data = array(
|
$data = array(
|
||||||
array(
|
array(
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
|
@ -5006,7 +5006,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
public function testSaveAllValidationOnly() {
|
public function testSaveAllValidationOnly() {
|
||||||
$this->loadFixtures('Comment', 'Attachment');
|
$this->loadFixtures('Comment', 'Attachment');
|
||||||
$TestModel = new Comment();
|
$TestModel = new Comment();
|
||||||
$TestModel->Attachment->validate = array('attachment' => 'notEmpty');
|
$TestModel->Attachment->validate = array('attachment' => 'notBlank');
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'Comment' => array(
|
'Comment' => array(
|
||||||
|
@ -5021,7 +5021,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->assertFalse($result);
|
$this->assertFalse($result);
|
||||||
|
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->validate = array('title' => 'notEmpty');
|
$TestModel->validate = array('title' => 'notBlank');
|
||||||
$result = $TestModel->saveAll(
|
$result = $TestModel->saveAll(
|
||||||
array(
|
array(
|
||||||
0 => array('title' => ''),
|
0 => array('title' => ''),
|
||||||
|
@ -5061,7 +5061,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$model = new Article();
|
$model = new Article();
|
||||||
$model->deleteAll(true);
|
$model->deleteAll(true);
|
||||||
|
|
||||||
$model->Comment->validate = array('comment' => 'notEmpty');
|
$model->Comment->validate = array('comment' => 'notBlank');
|
||||||
$result = $model->saveAll(array(
|
$result = $model->saveAll(array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'title' => 'Post with Author',
|
'title' => 'Post with Author',
|
||||||
|
@ -5198,7 +5198,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Article', 'Comment', 'Attachment');
|
$this->loadFixtures('Article', 'Comment', 'Attachment');
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->validate = array('comment' => 'notEmpty');
|
$TestModel->Comment->validate = array('comment' => 'notBlank');
|
||||||
|
|
||||||
$result = $TestModel->saveAll(
|
$result = $TestModel->saveAll(
|
||||||
array(
|
array(
|
||||||
|
@ -5406,7 +5406,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Comment', 'Article', 'User');
|
$this->loadFixtures('Comment', 'Article', 'User');
|
||||||
$Article = ClassRegistry::init('Article');
|
$Article = ClassRegistry::init('Article');
|
||||||
$Article->Comment->validator()->add('comment', array(
|
$Article->Comment->validator()->add('comment', array(
|
||||||
array('rule' => 'notEmpty')
|
array('rule' => 'notBlank')
|
||||||
));
|
));
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
|
@ -5694,8 +5694,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$model->Attachment->deleteAll(true);
|
$model->Attachment->deleteAll(true);
|
||||||
$this->assertEquals(array(), $model->Attachment->find('all'));
|
$this->assertEquals(array(), $model->Attachment->find('all'));
|
||||||
|
|
||||||
$model->validate = array('comment' => 'notEmpty');
|
$model->validate = array('comment' => 'notBlank');
|
||||||
$model->Attachment->validate = array('attachment' => 'notEmpty');
|
$model->Attachment->validate = array('attachment' => 'notBlank');
|
||||||
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
|
$model->Attachment->bindModel(array('belongsTo' => array('Comment')));
|
||||||
|
|
||||||
$result = $model->saveAssociated(
|
$result = $model->saveAssociated(
|
||||||
|
@ -5789,7 +5789,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
), array('atomic' => false));
|
), array('atomic' => false));
|
||||||
$this->assertSame($result, array(true, true, true));
|
$this->assertSame($result, array(true, true, true));
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric');
|
$TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric');
|
||||||
$result = $TestModel->saveMany(array(
|
$result = $TestModel->saveMany(array(
|
||||||
array(
|
array(
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
|
@ -5892,7 +5892,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Article', 'Comment');
|
$this->loadFixtures('Article', 'Comment');
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->validate = $TestModel->Comment->validate = array('user_id' => array('notEmpty' => array('rule' => 'notEmpty', 'required' => true)));
|
$TestModel->validate = $TestModel->Comment->validate = array('user_id' => array('notBlank' => array('rule' => 'notBlank', 'required' => true)));
|
||||||
|
|
||||||
//empty hasMany data is ignored in save
|
//empty hasMany data is ignored in save
|
||||||
$result = $TestModel->saveAssociated(array(
|
$result = $TestModel->saveAssociated(array(
|
||||||
|
@ -5924,7 +5924,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Article', 'Comment');
|
$this->loadFixtures('Article', 'Comment');
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->validate = array('comment' => 'notEmpty');
|
$TestModel->Comment->validate = array('comment' => 'notBlank');
|
||||||
|
|
||||||
$result = $TestModel->saveAssociated(array(
|
$result = $TestModel->saveAssociated(array(
|
||||||
'Article' => array('id' => 2),
|
'Article' => array('id' => 2),
|
||||||
|
@ -5965,7 +5965,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
$Post = new TestPost();
|
$Post = new TestPost();
|
||||||
$Post->validate = array(
|
$Post->validate = array(
|
||||||
'title' => array('rule' => array('notEmpty'))
|
'title' => array('rule' => array('notBlank'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// If validation error occurs, rollback() should be called.
|
// If validation error occurs, rollback() should be called.
|
||||||
|
@ -6026,7 +6026,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
$Post = new TestPost();
|
$Post = new TestPost();
|
||||||
$Post->Author->validate = array(
|
$Post->Author->validate = array(
|
||||||
'user' => array('rule' => array('notEmpty'))
|
'user' => array('rule' => array('notBlank'))
|
||||||
);
|
);
|
||||||
|
|
||||||
// If validation error occurs, rollback() should be called.
|
// If validation error occurs, rollback() should be called.
|
||||||
|
@ -6126,7 +6126,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Post', 'Author', 'Comment', 'Attachment');
|
$this->loadFixtures('Post', 'Author', 'Comment', 'Attachment');
|
||||||
$TestModel = new Post();
|
$TestModel = new Post();
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty');
|
$TestModel->validate = array('title' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
||||||
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
||||||
|
@ -6262,7 +6262,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
}
|
}
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty');
|
$TestModel->validate = array('title' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
array('author_id' => 1, 'title' => 'New Fourth Post'),
|
||||||
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
array('author_id' => 1, 'title' => 'New Fifth Post'),
|
||||||
|
@ -6395,7 +6395,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
unset($result[3]['Post']['created'], $result[3]['Post']['updated']);
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric');
|
$TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric');
|
||||||
$data = array(
|
$data = array(
|
||||||
array(
|
array(
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
|
@ -6421,7 +6421,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
$this->assertEquals($errors, $TestModel->validationErrors);
|
$this->assertEquals($errors, $TestModel->validationErrors);
|
||||||
|
|
||||||
$TestModel->validate = array('title' => 'notEmpty', 'author_id' => 'numeric');
|
$TestModel->validate = array('title' => 'notBlank', 'author_id' => 'numeric');
|
||||||
$data = array(
|
$data = array(
|
||||||
array(
|
array(
|
||||||
'id' => '1',
|
'id' => '1',
|
||||||
|
@ -6509,7 +6509,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
*/
|
*/
|
||||||
public function testValidateMany() {
|
public function testValidateMany() {
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->validate = array('title' => 'notEmpty');
|
$TestModel->validate = array('title' => 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
0 => array('title' => ''),
|
0 => array('title' => ''),
|
||||||
1 => array('title' => 'title 1'),
|
1 => array('title' => 'title 1'),
|
||||||
|
@ -6545,7 +6545,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$model = new Article();
|
$model = new Article();
|
||||||
$model->deleteAll(true);
|
$model->deleteAll(true);
|
||||||
|
|
||||||
$model->Comment->validate = array('comment' => 'notEmpty');
|
$model->Comment->validate = array('comment' => 'notBlank');
|
||||||
$result = $model->saveAssociated(array(
|
$result = $model->saveAssociated(array(
|
||||||
'Article' => array(
|
'Article' => array(
|
||||||
'title' => 'Post with Author',
|
'title' => 'Post with Author',
|
||||||
|
@ -6680,7 +6680,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
public function testValidateAssociated() {
|
public function testValidateAssociated() {
|
||||||
$this->loadFixtures('Attachment', 'Article', 'Comment');
|
$this->loadFixtures('Attachment', 'Article', 'Comment');
|
||||||
$TestModel = new Comment();
|
$TestModel = new Comment();
|
||||||
$TestModel->Attachment->validate = array('attachment' => 'notEmpty');
|
$TestModel->Attachment->validate = array('attachment' => 'notBlank');
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'Comment' => array(
|
'Comment' => array(
|
||||||
|
@ -6696,7 +6696,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
|
|
||||||
$TestModel = new Article();
|
$TestModel = new Article();
|
||||||
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
$TestModel->belongsTo = $TestModel->hasAndBelongsToMany = array();
|
||||||
$TestModel->Comment->validate = array('comment' => 'notEmpty');
|
$TestModel->Comment->validate = array('comment' => 'notBlank');
|
||||||
|
|
||||||
$data = array(
|
$data = array(
|
||||||
'Article' => array('id' => 2),
|
'Article' => array('id' => 2),
|
||||||
|
@ -7331,8 +7331,8 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('Attachment', 'Comment', 'Article', 'User');
|
$this->loadFixtures('Attachment', 'Comment', 'Article', 'User');
|
||||||
$TestModel = new Comment();
|
$TestModel = new Comment();
|
||||||
|
|
||||||
$TestModel->validate = array('comment' => 'notEmpty');
|
$TestModel->validate = array('comment' => 'notBlank');
|
||||||
$TestModel->Attachment->validate = array('attachment' => 'notEmpty');
|
$TestModel->Attachment->validate = array('attachment' => 'notBlank');
|
||||||
|
|
||||||
$record = array(
|
$record = array(
|
||||||
'Comment' => array(
|
'Comment' => array(
|
||||||
|
@ -7367,7 +7367,7 @@ class ModelWriteTest extends BaseModelTest {
|
||||||
$this->loadFixtures('ArticleFeatured', 'Featured');
|
$this->loadFixtures('ArticleFeatured', 'Featured');
|
||||||
$Article = new ArticleFeatured();
|
$Article = new ArticleFeatured();
|
||||||
$Article->belongsTo = $Article->hasMany = array();
|
$Article->belongsTo = $Article->hasMany = array();
|
||||||
$Article->Featured->validate = array('end_date' => 'notEmpty');
|
$Article->Featured->validate = array('end_date' => 'notBlank');
|
||||||
|
|
||||||
$record = array(
|
$record = array(
|
||||||
'ArticleFeatured' => array(
|
'ArticleFeatured' => array(
|
||||||
|
|
|
@ -58,7 +58,7 @@ class CakeValidationRuleTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testIsValid() {
|
public function testIsValid() {
|
||||||
$def = array('rule' => 'notEmpty', 'message' => 'Can not be empty');
|
$def = array('rule' => 'notBlank', 'message' => 'Can not be empty');
|
||||||
$data = array(
|
$data = array(
|
||||||
'fieldName' => ''
|
'fieldName' => ''
|
||||||
);
|
);
|
||||||
|
@ -122,19 +122,19 @@ class CakeValidationRuleTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testIsRequired() {
|
public function testIsRequired() {
|
||||||
$def = array('rule' => 'notEmpty', 'required' => true);
|
$def = array('rule' => 'notBlank', 'required' => true);
|
||||||
$Rule = new CakeValidationRule($def);
|
$Rule = new CakeValidationRule($def);
|
||||||
$this->assertTrue($Rule->isRequired());
|
$this->assertTrue($Rule->isRequired());
|
||||||
|
|
||||||
$def = array('rule' => 'notEmpty', 'required' => false);
|
$def = array('rule' => 'notBlank', 'required' => false);
|
||||||
$Rule = new CakeValidationRule($def);
|
$Rule = new CakeValidationRule($def);
|
||||||
$this->assertFalse($Rule->isRequired());
|
$this->assertFalse($Rule->isRequired());
|
||||||
|
|
||||||
$def = array('rule' => 'notEmpty', 'required' => 'create');
|
$def = array('rule' => 'notBlank', 'required' => 'create');
|
||||||
$Rule = new CakeValidationRule($def);
|
$Rule = new CakeValidationRule($def);
|
||||||
$this->assertTrue($Rule->isRequired());
|
$this->assertTrue($Rule->isRequired());
|
||||||
|
|
||||||
$def = array('rule' => 'notEmpty', 'required' => 'update');
|
$def = array('rule' => 'notBlank', 'required' => 'update');
|
||||||
$Rule = new CakeValidationRule($def);
|
$Rule = new CakeValidationRule($def);
|
||||||
$this->assertFalse($Rule->isRequired());
|
$this->assertFalse($Rule->isRequired());
|
||||||
|
|
||||||
|
@ -156,14 +156,14 @@ class CakeValidationRuleTest extends CakeTestCase {
|
||||||
$Rule = new CakeValidationRule($def);
|
$Rule = new CakeValidationRule($def);
|
||||||
$this->assertFalse($Rule->isEmptyAllowed());
|
$this->assertFalse($Rule->isEmptyAllowed());
|
||||||
|
|
||||||
$def = array('rule' => 'notEmpty', 'allowEmpty' => false, 'on' => 'update');
|
$def = array('rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'update');
|
||||||
$Rule = new CakeValidationRule($def);
|
$Rule = new CakeValidationRule($def);
|
||||||
$this->assertTrue($Rule->isEmptyAllowed());
|
$this->assertTrue($Rule->isEmptyAllowed());
|
||||||
|
|
||||||
$Rule->isUpdate(true);
|
$Rule->isUpdate(true);
|
||||||
$this->assertFalse($Rule->isEmptyAllowed());
|
$this->assertFalse($Rule->isEmptyAllowed());
|
||||||
|
|
||||||
$def = array('rule' => 'notEmpty', 'allowEmpty' => false, 'on' => 'create');
|
$def = array('rule' => 'notBlank', 'allowEmpty' => false, 'on' => 'create');
|
||||||
$Rule = new CakeValidationRule($def);
|
$Rule = new CakeValidationRule($def);
|
||||||
$this->assertFalse($Rule->isEmptyAllowed());
|
$this->assertFalse($Rule->isEmptyAllowed());
|
||||||
|
|
||||||
|
|
|
@ -41,7 +41,7 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testValidate() {
|
public function testValidate() {
|
||||||
$Field = new CakeValidationSet('title', 'notEmpty');
|
$Field = new CakeValidationSet('title', 'notBlank');
|
||||||
$data = array(
|
$data = array(
|
||||||
'title' => '',
|
'title' => '',
|
||||||
'body' => 'a body'
|
'body' => 'a body'
|
||||||
|
@ -51,20 +51,20 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
$expected = array('This field cannot be left blank');
|
$expected = array('This field cannot be left blank');
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$Field = new CakeValidationSet('body', 'notEmpty');
|
$Field = new CakeValidationSet('body', 'notBlank');
|
||||||
|
|
||||||
$result = $Field->validate($data);
|
$result = $Field->validate($data);
|
||||||
$this->assertEmpty($result);
|
$this->assertEmpty($result);
|
||||||
|
|
||||||
$Field = new CakeValidationSet('nothere', array(
|
$Field = new CakeValidationSet('nothere', array(
|
||||||
'notEmpty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'required' => true
|
'required' => true
|
||||||
)
|
)
|
||||||
));
|
));
|
||||||
|
|
||||||
$result = $Field->validate($data);
|
$result = $Field->validate($data);
|
||||||
$expected = array('notEmpty');
|
$expected = array('notBlank');
|
||||||
$this->assertEquals($expected, $result);
|
$this->assertEquals($expected, $result);
|
||||||
|
|
||||||
$Field = new CakeValidationSet('body', array(
|
$Field = new CakeValidationSet('body', array(
|
||||||
|
@ -83,11 +83,11 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetRule() {
|
public function testGetRule() {
|
||||||
$rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
|
$rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty'));
|
||||||
$Field = new CakeValidationSet('title', $rules);
|
$Field = new CakeValidationSet('title', $rules);
|
||||||
$result = $Field->getRule('notEmpty');
|
$result = $Field->getRule('notBlank');
|
||||||
$this->assertInstanceOf('CakeValidationRule', $result);
|
$this->assertInstanceOf('CakeValidationRule', $result);
|
||||||
$this->assertEquals('notEmpty', $result->rule);
|
$this->assertEquals('notBlank', $result->rule);
|
||||||
$this->assertEquals(null, $result->required);
|
$this->assertEquals(null, $result->required);
|
||||||
$this->assertEquals(false, $result->allowEmpty);
|
$this->assertEquals(false, $result->allowEmpty);
|
||||||
$this->assertEquals(null, $result->on);
|
$this->assertEquals(null, $result->on);
|
||||||
|
@ -101,12 +101,12 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testGetRules() {
|
public function testGetRules() {
|
||||||
$rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
|
$rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty'));
|
||||||
$Field = new CakeValidationSet('title', $rules);
|
$Field = new CakeValidationSet('title', $rules);
|
||||||
|
|
||||||
$result = $Field->getRules();
|
$result = $Field->getRules();
|
||||||
$this->assertEquals(array('notEmpty'), array_keys($result));
|
$this->assertEquals(array('notBlank'), array_keys($result));
|
||||||
$this->assertInstanceOf('CakeValidationRule', $result['notEmpty']);
|
$this->assertInstanceOf('CakeValidationRule', $result['notBlank']);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -115,23 +115,23 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetRule() {
|
public function testSetRule() {
|
||||||
$rules = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
|
$rules = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty'));
|
||||||
$Field = new CakeValidationSet('title', $rules);
|
$Field = new CakeValidationSet('title', $rules);
|
||||||
$Rule = new CakeValidationRule($rules['notEmpty']);
|
$Rule = new CakeValidationRule($rules['notBlank']);
|
||||||
|
|
||||||
$this->assertEquals($Rule, $Field->getRule('notEmpty'));
|
$this->assertEquals($Rule, $Field->getRule('notBlank'));
|
||||||
|
|
||||||
$rules = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email'));
|
$rules = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email'));
|
||||||
$Rule = new CakeValidationRule($rules['validEmail']);
|
$Rule = new CakeValidationRule($rules['validEmail']);
|
||||||
$Field->setRule('validEmail', $Rule);
|
$Field->setRule('validEmail', $Rule);
|
||||||
$result = $Field->getRules();
|
$result = $Field->getRules();
|
||||||
$this->assertEquals(array('notEmpty', 'validEmail'), array_keys($result));
|
$this->assertEquals(array('notBlank', 'validEmail'), array_keys($result));
|
||||||
|
|
||||||
$rules = array('validEmail' => array('rule' => 'email', 'message' => 'Other message'));
|
$rules = array('validEmail' => array('rule' => 'email', 'message' => 'Other message'));
|
||||||
$Rule = new CakeValidationRule($rules['validEmail']);
|
$Rule = new CakeValidationRule($rules['validEmail']);
|
||||||
$Field->setRule('validEmail', $Rule);
|
$Field->setRule('validEmail', $Rule);
|
||||||
$result = $Field->getRules();
|
$result = $Field->getRules();
|
||||||
$this->assertEquals(array('notEmpty', 'validEmail'), array_keys($result));
|
$this->assertEquals(array('notBlank', 'validEmail'), array_keys($result));
|
||||||
$result = $Field->getRule('validEmail');
|
$result = $Field->getRule('validEmail');
|
||||||
$this->assertInstanceOf('CakeValidationRule', $result);
|
$this->assertInstanceOf('CakeValidationRule', $result);
|
||||||
$this->assertEquals('email', $result->rule);
|
$this->assertEquals('email', $result->rule);
|
||||||
|
@ -148,9 +148,9 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testSetRules() {
|
public function testSetRules() {
|
||||||
$rule = array('notEmpty' => array('rule' => 'notEmpty', 'message' => 'Can not be empty'));
|
$rule = array('notBlank' => array('rule' => 'notBlank', 'message' => 'Can not be empty'));
|
||||||
$Field = new CakeValidationSet('title', $rule);
|
$Field = new CakeValidationSet('title', $rule);
|
||||||
$RuleEmpty = new CakeValidationRule($rule['notEmpty']);
|
$RuleEmpty = new CakeValidationRule($rule['notBlank']);
|
||||||
|
|
||||||
$rule = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email'));
|
$rule = array('validEmail' => array('rule' => 'email', 'message' => 'Invalid email'));
|
||||||
$RuleEmail = new CakeValidationRule($rule['validEmail']);
|
$RuleEmail = new CakeValidationRule($rule['validEmail']);
|
||||||
|
@ -165,15 +165,15 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
$this->assertEquals(array('validEmail'), array_keys($result));
|
$this->assertEquals(array('validEmail'), array_keys($result));
|
||||||
$this->assertTrue(array_pop($result) instanceof CakeValidationRule);
|
$this->assertTrue(array_pop($result) instanceof CakeValidationRule);
|
||||||
|
|
||||||
$rules = array('notEmpty' => $RuleEmpty);
|
$rules = array('notBlank' => $RuleEmpty);
|
||||||
$Field->setRules($rules, true);
|
$Field->setRules($rules, true);
|
||||||
$result = $Field->getRules();
|
$result = $Field->getRules();
|
||||||
$this->assertEquals(array('validEmail', 'notEmpty'), array_keys($result));
|
$this->assertEquals(array('validEmail', 'notBlank'), array_keys($result));
|
||||||
|
|
||||||
$rules = array('notEmpty' => array('rule' => 'notEmpty'));
|
$rules = array('notBlank' => array('rule' => 'notBlank'));
|
||||||
$Field->setRules($rules, true);
|
$Field->setRules($rules, true);
|
||||||
$result = $Field->getRules();
|
$result = $Field->getRules();
|
||||||
$this->assertEquals(array('validEmail', 'notEmpty'), array_keys($result));
|
$this->assertEquals(array('validEmail', 'notBlank'), array_keys($result));
|
||||||
$this->assertTrue(array_pop($result) instanceof CakeValidationRule);
|
$this->assertTrue(array_pop($result) instanceof CakeValidationRule);
|
||||||
$this->assertTrue(array_pop($result) instanceof CakeValidationRule);
|
$this->assertTrue(array_pop($result) instanceof CakeValidationRule);
|
||||||
}
|
}
|
||||||
|
@ -185,14 +185,14 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testArrayAccessGet() {
|
public function testArrayAccessGet() {
|
||||||
$Set = new CakeValidationSet('title', array(
|
$Set = new CakeValidationSet('title', array(
|
||||||
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
|
'notBlank' => array('rule' => 'notBlank', 'required' => true),
|
||||||
'numeric' => array('rule' => 'numeric'),
|
'numeric' => array('rule' => 'numeric'),
|
||||||
'other' => array('rule' => array('other', 1)),
|
'other' => array('rule' => array('other', 1)),
|
||||||
));
|
));
|
||||||
|
|
||||||
$rule = $Set['notEmpty'];
|
$rule = $Set['notBlank'];
|
||||||
$this->assertInstanceOf('CakeValidationRule', $rule);
|
$this->assertInstanceOf('CakeValidationRule', $rule);
|
||||||
$this->assertEquals('notEmpty', $rule->rule);
|
$this->assertEquals('notBlank', $rule->rule);
|
||||||
|
|
||||||
$rule = $Set['numeric'];
|
$rule = $Set['numeric'];
|
||||||
$this->assertInstanceOf('CakeValidationRule', $rule);
|
$this->assertInstanceOf('CakeValidationRule', $rule);
|
||||||
|
@ -210,12 +210,12 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testArrayAccessExists() {
|
public function testArrayAccessExists() {
|
||||||
$Set = new CakeValidationSet('title', array(
|
$Set = new CakeValidationSet('title', array(
|
||||||
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
|
'notBlank' => array('rule' => 'notBlank', 'required' => true),
|
||||||
'numeric' => array('rule' => 'numeric'),
|
'numeric' => array('rule' => 'numeric'),
|
||||||
'other' => array('rule' => array('other', 1)),
|
'other' => array('rule' => array('other', 1)),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertTrue(isset($Set['notEmpty']));
|
$this->assertTrue(isset($Set['notBlank']));
|
||||||
$this->assertTrue(isset($Set['numeric']));
|
$this->assertTrue(isset($Set['numeric']));
|
||||||
$this->assertTrue(isset($Set['other']));
|
$this->assertTrue(isset($Set['other']));
|
||||||
$this->assertFalse(isset($Set['fail']));
|
$this->assertFalse(isset($Set['fail']));
|
||||||
|
@ -228,7 +228,7 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testArrayAccessSet() {
|
public function testArrayAccessSet() {
|
||||||
$Set = new CakeValidationSet('title', array(
|
$Set = new CakeValidationSet('title', array(
|
||||||
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
|
'notBlank' => array('rule' => 'notBlank', 'required' => true),
|
||||||
));
|
));
|
||||||
|
|
||||||
$this->assertFalse(isset($Set['other']));
|
$this->assertFalse(isset($Set['other']));
|
||||||
|
@ -251,19 +251,19 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testArrayAccessUnset() {
|
public function testArrayAccessUnset() {
|
||||||
$Set = new CakeValidationSet('title', array(
|
$Set = new CakeValidationSet('title', array(
|
||||||
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
|
'notBlank' => array('rule' => 'notBlank', 'required' => true),
|
||||||
'numeric' => array('rule' => 'numeric'),
|
'numeric' => array('rule' => 'numeric'),
|
||||||
'other' => array('rule' => array('other', 1)),
|
'other' => array('rule' => array('other', 1)),
|
||||||
));
|
));
|
||||||
|
|
||||||
unset($Set['notEmpty']);
|
unset($Set['notBlank']);
|
||||||
$this->assertFalse(isset($Set['notEmpty']));
|
$this->assertFalse(isset($Set['notBlank']));
|
||||||
|
|
||||||
unset($Set['numeric']);
|
unset($Set['numeric']);
|
||||||
$this->assertFalse(isset($Set['notEmpty']));
|
$this->assertFalse(isset($Set['notBlank']));
|
||||||
|
|
||||||
unset($Set['other']);
|
unset($Set['other']);
|
||||||
$this->assertFalse(isset($Set['notEmpty']));
|
$this->assertFalse(isset($Set['notBlank']));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -273,7 +273,7 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testIterator() {
|
public function testIterator() {
|
||||||
$Set = new CakeValidationSet('title', array(
|
$Set = new CakeValidationSet('title', array(
|
||||||
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
|
'notBlank' => array('rule' => 'notBlank', 'required' => true),
|
||||||
'numeric' => array('rule' => 'numeric'),
|
'numeric' => array('rule' => 'numeric'),
|
||||||
'other' => array('rule' => array('other', 1)),
|
'other' => array('rule' => array('other', 1)),
|
||||||
));
|
));
|
||||||
|
@ -281,7 +281,7 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
$i = 0;
|
$i = 0;
|
||||||
foreach ($Set as $name => $rule) {
|
foreach ($Set as $name => $rule) {
|
||||||
if ($i === 0) {
|
if ($i === 0) {
|
||||||
$this->assertEquals('notEmpty', $name);
|
$this->assertEquals('notBlank', $name);
|
||||||
}
|
}
|
||||||
if ($i === 1) {
|
if ($i === 1) {
|
||||||
$this->assertEquals('numeric', $name);
|
$this->assertEquals('numeric', $name);
|
||||||
|
@ -302,7 +302,7 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testCount() {
|
public function testCount() {
|
||||||
$Set = new CakeValidationSet('title', array(
|
$Set = new CakeValidationSet('title', array(
|
||||||
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
|
'notBlank' => array('rule' => 'notBlank', 'required' => true),
|
||||||
'numeric' => array('rule' => 'numeric'),
|
'numeric' => array('rule' => 'numeric'),
|
||||||
'other' => array('rule' => array('other', 1)),
|
'other' => array('rule' => array('other', 1)),
|
||||||
));
|
));
|
||||||
|
@ -319,13 +319,13 @@ class CakeValidationSetTest extends CakeTestCase {
|
||||||
*/
|
*/
|
||||||
public function testRemoveRule() {
|
public function testRemoveRule() {
|
||||||
$Set = new CakeValidationSet('title', array(
|
$Set = new CakeValidationSet('title', array(
|
||||||
'notEmpty' => array('rule' => 'notEmpty', 'required' => true),
|
'notBlank' => array('rule' => 'notBlank', 'required' => true),
|
||||||
'numeric' => array('rule' => 'numeric'),
|
'numeric' => array('rule' => 'numeric'),
|
||||||
'other' => array('rule' => array('other', 1)),
|
'other' => array('rule' => array('other', 1)),
|
||||||
));
|
));
|
||||||
|
|
||||||
$Set->removeRule('notEmpty');
|
$Set->removeRule('notBlank');
|
||||||
$this->assertFalse(isset($Set['notEmpty']));
|
$this->assertFalse(isset($Set['notBlank']));
|
||||||
|
|
||||||
$Set->removeRule('numeric');
|
$Set->removeRule('numeric');
|
||||||
$this->assertFalse(isset($Set['numeric']));
|
$this->assertFalse(isset($Set['numeric']));
|
||||||
|
|
|
@ -208,7 +208,7 @@ class User extends CakeTestModel {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array('user' => 'notEmpty', 'password' => 'notEmpty');
|
public $validate = array('user' => 'notBlank', 'password' => 'notBlank');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* beforeFind() callback used to run ContainableBehaviorTest::testLazyLoad()
|
* beforeFind() callback used to run ContainableBehaviorTest::testLazyLoad()
|
||||||
|
@ -269,8 +269,8 @@ class Article extends CakeTestModel {
|
||||||
*/
|
*/
|
||||||
public $validate = array(
|
public $validate = array(
|
||||||
'user_id' => 'numeric',
|
'user_id' => 'numeric',
|
||||||
'title' => array('required' => false, 'rule' => 'notEmpty'),
|
'title' => array('required' => false, 'rule' => 'notBlank'),
|
||||||
'body' => array('required' => false, 'rule' => 'notEmpty'),
|
'body' => array('required' => false, 'rule' => 'notBlank'),
|
||||||
);
|
);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -424,7 +424,7 @@ class ArticleFeatured extends CakeTestModel {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array('user_id' => 'numeric', 'title' => 'notEmpty', 'body' => 'notEmpty');
|
public $validate = array('user_id' => 'numeric', 'title' => 'notBlank', 'body' => 'notBlank');
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -802,7 +802,7 @@ class Apple extends CakeTestModel {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array('name' => 'notEmpty');
|
public $validate = array('name' => 'notBlank');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* hasOne property
|
* hasOne property
|
||||||
|
@ -1197,7 +1197,7 @@ class NodeAfterFind extends CakeTestModel {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array('name' => 'notEmpty');
|
public $validate = array('name' => 'notBlank');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* useTable property
|
* useTable property
|
||||||
|
@ -1287,7 +1287,7 @@ class NodeNoAfterFind extends CakeTestModel {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array('name' => 'notEmpty');
|
public $validate = array('name' => 'notBlank');
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* useTable property
|
* useTable property
|
||||||
|
@ -2191,10 +2191,10 @@ class ValidationTest1 extends CakeTestModel {
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array(
|
public $validate = array(
|
||||||
'title' => 'notEmpty',
|
'title' => 'notBlank',
|
||||||
'published' => 'customValidationMethod',
|
'published' => 'customValidationMethod',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'notEmpty',
|
'notBlank',
|
||||||
'/^.{5,}$/s' => 'no matchy',
|
'/^.{5,}$/s' => 'no matchy',
|
||||||
'/^[0-9A-Za-z \\.]{1,}$/s'
|
'/^[0-9A-Za-z \\.]{1,}$/s'
|
||||||
)
|
)
|
||||||
|
@ -2270,10 +2270,10 @@ class ValidationTest2 extends CakeTestModel {
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array(
|
public $validate = array(
|
||||||
'title' => 'notEmpty',
|
'title' => 'notBlank',
|
||||||
'published' => 'customValidationMethod',
|
'published' => 'customValidationMethod',
|
||||||
'body' => array(
|
'body' => array(
|
||||||
'notEmpty',
|
'notBlank',
|
||||||
'/^.{5,}$/s' => 'no matchy',
|
'/^.{5,}$/s' => 'no matchy',
|
||||||
'/^[0-9A-Za-z \\.]{1,}$/s'
|
'/^[0-9A-Za-z \\.]{1,}$/s'
|
||||||
)
|
)
|
||||||
|
@ -2394,7 +2394,7 @@ class Story extends CakeTestModel {
|
||||||
*
|
*
|
||||||
* @var array
|
* @var array
|
||||||
*/
|
*/
|
||||||
public $validate = array('title' => 'notEmpty');
|
public $validate = array('title' => 'notBlank');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -81,15 +81,15 @@ class Contact extends CakeTestModel {
|
||||||
'non_existing' => array(),
|
'non_existing' => array(),
|
||||||
'idontexist' => array(),
|
'idontexist' => array(),
|
||||||
'imrequired' => array('rule' => array('between', 5, 30), 'allowEmpty' => false),
|
'imrequired' => array('rule' => array('between', 5, 30), 'allowEmpty' => false),
|
||||||
'imrequiredonupdate' => array('notEmpty' => array('rule' => 'alphaNumeric', 'on' => 'update')),
|
'imrequiredonupdate' => array('notBlank' => array('rule' => 'alphaNumeric', 'on' => 'update')),
|
||||||
'imrequiredoncreate' => array('required' => array('rule' => 'alphaNumeric', 'on' => 'create')),
|
'imrequiredoncreate' => array('required' => array('rule' => 'alphaNumeric', 'on' => 'create')),
|
||||||
'imrequiredonboth' => array(
|
'imrequiredonboth' => array(
|
||||||
'required' => array('rule' => 'alphaNumeric'),
|
'required' => array('rule' => 'alphaNumeric'),
|
||||||
),
|
),
|
||||||
'string_required' => 'notEmpty',
|
'string_required' => 'notBlank',
|
||||||
'imalsorequired' => array('rule' => 'alphaNumeric', 'allowEmpty' => false),
|
'imalsorequired' => array('rule' => 'alphaNumeric', 'allowEmpty' => false),
|
||||||
'imrequiredtoo' => array('rule' => 'notEmpty'),
|
'imrequiredtoo' => array('rule' => 'notBlank'),
|
||||||
'required_one' => array('required' => array('rule' => array('notEmpty'))),
|
'required_one' => array('required' => array('rule' => array('notBlank'))),
|
||||||
'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true),
|
'imnotrequired' => array('required' => false, 'rule' => 'alphaNumeric', 'allowEmpty' => true),
|
||||||
'imalsonotrequired' => array(
|
'imalsonotrequired' => array(
|
||||||
'alpha' => array('rule' => 'alphaNumeric', 'allowEmpty' => true),
|
'alpha' => array('rule' => 'alphaNumeric', 'allowEmpty' => true),
|
||||||
|
@ -3623,9 +3623,9 @@ class FormHelperTest extends CakeTestCase {
|
||||||
);
|
);
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
$Contact->validationErrors['field'] = array('notEmpty', 'email', 'Something else');
|
$Contact->validationErrors['field'] = array('notBlank', 'email', 'Something else');
|
||||||
$result = $this->Form->error('Contact.field', array(
|
$result = $this->Form->error('Contact.field', array(
|
||||||
'notEmpty' => 'Cannot be empty',
|
'notBlank' => 'Cannot be empty',
|
||||||
'email' => 'No good!'
|
'email' => 'No good!'
|
||||||
));
|
));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
|
@ -3640,13 +3640,13 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$this->assertTags($result, $expected);
|
$this->assertTags($result, $expected);
|
||||||
|
|
||||||
// Testing error messages list options
|
// Testing error messages list options
|
||||||
$Contact->validationErrors['field'] = array('notEmpty', 'email');
|
$Contact->validationErrors['field'] = array('notBlank', 'email');
|
||||||
|
|
||||||
$result = $this->Form->error('Contact.field', null, array('listOptions' => 'ol'));
|
$result = $this->Form->error('Contact.field', null, array('listOptions' => 'ol'));
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'div' => array('class' => 'error-message'),
|
'div' => array('class' => 'error-message'),
|
||||||
'ol' => array(),
|
'ol' => array(),
|
||||||
'<li', 'notEmpty', '/li',
|
'<li', 'notBlank', '/li',
|
||||||
'<li', 'email', '/li',
|
'<li', 'email', '/li',
|
||||||
'/ol',
|
'/ol',
|
||||||
'/div'
|
'/div'
|
||||||
|
@ -3657,7 +3657,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'div' => array('class' => 'error-message'),
|
'div' => array('class' => 'error-message'),
|
||||||
'ol' => array(),
|
'ol' => array(),
|
||||||
'<li', 'notEmpty', '/li',
|
'<li', 'notBlank', '/li',
|
||||||
'<li', 'email', '/li',
|
'<li', 'email', '/li',
|
||||||
'/ol',
|
'/ol',
|
||||||
'/div'
|
'/div'
|
||||||
|
@ -3675,7 +3675,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
$expected = array(
|
$expected = array(
|
||||||
'div' => array('class' => 'error-message'),
|
'div' => array('class' => 'error-message'),
|
||||||
'ul' => array('class' => 'ul-class'),
|
'ul' => array('class' => 'ul-class'),
|
||||||
array('li' => array('class' => 'li-class')), 'notEmpty', '/li',
|
array('li' => array('class' => 'li-class')), 'notBlank', '/li',
|
||||||
array('li' => array('class' => 'li-class')), 'email', '/li',
|
array('li' => array('class' => 'li-class')), 'email', '/li',
|
||||||
'/ul',
|
'/ul',
|
||||||
'/div'
|
'/div'
|
||||||
|
@ -9070,7 +9070,7 @@ class FormHelperTest extends CakeTestCase {
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function testFormInputRequiredDetectionModelValidator() {
|
public function testFormInputRequiredDetectionModelValidator() {
|
||||||
ClassRegistry::getObject('ContactTag')->validator()->add('iwillberequired', 'required', array('rule' => 'notEmpty'));
|
ClassRegistry::getObject('ContactTag')->validator()->add('iwillberequired', 'required', array('rule' => 'notBlank'));
|
||||||
|
|
||||||
$this->Form->create('ContactTag');
|
$this->Form->create('ContactTag');
|
||||||
$result = $this->Form->input('ContactTag.iwillberequired');
|
$result = $this->Form->input('ContactTag.iwillberequired');
|
||||||
|
|
|
@ -29,8 +29,8 @@ class TestPluginAuthors extends TestPluginAppModel {
|
||||||
|
|
||||||
public $validate = array(
|
public $validate = array(
|
||||||
'field' => array(
|
'field' => array(
|
||||||
'notEmpty' => array(
|
'notBlank' => array(
|
||||||
'rule' => 'notEmpty',
|
'rule' => 'notBlank',
|
||||||
'message' => 'I can haz plugin model validation message',
|
'message' => 'I can haz plugin model validation message',
|
||||||
),
|
),
|
||||||
),
|
),
|
||||||
|
|
Loading…
Reference in a new issue