|
|
@@ -23,16 +23,16 @@ class ConfirmableBehaviorTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testBasicValidation() {
|
|
|
- $this->Animals = TableRegistry::get('SluggedArticles');
|
|
|
- $this->Animals->addBehavior('Tools.Confirmable');
|
|
|
+ $this->Articles = TableRegistry::get('SluggedArticles');
|
|
|
+ $this->Articles->addBehavior('Tools.Confirmable');
|
|
|
|
|
|
- $animal = $this->Animals->newEntity();
|
|
|
+ $animal = $this->Articles->newEntity();
|
|
|
|
|
|
$data = array(
|
|
|
'name' => 'FooBar',
|
|
|
'confirm' => '0'
|
|
|
);
|
|
|
- $animal = $this->Animals->patchEntity($animal, $data);
|
|
|
+ $animal = $this->Articles->patchEntity($animal, $data);
|
|
|
$this->assertNotEmpty($animal->errors());
|
|
|
$this->assertSame(array('confirm' => array('notEmpty' => __d('tools', 'Please confirm the checkbox'))), $animal->errors());
|
|
|
|
|
|
@@ -40,7 +40,7 @@ class ConfirmableBehaviorTest extends TestCase {
|
|
|
'name' => 'FooBar',
|
|
|
'confirm' => '1'
|
|
|
);
|
|
|
- $animal = $this->Animals->patchEntity($animal, $data);
|
|
|
+ $animal = $this->Articles->patchEntity($animal, $data);
|
|
|
$this->assertEmpty($animal->errors());
|
|
|
}
|
|
|
|
|
|
@@ -50,9 +50,9 @@ class ConfirmableBehaviorTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testValidationThatHasBeenModifiedBefore() {
|
|
|
- $this->Animals = TableRegistry::get('SluggedArticles');
|
|
|
+ $this->Articles = TableRegistry::get('SluggedArticles');
|
|
|
/*
|
|
|
- $this->Animals->validator()->add('confirm', 'notEmpty', [
|
|
|
+ $this->Articles->validator()->add('confirm', 'notEmpty', [
|
|
|
'rule' => function ($value, $context) {
|
|
|
return !empty($value);
|
|
|
},
|
|
|
@@ -61,18 +61,18 @@ class ConfirmableBehaviorTest extends TestCase {
|
|
|
'allowEmpty' => false,
|
|
|
'last' => true,
|
|
|
]);
|
|
|
- $this->Animals->validator()->remove('confirm');
|
|
|
+ $this->Articles->validator()->remove('confirm');
|
|
|
*/
|
|
|
|
|
|
- $this->Animals->addBehavior('Tools.Confirmable');
|
|
|
+ $this->Articles->addBehavior('Tools.Confirmable');
|
|
|
|
|
|
- $animal = $this->Animals->newEntity();
|
|
|
+ $animal = $this->Articles->newEntity();
|
|
|
|
|
|
$data = array(
|
|
|
'name' => 'FooBar',
|
|
|
'confirm' => '0'
|
|
|
);
|
|
|
- $animal = $this->Animals->patchEntity($animal, $data);
|
|
|
+ $animal = $this->Articles->patchEntity($animal, $data);
|
|
|
$this->assertNotEmpty($animal->errors());
|
|
|
|
|
|
$this->assertSame(array('confirm' => array('notEmpty' => __d('tools', 'Please confirm the checkbox'))), $animal->errors());
|
|
|
@@ -81,7 +81,7 @@ class ConfirmableBehaviorTest extends TestCase {
|
|
|
'name' => 'FooBar',
|
|
|
'confirm' => '1'
|
|
|
);
|
|
|
- $animal = $this->Animals->patchEntity($animal, $data);
|
|
|
+ $animal = $this->Articles->patchEntity($animal, $data);
|
|
|
$this->assertEmpty($animal->errors());
|
|
|
}
|
|
|
|
|
|
@@ -91,14 +91,14 @@ class ConfirmableBehaviorTest extends TestCase {
|
|
|
* @return void
|
|
|
*/
|
|
|
public function testValidationFieldMissing() {
|
|
|
- $this->Animals = TableRegistry::get('SluggedArticles');
|
|
|
- $this->Animals->addBehavior('Tools.Confirmable');
|
|
|
+ $this->Articles = TableRegistry::get('SluggedArticles');
|
|
|
+ $this->Articles->addBehavior('Tools.Confirmable');
|
|
|
|
|
|
- $animal = $this->Animals->newEntity();
|
|
|
+ $animal = $this->Articles->newEntity();
|
|
|
$data = array(
|
|
|
'name' => 'FooBar'
|
|
|
);
|
|
|
- $animal = $this->Animals->patchEntity($animal, $data);
|
|
|
+ $animal = $this->Articles->patchEntity($animal, $data);
|
|
|
$this->assertSame(array('confirm' => array('This field is required')), $animal->errors());
|
|
|
}
|
|
|
|