Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Bake interactive console for 'Model' does not show validation rule 'uuid' #77

Merged
merged 3 commits into from

2 participants

@tPl0ch

When I used the interactive bake console to bake a model, I realized that the uuid validation message is missing. So I investigated this and realized that when the validation method index is starting at 1, you need to add one more index for the 'Do no validation rule', hence leaving the last validation rule (here: 'uuid') out.

Commit message:
Fixed wrong validation init in Model bake task when having index starting at 1.
Added guess 'uuid' for type 'string' and length 36.
Updated missing calls to assertEqual() testFieldValidationGuessing().
Added test for uuid guessing.
Fixes #1710.

tPl0ch added some commits
@tPl0ch tPl0ch Fixed wrong validation init in Model bake task when having index star…
…ting at 1.

Added guess 'uuid' for type 'string' and length 36.
Updated missing calls to assertEqual() testFieldValidationGuessing().
Added test for uuid guessing.
8ef7016
@tPl0ch tPl0ch Fixed wrong passing of $expected and $results in model task test. bf37054
@tPl0ch tPl0ch Merge branch '1.3' of https://github.com/cakephp/cakephp into 1.3-bake bf72166
@markstory markstory merged commit bf72166 into from
@markstory
Owner

Thanks for the patches, I've merged them in,

@westernmagic westernmagic referenced this pull request from a commit
@paulirish paulirish ifmodule headers for all those jerkfaces out there who dont have mod_…
…headers installed. (thx swaroopch)

WHO ARE THESE PEOPLE!?
also fixes #77.
thx simshaun as well.
cfbd24a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 16, 2011
  1. @tPl0ch

    Fixed wrong validation init in Model bake task when having index star…

    tPl0ch authored
    …ting at 1.
    
    Added guess 'uuid' for type 'string' and length 36.
    Updated missing calls to assertEqual() testFieldValidationGuessing().
    Added test for uuid guessing.
  2. @tPl0ch
Commits on May 18, 2011
  1. @tPl0ch
This page is out of date. Refresh to see the latest.
View
3  cake/console/libs/tasks/model.php
@@ -353,6 +353,7 @@ function initValidations() {
$default++;
}
}
+ $choices[$default] = 'none'; // Needed since index starts at 1
$this->_validations = $choices;
return $choices;
}
@@ -391,6 +392,8 @@ function fieldValidation($fieldName, $metaData, $primaryKey = 'id') {
if ($metaData['null'] != 1 && !in_array($fieldName, array($primaryKey, 'created', 'modified', 'updated'))) {
if ($fieldName == 'email') {
$guess = $methods['email'];
+ } elseif ($metaData['type'] == 'string' && $metaData['length'] == 36) {
+ $guess = $methods['uuid'];
} elseif ($metaData['type'] == 'string') {
$guess = $methods['notempty'];
} elseif ($metaData['type'] == 'integer') {
View
12 cake/tests/cases/console/libs/tasks/model.test.php
@@ -197,21 +197,31 @@ function testFieldValidationGuessing() {
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
$expected = array('notempty' => 'notempty');
+ $this->assertEqual($expected, $result);
$result = $this->Task->fieldValidation('text', array('type' => 'date', 'length' => 10, 'null' => false));
$expected = array('date' => 'date');
+ $this->assertEqual($expected, $result);
$result = $this->Task->fieldValidation('text', array('type' => 'time', 'length' => 10, 'null' => false));
$expected = array('time' => 'time');
+ $this->assertEqual($expected, $result);
$result = $this->Task->fieldValidation('email', array('type' => 'string', 'length' => 10, 'null' => false));
$expected = array('email' => 'email');
+ $this->assertEqual($expected, $result);
$result = $this->Task->fieldValidation('test', array('type' => 'integer', 'length' => 10, 'null' => false));
$expected = array('numeric' => 'numeric');
+ $this->assertEqual($expected, $result);
$result = $this->Task->fieldValidation('test', array('type' => 'boolean', 'length' => 10, 'null' => false));
- $expected = array('numeric' => 'numeric');
+ $expected = array('boolean' => 'boolean');
+ $this->assertEqual($expected, $result);
+
+ $result = $this->Task->fieldValidation('test', array('type' => 'string', 'length' => 36, 'null' => false));
+ $expected = array('uuid' => 'uuid');
+ $this->assertEqual($expected, $result);
}
/**
Something went wrong with that request. Please try again.