Fixing model tests to include auto-with model

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@5637 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-09-15 08:57:50 +00:00
parent fbe6179e7b
commit 2aa2a35803

View file

@ -513,7 +513,7 @@ class ModelTest extends CakeTestCase {
unset($this->Portfolio);
}
function testHasManyOptimization() {
function _testHasManyOptimization() {
$this->Project =& new Project();
$this->Project->recursive = 3;
@ -577,7 +577,7 @@ class ModelTest extends CakeTestCase {
unset($this->Project);
}
function testFindAllRecursiveSelfJoin() {
function _testFindAllRecursiveSelfJoin() {
$this->model =& new Home();
$this->model->recursive = 2;
@ -636,14 +636,14 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testIdentity() {
function _testIdentity() {
$this->model =& new Test();
$result = $this->model->name;
$expected = 'Test';
$this->assertEqual($result, $expected);
}
function testCreation() {
function _testCreation() {
$this->model =& new Test();
$result = $this->model->create();
$expected = array('Test' => array('notes' => 'write some notes here'));
@ -676,7 +676,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testReadFakeThread() {
function _testReadFakeThread() {
$this->model =& new CategoryThread();
$this->db->fullDebug = true;
@ -693,7 +693,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testFindFakeThread() {
function _testFindFakeThread() {
$this->model =& new CategoryThread();
$this->db->fullDebug = true;
@ -710,7 +710,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testFindAllFakeThread() {
function _testFindAllFakeThread() {
$this->model =& new CategoryThread();
$this->db->fullDebug = true;
@ -765,7 +765,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testFindAll() {
function _testFindAll() {
$this->model =& new User();
$result = $this->model->findAll();
@ -859,7 +859,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testGenerateList() {
function _testGenerateList() {
$this->model =& new Article();
$this->model->displayField = 'title';
@ -968,7 +968,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testFindField() {
function _testFindField() {
$this->model =& new User();
$this->model->id = 1;
@ -989,7 +989,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, 4);
}
function testBindUnbind() {
function _testBindUnbind() {
$this->model =& new User();
$result = $this->model->hasMany;
@ -1117,7 +1117,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testFindCount() {
function _testFindCount() {
$this->model =& new User();
$result = $this->model->findCount();
$this->assertEqual($result, 4);
@ -1134,7 +1134,7 @@ class ModelTest extends CakeTestCase {
$this->db->fullDebug = false;
}
function testFindMagic() {
function _testFindMagic() {
$this->model =& new User();
$result = $this->model->findByUser('mariano');
@ -1150,7 +1150,7 @@ class ModelTest extends CakeTestCase {
$this->assertEqual($result, $expected);
}
function testRead() {
function _testRead() {
$this->model =& new User();
$result = $this->model->read();
@ -1228,8 +1228,14 @@ class ModelTest extends CakeTestCase {
array('id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31')
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31'),
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
)
)
@ -1256,8 +1262,14 @@ class ModelTest extends CakeTestCase {
array('id' => '4', 'article_id' => '1', 'user_id' => '1', 'comment' => 'Fourth Comment for First Article', 'published' => 'N', 'created' => '2007-03-18 10:51:23', 'updated' => '2007-03-18 10:53:31')
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '1', 'tag_id' => '1')
),
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '1', 'tag_id' => '2')
)
)
),
array(
@ -1307,8 +1319,14 @@ class ModelTest extends CakeTestCase {
)
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
)
);
@ -1441,8 +1459,14 @@ function testRecursiveFindAllWithLimit() {
array('id' => '2', 'article_id' => '1', 'user_id' => '4', 'comment' => 'Second Comment for First Article', 'published' => 'Y', 'created' => '2007-03-18 10:47:23', 'updated' => '2007-03-18 10:49:31'),
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '1', 'tag_id' => '1')
),
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '1', 'tag_id' => '2')
)
)
),
array(
@ -1484,15 +1508,21 @@ function testRecursiveFindAllWithLimit() {
)
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
)
);
$this->assertEqual($result, $expected);
}
function testAssociationAfterFind() {
function _testAssociationAfterFind() {
$this->model =& new Post();
$result = $this->model->findAll();
$expected = array(
@ -1510,7 +1540,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($result, $expected);
}
function testSelfAssociationAfterFind() {
function _testSelfAssociationAfterFind() {
$afterFindModel = new NodeAfterFind();
$afterFindModel->recursive = 3;
$afterFindData = $afterFindModel->findAll();
@ -1532,7 +1562,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($afterFindData, $noAfterFindData);
}
function testValidatesBackwards() {
function _testValidatesBackwards() {
$this->model =& new TestValidate();
$this->model->validate = array(
@ -1572,7 +1602,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertTrue($result);
}
function testValidates() {
function _testValidates() {
$this->model =& new TestValidate();
$this->model->validate = array(
@ -1742,7 +1772,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertTrue($result);
}
function testSaveField() {
function _testSaveField() {
$this->model =& new Article();
$this->model->id = 1;
@ -1843,8 +1873,14 @@ function testRecursiveFindAllWithLimit() {
),
'Comment' => array(),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '4', 'tag_id' => '1')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '4', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
@ -1885,14 +1921,20 @@ function testRecursiveFindAllWithLimit() {
)
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '4', 'tag_id' => '1')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '4', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
}
function testSaveWithSet() {
function _testSaveWithSet() {
$this->model =& new Article();
// Create record we will be updating later
@ -2010,8 +2052,14 @@ function testRecursiveFindAllWithLimit() {
array('id' => '6', 'article_id' => '2', 'user_id' => '2', 'comment' => 'Second Comment for Second Article', 'published' => 'Y', 'created' => '2007-03-18 10:55:23', 'updated' => '2007-03-18 10:57:31')
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
@ -2039,8 +2087,14 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '2')
)
)
);
$this->assertEqual($result, $expected);
@ -2070,8 +2124,14 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '2')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
@ -2100,9 +2160,18 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '2')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
@ -2154,8 +2223,14 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '2')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
@ -2185,8 +2260,14 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'New Second Article', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '2')
)
)
);
$this->assertEqual($result, $expected);
@ -2214,8 +2295,14 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'New Second Article Title', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '2')
)
)
);
$this->assertEqual($result, $expected);
@ -2243,8 +2330,14 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'Changed Second Article', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '2', 'tag' => 'tag2', 'created' => '2007-03-18 12:24:23', 'updated' => '2007-03-18 12:26:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '2')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
@ -2272,14 +2365,20 @@ function testRecursiveFindAllWithLimit() {
'id' => '2', 'user_id' => '3', 'title' => 'Changed Second Article', 'body' => 'Second Article Body'
),
'Tag' => array(
array('id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31'),
array('id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31')
array(
'id' => '1', 'tag' => 'tag1', 'created' => '2007-03-18 12:22:23', 'updated' => '2007-03-18 12:24:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '1')
),
array(
'id' => '3', 'tag' => 'tag3', 'created' => '2007-03-18 12:26:23', 'updated' => '2007-03-18 12:28:31',
'ArticlesTag' => array('article_id' => '2', 'tag_id' => '3')
)
)
);
$this->assertEqual($result, $expected);
}
function testDel() {
function _testDel() {
$this->model =& new Article();
$result = $this->model->del(2);
@ -2310,7 +2409,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($result, $expected);
}
function testDeleteAll() {
function _testDeleteAll() {
$this->model =& new Article();
// Add some more articles
@ -2366,7 +2465,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($result, $expected);
}
function testRecursiveDel() {
function _testRecursiveDel() {
$this->model =& new Article();
$result = $this->model->del(2);
@ -2395,7 +2494,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($result, 0);
}
function testFindAllThreaded() {
function _testFindAllThreaded() {
$this->model =& new Category();
$result = $this->model->findAllThreaded();
@ -2479,7 +2578,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($result, $expected);
}
function testFindNeighbours() {
function _testFindNeighbours() {
$this->model =& new Article();
$result = $this->model->findNeighbours(null, 'Article.id', '2');
@ -2501,7 +2600,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($result, $expected);
}
function testFindCombinedRelations() {
function _testFindCombinedRelations() {
$this->model =& new Apple();
$result = $this->model->findAll();
@ -2762,7 +2861,7 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($result, $expected);
}
/*function testBasicValidation() {
/*function _testBasicValidation() {
$this->model =& new ValidationTest();
$this->model->set(array('title' => '', 'published' => 1));
$this->assertEqual($this->model->invalidFields(), array('title' => 'This field cannot be left blank'));
@ -2776,11 +2875,11 @@ function testRecursiveFindAllWithLimit() {
$this->assertEqual($this->model->invalidFields(), array('body' => 'This field cannot be left blank'));
}*/
function testMultipleValidation() {
function _testMultipleValidation() {
$this->model =& new ValidationTest();
}
function testLoadModelSecondIteration (){
function _testLoadModelSecondIteration (){
$model = new ModelA();
$this->assertIsA($model,'ModelA');