array( 'className' => 'TestTask.TestTaskComment', 'foreignKey' => 'article_id', ) ); var $hasAndBelongsToMany = array( 'Tag' => array( 'className' => 'TestTaskTag', 'joinTable' => 'articles_tags', 'foreignKey' => 'article_id', 'associationForeignKey' => 'tag_id' ) ); } class TestTaskTag extends Model { var $name = 'TestTaskTag'; var $useTable = 'tags'; var $hasAndBelongsToMany = array( 'Article' => array( 'className' => 'TestTaskArticle', 'joinTable' => 'articles_tags', 'foreignKey' => 'tag_id', 'associationForeignKey' => 'article_id' ) ); } /** * Simulated Plugin **/ class TestTaskAppModel extends Model { } class TestTaskComment extends TestTaskAppModel { var $name = 'TestTaskComment'; var $useTable = 'comments'; var $belongsTo = array( 'Article' => array( 'className' => 'TestTaskArticle', 'foreignKey' => 'article_id', ) ); } /** * TestTaskTest class * * @package cake * @subpackage cake.tests.cases.console.libs.tasks */ class TestTaskTest extends CakeTestCase { var $fixtures = array('core.article', 'core.comment', 'core.articles_tag', 'core.tag'); /** * setUp method * * @return void * @access public */ function setUp() { $this->Dispatcher =& new TestTestTaskMockShellDispatcher(); $this->Task =& new MockTestTask($this->Dispatcher); $this->Task->Dispatch = new $this->Dispatcher; } /** * tearDown method * * @return void * @access public */ function tearDown() { ClassRegistry::flush(); } /** * Test that file path generation doesn't continuously append paths. * * @access public * @return void */ function testFilePathGeneration () { $file = TESTS . 'cases' . DS . 'models' . DS . 'my_class.test.php'; $this->Task->Dispatch->expectNever('stderr'); $this->Task->Dispatch->expectNever('_stop'); $this->Task->setReturnValueAt(0, 'in', 'y'); $this->Task->expectAt(0, 'createFile', array($file, '*')); $this->Task->bake('Model', 'MyClass'); $this->Task->setReturnValueAt(1, 'in', 'y'); $this->Task->expectAt(1, 'createFile', array($file, '*')); $this->Task->bake('Model', 'MyClass'); } /** * Test that method introspection pulls all relevant non parent class * methods into the test case. * * @return void **/ function testMethodIntrospection() { $result = $this->Task->getTestableMethods('TestTaskSubjectClass'); $expected = array('methodOne', 'methodTwo'); $this->assertEqual($result, $expected); } /** * test that the generation of fixtures works correctly. * * @return void **/ function testFixtureArrayGeneration() { $subject = ClassRegistry::init('TestTaskArticle'); $result = $this->Task->generateFixtureList($subject); $expected = array('plugin.test_task.test_task_comment', 'app.articles_tags', 'app.test_task_article', 'app.test_task_tag'); $this->assertEqual(sort($result), sort($expected)); } } ?>