mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
Adding App::uses() call to model baking.
Models should always include their parent classes to be safe. Bake should reflect the best practice. Refs #1971
This commit is contained in:
parent
1743eaa776
commit
7c08c966b0
3 changed files with 9 additions and 3 deletions
|
@ -743,7 +743,10 @@ class ModelTask extends BakeTask {
|
|||
$data = array_merge($defaults, $data);
|
||||
|
||||
$this->Template->set($data);
|
||||
$this->Template->set('plugin', $this->plugin);
|
||||
$this->Template->set(array(
|
||||
'plugin' => $this->plugin,
|
||||
'pluginPath' => empty($this->plugin) ? '' : $this->plugin . '.'
|
||||
));
|
||||
$out = $this->Template->generate('classes', 'model');
|
||||
|
||||
$path = $this->getPath();
|
||||
|
|
|
@ -19,7 +19,9 @@
|
|||
* @license MIT License (http://www.opensource.org/licenses/mit-license.php)
|
||||
*/
|
||||
|
||||
echo "<?php\n"; ?>
|
||||
echo "<?php\n";
|
||||
echo "App::uses('{$plugin}AppModel', '{$pluginPath}Model');\n";
|
||||
?>
|
||||
/**
|
||||
* <?php echo $name ?> Model
|
||||
*
|
||||
|
|
|
@ -754,7 +754,8 @@ STRINGEND;
|
|||
$this->Task->expects($this->once())->method('createFile')
|
||||
->with($path, new PHPUnit_Framework_Constraint_PCREMatch('/BakeArticle extends ControllerTestAppModel/'));
|
||||
|
||||
$this->Task->bake('BakeArticle', array(), array());
|
||||
$result = $this->Task->bake('BakeArticle', array(), array());
|
||||
$this->assertContains("App::uses('ControllerTestAppModel', 'ControllerTest.Model');", $result);
|
||||
|
||||
$this->assertEqual(count(ClassRegistry::keys()), 0);
|
||||
$this->assertEqual(count(ClassRegistry::mapKeys()), 0);
|
||||
|
|
Loading…
Add table
Reference in a new issue