Adding double-escaping test case for DboSource, disproves #4196

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6476 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2008-02-24 15:28:17 +00:00
parent 4e573f48f0
commit f056ee4a3d

View file

@ -630,6 +630,38 @@ class DboSourceTest extends CakeTestCase {
$time = microtime(true) - $start;
}
function testFieldDoubleEscaping() {
$test =& ConnectionManager::create('quoteTest', array('driver' => 'test'));
$this->Model = new Article2(array('name' => 'Article', 'ds' => 'quoteTest'));
$this->Model->setDataSource('quoteTest');
$this->assertEqual($this->Model->escapeField(), '`Article`.`id`');
$result = $test->fields($this->Model, null, $this->Model->escapeField());
$this->assertEqual($result, array('`Article`.`id`'));
$result = $test->read($this->Model, array(
'fields' => $this->Model->escapeField(),
'conditions' => null,
'recursive' => -1
));
$this->assertEqual(trim($test->simulated[0]), 'SELECT `Article`.`id` FROM `article` AS `Article` WHERE 1 = 1');
$test->startQuote = '[';
$test->endQuote = ']';
$this->assertEqual($this->Model->escapeField(), '[Article].[id]');
$result = $test->fields($this->Model, null, $this->Model->escapeField());
$this->assertEqual($result, array('[Article].[id]'));
$result = $test->read($this->Model, array(
'fields' => $this->Model->escapeField(),
'conditions' => null,
'recursive' => -1
));
$this->assertEqual(trim($test->simulated[1]), 'SELECT [Article].[id] FROM [article] AS [Article] WHERE 1 = 1');
}
function testGenerateAssociationQuerySelfJoin() {
$this->startTime = microtime(true);
$this->Model = new Article2();
@ -690,9 +722,7 @@ class DboSourceTest extends CakeTestCase {
'table' => '`test_model4`',
'alias' => 'TestModel4Parent',
'type' => 'LEFT',
'conditions' => array (
'`TestModel4`.`parent_id`' => '{$__cakeIdentifier[TestModel4Parent.id]__$}'
)
'conditions' => array('`TestModel4`.`parent_id`' => '{$__cakeIdentifier[TestModel4Parent.id]__$}')
)
),
'table' => '`test_model4`',