mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-02-12 06:56:24 +00:00
Fixing notice errors when bogus validation options are selected. Refs #453
This commit is contained in:
parent
4c668c036c
commit
8e8acfaccd
2 changed files with 23 additions and 1 deletions
|
@ -410,6 +410,10 @@ class ModelTask extends BakeTask {
|
||||||
$this->out(__("You have already chosen that validation rule,\nplease choose again", true));
|
$this->out(__("You have already chosen that validation rule,\nplease choose again", true));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!isset($this->_validations[$choice])) {
|
||||||
|
$this->out(__('Please make a valid selection.', true));
|
||||||
|
continue;
|
||||||
|
}
|
||||||
$alreadyChosen[] = $choice;
|
$alreadyChosen[] = $choice;
|
||||||
} else {
|
} else {
|
||||||
$choice = $guess;
|
$choice = $guess;
|
||||||
|
|
|
@ -42,7 +42,7 @@ Mock::generatePartial(
|
||||||
);
|
);
|
||||||
Mock::generatePartial(
|
Mock::generatePartial(
|
||||||
'ModelTask', 'MockModelTask',
|
'ModelTask', 'MockModelTask',
|
||||||
array('in', 'out', 'err', 'createFile', '_stop', '_checkUnitTest')
|
array('in', 'out', 'hr', 'err', 'createFile', '_stop', '_checkUnitTest')
|
||||||
);
|
);
|
||||||
|
|
||||||
Mock::generate(
|
Mock::generate(
|
||||||
|
@ -233,6 +233,24 @@ class ModelTaskTest extends CakeTestCase {
|
||||||
$this->assertEqual($result, $expected);
|
$this->assertEqual($result, $expected);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* test that a bogus response doesn't cause errors to bubble up.
|
||||||
|
*
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function testInteractiveFieldValidationWithBogusResponse() {
|
||||||
|
$this->Task->initValidations();
|
||||||
|
$this->Task->interactive = true;
|
||||||
|
$this->Task->setReturnValueAt(0, 'in', '--bogus--');
|
||||||
|
$this->Task->setReturnValueAt(1, 'in', '19');
|
||||||
|
$this->Task->setReturnValueAt(2, 'in', 'n');
|
||||||
|
$this->Task->expectAt(4, 'out', array(new PatternExpectation('/make a valid/')));
|
||||||
|
|
||||||
|
$result = $this->Task->fieldValidation('text', array('type' => 'string', 'length' => 10, 'null' => false));
|
||||||
|
$expected = array('notempty' => 'notempty');
|
||||||
|
$this->assertEqual($result, $expected);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* test the validation Generation routine
|
* test the validation Generation routine
|
||||||
*
|
*
|
||||||
|
|
Loading…
Add table
Reference in a new issue