Fixed test to used array based self join

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4771 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
mariano.iglesias 2007-04-05 03:40:08 +00:00
parent f0cd2d49ea
commit a53e15ee51

View file

@ -595,9 +595,36 @@ class DboSourceTest extends UnitTestCase {
$result = $this->db->generateSelfAssociationQuery($this->model, $params['linkModel'], $params['type'], $params['assoc'], $params['assocData'], $queryData, $params['external'], $resultSet);
$this->assertTrue($result);
//$this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $queryData['selfJoin'][0]);
//$this->assertPattern('/FROM\s+`test_model4` AS `TestModel4`\s+LEFT JOIN\s+`test_model4` AS `TestModel4Parent`/', $queryData['selfJoin'][0]);
//$this->assertPattern('/\s+ON\s+\(`TestModel4`.`parent_id` = `TestModel4Parent`.`id`\)\s+WHERE\s+1 = 1\s*$/', $queryData['selfJoin'][0]);
$expected = array (array (
'fields' => array (
'`TestModel4`.`id`',
'`TestModel4`.`name`',
'`TestModel4`.`created`',
'`TestModel4`.`updated`',
'`TestModel4Parent`.`id`',
'`TestModel4Parent`.`name`',
'`TestModel4Parent`.`created`',
'`TestModel4Parent`.`updated`'
),
'joins' => array (
array (
'table' => '`test_model4`',
'alias' => 'TestModel4Parent',
'type' => 'LEFT',
'conditions' => array (
'`TestModel4`.`parent_id`' => '{$__cakeIdentifier[TestModel4Parent.id]__$}'
)
)
),
'table' => '`test_model4`',
'alias' => 'TestModel4',
'limit' => array ( ),
'offset' => array ( ),
'conditions' => array ( ),
'order' => array ( )
));
$this->assertEqual($queryData['selfJoin'], $expected);
$result = $this->db->generateAssociationQuery($this->model, $null, null, null, null, $queryData, false, $null);
$this->assertPattern('/^SELECT\s+`TestModel4`\.`id`, `TestModel4`\.`name`, `TestModel4`\.`created`, `TestModel4`\.`updated`, `TestModel4Parent`\.`id`, `TestModel4Parent`\.`name`, `TestModel4Parent`\.`created`, `TestModel4Parent`\.`updated`\s+/', $result);