Permalink
Browse files

Additional tests for fixture baking to ensure

parameters are passed from model to fixture task
Adding -plugin support to ModelTask
  • Loading branch information...
1 parent 4d89086 commit 21818460a2e1ad29938ae6c132a27b4f70080bc4 @markstory markstory committed Jun 7, 2009
Showing with 23 additions and 3 deletions.
  1. +7 −3 cake/console/libs/tasks/model.php
  2. +16 −0 cake/tests/cases/console/libs/tasks/model.test.php
@@ -706,9 +706,12 @@ function bake($name, $associations = array(), $validate = array(), $primaryKey =
$this->Template->set(compact('name', 'useDbConfig', 'associations', 'validate', 'primaryKey', 'useTable'));
$this->Template->set('plugin', $this->plugin);
$out = $this->Template->generate('objects', 'model');
-
- //@todo solve plugin model paths.
- $filename = $this->path . Inflector::underscore($name) . '.php';
+
+ $path = $this->path;
+ if (isset($this->plugin)) {
+ $path = $this->_pluginPath($this->plugin) . 'models' . DS;
+ }
+ $filename = $path . Inflector::underscore($name) . '.php';
$this->out("\nBaking model class for $name...");
$this->createFile($filename, $out);
return $out;
@@ -866,6 +869,7 @@ function help() {
**/
function bakeFixture($className, $useTable = null) {
$this->Fixture->connection = $this->connection;
+ $this->Fixture->plugin = $this->plugin;
$this->Fixture->bake($className, $useTable);
}
}
@@ -458,6 +458,9 @@ function testDoAssociationsNonInteractive() {
function testBakeFixture() {
$this->Task->Fixture->expectAt(0, 'bake', array('Article', 'articles'));
$this->Task->bakeFixture('Article', 'articles');
+
+ $this->assertEqual($this->Task->plugin, $this->Task->Fixture->plugin);
+ $this->assertEqual($this->Task->connection, $this->Task->Fixture->connection);
}
/**
@@ -604,6 +607,19 @@ function testBakeRelations() {
}
/**
+ * test bake() with a -plugin param
+ *
+ * @return void
+ **/
+ function testBakeWithPlugin() {
+ $this->Task->plugin = 'ControllerTest';
+
+ $path = APP . 'plugins' . DS . 'controller_test' . DS . 'models' . DS . 'article.php';
+ $this->Task->expectAt(0, 'createFile', array($path, '*'));
+ $this->Task->bake('Article', array(), array());
+ }
+
+/**
* test that execute passes runs bake depending with named model.
*
* @return void

0 comments on commit 2181846

Please sign in to comment.