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

This commit is contained in:
renan.saddam 2010-02-12 01:57:04 -02:00
parent 317463096a
commit d5ea6b7c2a
2 changed files with 21 additions and 2 deletions

View file

@ -666,6 +666,7 @@ class ModelTask extends Shell {
}
$out .= "}\n";
$out .= "?>";
ClassRegistry::flush();
$filename = $this->path . Inflector::underscore($name) . '.php';
$this->out("\nBaking model class for $name...");
return $this->createFile($filename, $out);

View file

@ -44,7 +44,7 @@ Mock::generatePartial(
);
Mock::generatePartial(
'ModelTask', 'MockModelTask',
array('in', 'out', 'createFile')
array('in', 'out', 'createFile', '_checkUnitTest')
);
/**
* ModelTaskTest class
@ -53,7 +53,7 @@ Mock::generatePartial(
* @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 @@ class ModelTaskTest extends CakeTestCase {
$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);
}
}
?>