Permalink
Browse files

Flushing the CR after a model is baked, tests added. Refs #310.

  • Loading branch information...
1 parent 3174630 commit d5ea6b7c2a99bbda503f2247702aa4a6953dcf1b @renan renan committed Feb 12, 2010
Showing with 21 additions and 2 deletions.
  1. +1 −0 cake/console/libs/tasks/model.php
  2. +20 −2 cake/tests/cases/console/libs/tasks/model.test.php
@@ -666,6 +666,7 @@ function bake($name, $associations = array(), $validate = array(), $primaryKey
}
$out .= "}\n";
$out .= "?>";
+ ClassRegistry::flush();
$filename = $this->path . Inflector::underscore($name) . '.php';
$this->out("\nBaking model class for $name...");
return $this->createFile($filename, $out);
@@ -44,7 +44,7 @@
);
Mock::generatePartial(
'ModelTask', 'MockModelTask',
- array('in', 'out', 'createFile')
+ array('in', 'out', 'createFile', '_checkUnitTest')
);
/**
* ModelTaskTest class
@@ -53,7 +53,7 @@
* @subpackage cake.tests.cases.console.libs.tasks
*/
class ModelTaskTest extends CakeTestCase {
- var $fixtures = array('core.datatype', 'core.binary_test');
+ var $fixtures = array('core.datatype', 'core.binary_test', 'core.article');
/**
* setUp method
*
@@ -88,5 +88,23 @@ function testFixtureGeneration() {
$result = $this->Task->fixture('BinaryTest');
$this->assertPattern("/'data' => 'Lorem ipsum dolor sit amet'/", $result);
}
+/**
+ * test that execute passes runs bake depending with named model.
+ *
+ * @return void
+ * @access public
+ */
+ function testBakeModel() {
+ $this->Task->connection = 'test_suite';
+ $this->Task->path = '/my/path/';
+ $filename = '/my/path/article.php';
+ $this->Task->setReturnValue('_checkUnitTest', 1);
+ $this->Task->expectAt(0, 'createFile', array($filename, new PatternExpectation('/class Article extends AppModel/')));
+ $model =& new Model(array('name' => 'Article', 'table' => 'articles', 'ds' => 'test_suite'));
+ $this->Task->bake($model);
+
+ $this->assertEqual(count(ClassRegistry::keys()), 0);
+ $this->assertEqual(count(ClassRegistry::mapKeys()), 0);
+ }
}
?>

0 comments on commit d5ea6b7

Please sign in to comment.