Skip to content

Commit

Permalink
Additional tests for fixture baking to ensure
Browse files Browse the repository at this point in the history
parameters are passed from model to fixture task
Adding -plugin support to ModelTask
  • Loading branch information
markstory committed Jun 7, 2009
1 parent 4d89086 commit 2181846
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
10 changes: 7 additions & 3 deletions cake/console/libs/tasks/model.php
Expand Up @@ -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;
Expand Down Expand Up @@ -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);
}
}
Expand Down
16 changes: 16 additions & 0 deletions cake/tests/cases/console/libs/tasks/model.test.php
Expand Up @@ -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);
}

/**
Expand Down Expand Up @@ -603,6 +606,19 @@ function testBakeRelations() {
$this->assertPattern('/Comment/', $result);
}

/**
* 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.
*
Expand Down

0 comments on commit 2181846

Please sign in to comment.