Skip to content
Permalink
Browse files

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
  • Loading branch information...
markstory committed Sep 10, 2011
1 parent 1743eaa commit 7c08c966b0793903891c56d3613e059fb259ff45
@@ -743,7 +743,10 @@ public function bake($name, $data = array()) {
$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 @@ public function testBakeWithPlugin() {
$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);

0 comments on commit 7c08c96

Please sign in to comment.
You can’t perform that action at this time.