mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Updating tests for ModelTask. Making it impossible to bake a model which does not have a table on the active connection. Fixes #6035
This commit is contained in:
parent
9bbb33ef2f
commit
7e1f9eeebd
2 changed files with 30 additions and 2 deletions
|
@ -197,6 +197,10 @@ class ModelTask extends Shell {
|
|||
if (!array_key_exists('id', $fields)) {
|
||||
$primaryKey = $this->findPrimaryKey($fields);
|
||||
}
|
||||
} else {
|
||||
$this->err(sprintf(__('Table %s does not exist, cannot bake a model without a table.', true), $useTable));
|
||||
$this->_stop();
|
||||
return false;
|
||||
}
|
||||
$displayField = $tempModel->hasField(array('name', 'title'));
|
||||
if (!$displayField) {
|
||||
|
|
|
@ -698,6 +698,7 @@ class ModelTaskTest extends CakeTestCase {
|
|||
function testExecuteIntoInteractive() {
|
||||
$this->Task->connection = 'test_suite';
|
||||
$this->Task->path = '/my/path/';
|
||||
$this->Task->interactive = true;
|
||||
|
||||
$this->Task->setReturnValueAt(0, 'in', '1'); //choose article
|
||||
$this->Task->setReturnValueAt(1, 'in', 'n'); //no validation
|
||||
|
@ -705,11 +706,34 @@ class ModelTaskTest extends CakeTestCase {
|
|||
$this->Task->setReturnValueAt(3, 'in', 'y'); //yes to comment relation
|
||||
$this->Task->setReturnValueAt(4, 'in', 'y'); //yes to user relation
|
||||
$this->Task->setReturnValueAt(5, 'in', 'y'); //yes to tag relation
|
||||
$this->Task->setReturnValueAt(6, 'in', 'n'); //no to looksGood?
|
||||
$this->Task->setReturnValueAt(6, 'in', 'n'); //no to additional assocs
|
||||
$this->Task->setReturnValueAt(7, 'in', 'y'); //yes to looksGood?
|
||||
$this->Task->setReturnValue('_checkUnitTest', true);
|
||||
|
||||
$this->Task->Test->expectOnce('bake');
|
||||
$this->Task->Fixture->expectOnce('bake');
|
||||
|
||||
$filename = '/my/path/article.php';
|
||||
$this->Task->expectOnce('createFile');
|
||||
$this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article/')));
|
||||
$this->Task->execute();
|
||||
}
|
||||
|
||||
/**
|
||||
* test using bake interactively with a table that does not exist.
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testExecuteWithNonExistantTableName() {
|
||||
$this->Task->connection = 'test_suite';
|
||||
$this->Task->path = '/my/path/';
|
||||
|
||||
$this->Task->expectOnce('_stop');
|
||||
$this->Task->expectOnce('err');
|
||||
|
||||
$this->Task->setReturnValueAt(0, 'in', 'Foobar');
|
||||
$this->Task->setReturnValueAt(1, 'in', 'y');
|
||||
$this->Task->execute();
|
||||
}
|
||||
}
|
||||
?>
|
Loading…
Reference in a new issue