Skip to content

Commit

Permalink
Fix allowEmpty calculation.
Browse files Browse the repository at this point in the history
I had the logic backwards.
  • Loading branch information
markstory committed Mar 18, 2014
1 parent 3b0a9fc commit a29aec1
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Console/Command/Task/ModelTask.php
Expand Up @@ -437,7 +437,7 @@ public function fieldValidation($fieldName, $metaData, $primaryKey) {
}

$allowEmpty = false;
if ($rule !== 'notEmpty' && $metaData['null'] === false) {
if ($rule !== 'notEmpty' && $metaData['null'] === true) {
$allowEmpty = true;
}

Expand Down
6 changes: 3 additions & 3 deletions tests/TestCase/Console/Command/Task/ModelTaskTest.php
Expand Up @@ -371,11 +371,11 @@ public function testGetValidation() {
$model = TableRegistry::get('BakeArticles');
$result = $this->Task->getValidation($model);
$expected = [
'id' => ['rule' => 'numeric', 'allowEmpty' => true],
'bake_user_id' => ['rule' => 'numeric', 'allowEmpty' => true],
'id' => ['rule' => 'numeric', 'allowEmpty' => false],
'bake_user_id' => ['rule' => 'numeric', 'allowEmpty' => false],
'title' => ['rule' => 'notEmpty', 'allowEmpty' => false],
'body' => ['rule' => 'notEmpty', 'allowEmpty' => false],
'published' => ['rule' => 'boolean', 'allowEmpty' => false],
'published' => ['rule' => 'boolean', 'allowEmpty' => true],
];
$this->assertEquals($expected, $result);
}
Expand Down

0 comments on commit a29aec1

Please sign in to comment.