Added unit tests for correlated subqueries - select, from, where.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8556 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-06-30 15:36:03 +00:00
parent 5d1eb1c21e
commit 1353ade0c2
41 changed files with 661 additions and 256 deletions

View file

@ -0,0 +1,54 @@
<?php
class DBTest extends PHPUnit_Framework_TestCase {
function _testQuery($xml_file, $argsString, $expected, $methodName){
$tester = new QueryTester();
$outputString = $tester->getNewParserOutputString($xml_file, $argsString);
$output = eval($outputString);
if(!is_a($output, 'Query')){
if(!$output->toBool()) $querySql = "Date incorecte! Query-ul nu a putut fi executat.";
}else {
$db = &DB::getInstance();
$querySql = $db->{$methodName}($output);
// Remove whitespaces, tabs and all
$querySql = Helper::cleanQuery($querySql);
$expected = Helper::cleanQuery($expected);
}
$this->assertEquals($expected, $querySql);
}
function _testPreparedQuery($xml_file, $argsString, $expected, $methodName, $expectedArgs = NULL){
$tester = new QueryTester();
$outputString = $tester->getNewParserOutputString($xml_file, $argsString);
$output = eval($outputString);
if(!is_a($output, 'Query')){
if(!$output->toBool()) $querySql = "Date incorecte! Query-ul nu a putut fi executat.";
}else {
$db = &DB::getInstance();
$querySql = $db->{$methodName}($output);
$queryArguments = $output->getArguments();
// Remove whitespaces, tabs and all
$querySql = Helper::cleanQuery($querySql);
$expected = Helper::cleanQuery($expected);
}
// Test
$this->assertEquals($expected, $querySql);
// Test query arguments
$argCount = count($expectedArgs);
for($i = 0; $i < $argCount; $i++){
//echo "$i: $expectedArgs[$i] vs $queryArguments[$i]->getValue()";
$this->assertEquals($expectedArgs[$i], $queryArguments[$i]->getValue());
}
}
}
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
?>