mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Merge remote branch 'origin/1.2' into merger
Conflicts: cake/console/templates/skel/config/inflections.php cake/libs/model/cake_schema.php cake/libs/model/model.php
This commit is contained in:
commit
09ad7418f5
4 changed files with 67 additions and 20 deletions
|
@ -53,19 +53,4 @@
|
|||
*/
|
||||
$singularRules = array();
|
||||
|
||||
/**
|
||||
* This is a key only array of singular words that should not be inflected.
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
* as the $uninflectedPlural above.
|
||||
*/
|
||||
$uninflectedSingular = $uninflectedPlural;
|
||||
|
||||
/**
|
||||
* This is a key => value array of singular irregular words.
|
||||
* Most of the time this will be a reverse of the above $irregularPlural array
|
||||
* You should not have to change this value below if you do change it use same format
|
||||
*
|
||||
* $irregularSingular = array('atlases' => 'atlas', 'beefs' => 'beef', 'brothers' => 'brother')
|
||||
*/
|
||||
$irregularSingular = array_flip($irregularPlural);
|
||||
?>
|
|
@ -485,11 +485,13 @@ class CakeSchema extends Object {
|
|||
|
||||
if (isset($old[$table]['indexes']) && isset($new[$table]['indexes'])) {
|
||||
$diff = $this->_compareIndexes($new[$table]['indexes'], $old[$table]['indexes']);
|
||||
if ($diff && isset($diff['drop'])) {
|
||||
$tables[$table]['drop']['indexes'] = $diff['drop'];
|
||||
}
|
||||
if ($diff && isset($diff['add'])) {
|
||||
$tables[$table]['add']['indexes'] = $diff['add'];
|
||||
if ($diff) {
|
||||
if (isset($tables[$table]['drop']['indexes']) && isset($diff['drop'])) {
|
||||
$tables[$table]['drop']['indexes'] = $diff['drop'];
|
||||
}
|
||||
if (isset($tables[$table]['add']['indexes']) && isset($diff['add'])) {
|
||||
$tables[$table]['add']['indexes'] = $diff['add'];
|
||||
}
|
||||
}
|
||||
}
|
||||
if (isset($old[$table]['tableParameters']) && isset($new[$table]['tableParameters'])) {
|
||||
|
|
|
@ -69,6 +69,56 @@ class ModelValidationTest extends BaseModelTest {
|
|||
);
|
||||
|
||||
$this->assertEqual($TestModel->invalidFields(), $expected);
|
||||
|
||||
$TestModel->validate['title'] = array(
|
||||
'rule' => array('customValidatorWithSixParams', 'one', 'two', null, 'four'),
|
||||
'required' => true
|
||||
);
|
||||
$TestModel->create(array('title' => 'foo'));
|
||||
$TestModel->invalidFields();
|
||||
$expected = array(
|
||||
'data' => array(
|
||||
'title' => 'foo'
|
||||
),
|
||||
'one' => 'one',
|
||||
'two' => 'two',
|
||||
'three' => null,
|
||||
'four' => 'four',
|
||||
'five' => array(
|
||||
'rule' => array(1 => 'one', 2 => 'two', 3 => null, 4 => 'four'),
|
||||
'on' => null,
|
||||
'last' => false,
|
||||
'allowEmpty' => false,
|
||||
'required' => true
|
||||
),
|
||||
'six' => 6
|
||||
);
|
||||
$this->assertEqual($TestModel->validatorParams, $expected);
|
||||
|
||||
$TestModel->validate['title'] = array(
|
||||
'rule' => array('customValidatorWithSixParams', 'one', array('two'), null, 'four', array('five' => 5)),
|
||||
'required' => true
|
||||
);
|
||||
$TestModel->create(array('title' => 'foo'));
|
||||
$TestModel->invalidFields();
|
||||
$expected = array(
|
||||
'data' => array(
|
||||
'title' => 'foo'
|
||||
),
|
||||
'one' => 'one',
|
||||
'two' => array('two'),
|
||||
'three' => null,
|
||||
'four' => 'four',
|
||||
'five' => array('five' => 5),
|
||||
'six' => array(
|
||||
'rule' => array(1 => 'one', 2 => array('two'), 3 => null, 4 => 'four', 5 => array('five' => 5)),
|
||||
'on' => null,
|
||||
'last' => false,
|
||||
'allowEmpty' => false,
|
||||
'required' => true
|
||||
)
|
||||
);
|
||||
$this->assertEqual($TestModel->validatorParams, $expected);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -2218,6 +2218,16 @@ class ValidationTest1 extends CakeTestModel {
|
|||
function customValidatorWithMessage($data) {
|
||||
return 'This field will *never* validate! Muhahaha!';
|
||||
}
|
||||
/**
|
||||
* Test validation with many parameters
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function customValidatorWithSixParams($data, $one = 1, $two = 2, $three = 3, $four = 4, $five = 5, $six = 6) {
|
||||
$this->validatorParams = get_defined_vars();
|
||||
unset($this->validatorParams['this']);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
Loading…
Add table
Reference in a new issue