mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-04-02 01:52:10 +09:00
Moved DB unit tests from .\test-phpUnit to .\tests folder.
git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0@9788 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
aada2366d1
commit
97470e4d40
99 changed files with 53 additions and 85 deletions
|
|
@ -1,12 +0,0 @@
|
|||
<?php
|
||||
require('config/config.inc.php');
|
||||
|
||||
$oDB = &DB::getInstance('mssql');
|
||||
//$oDB = &DB::getInstance();
|
||||
$dbParser = $oDB->getParser();
|
||||
$dbParser = new DBParser('[', ']');
|
||||
$parser = new QueryParser($xml_obj->query, $dbParser);
|
||||
$query_file = $parser->toString();
|
||||
var_dump($parser->toString());
|
||||
|
||||
?>
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
/**
|
||||
* Test class for TableTag.
|
||||
*/
|
||||
|
|
@ -1,6 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
/**
|
||||
* Test class for TablesTag.
|
||||
*/
|
||||
|
|
@ -1,36 +1,30 @@
|
|||
<?php
|
||||
error_reporting(E_ALL ^ E_NOTICE);
|
||||
define('_XE_PATH_', str_replace('test-phpUnit/config/config.inc.php', '', str_replace('\\', '/', __FILE__)));
|
||||
define('_TEST_PATH_', _XE_PATH_ . 'test-phpUnit/');
|
||||
define('_XE_PATH_', str_replace('tests/classes/db/config/config.inc.php', '', str_replace('\\', '/', __FILE__)));
|
||||
define('_TEST_PATH_', _XE_PATH_ . 'tests/classes/db/');
|
||||
|
||||
if(!defined('__DEBUG__')) define('__DEBUG__', 4);
|
||||
define('__ZBXE__', true);
|
||||
define('__XE__', true);
|
||||
|
||||
require_once(_XE_PATH_.'test-phpUnit/Helper.class.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/QueryTester.class.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/DBTest.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/CubridTest.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/CubridOnlineTest.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/MssqlTest.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/MssqlOnlineTest.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/MysqlTest.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/SqliteTest.php');
|
||||
require_once(_TEST_PATH_.'Helper.class.php');
|
||||
require_once(_TEST_PATH_.'QueryTester.class.php');
|
||||
require_once(_TEST_PATH_.'db/DBTest.php');
|
||||
require_once(_TEST_PATH_.'db/CubridTest.php');
|
||||
require_once(_TEST_PATH_.'db/CubridOnlineTest.php');
|
||||
require_once(_TEST_PATH_.'db/MssqlTest.php');
|
||||
require_once(_TEST_PATH_.'db/MssqlOnlineTest.php');
|
||||
require_once(_TEST_PATH_.'db/MysqlTest.php');
|
||||
require_once(_TEST_PATH_.'db/SqliteTest.php');
|
||||
|
||||
require_once(_XE_PATH_.'config/config.inc.php');
|
||||
// require_once(_XE_PATH_.'classes/object/Object.class.php');
|
||||
// require_once(_XE_PATH_.'classes/handler/Handler.class.php');
|
||||
// require_once(_XE_PATH_.'classes/context/Context.class.php');
|
||||
// require_once(_XE_PATH_.'classes/file/FileHandler.class.php');
|
||||
// require_once(_XE_PATH_.'classes/xml/XmlParser.class.php');
|
||||
require_once(_XE_PATH_.'classes/xml/XmlQueryParser.150.class.php');
|
||||
//
|
||||
|
||||
require_once(_XE_PATH_.'classes/db/DB.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/DBCubrid.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/DBMssql.class.php');
|
||||
require_once(_XE_PATH_.'classes/db/DBMysql.class.php');
|
||||
require_once(_XE_PATH_.'test-phpUnit/db/MockDb.php');
|
||||
require_once(_TEST_PATH_.'db/MockDb.php');
|
||||
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/DBParser.class.php');
|
||||
require_once(_XE_PATH_.'classes/xml/xmlquery/argument/Argument.class.php');
|
||||
|
|
@ -1,5 +1,6 @@
|
|||
<?php
|
||||
class DBTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
class DBTest extends PHPUnit_Framework_TestCase {
|
||||
|
||||
function _testQuery($xml_file, $argsString, $expected, $methodName, $columnList = null){
|
||||
echo PHP_EOL . ' ----------------------------------- ' .PHP_EOL;
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class ExpressionParserTest extends PHPUnit_Framework_TestCase {
|
||||
/* Escape char for:
|
||||
|
|
@ -9,18 +8,18 @@
|
|||
*/
|
||||
var $dbLeftEscapeChar = '[';
|
||||
var $dbRightEscapeChar = ']';
|
||||
|
||||
|
||||
function _test($column_name, $alias, $expected){
|
||||
$expressionParser = new DBParser($this->dbLeftEscapeChar,$this->dbRightEscapeChar);
|
||||
$actual = $expressionParser->parseExpression($column_name);
|
||||
if($alias) $actual .= " as $alias";
|
||||
$this->assertEquals($expected, $actual);
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
|
||||
function testStarExpressionIsNotEscaped(){
|
||||
$this->_test("*", NULL, '*');
|
||||
}
|
||||
|
||||
|
||||
function testSimpleColumnNameGetsEscaped(){
|
||||
$this->_test("member_srl", NULL
|
||||
, $this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar );
|
||||
|
|
@ -28,81 +27,81 @@
|
|||
|
||||
function testUnqualifiedAliasedColumnNameGetsEscaped(){
|
||||
$this->_test("member_srl", "id"
|
||||
, $this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar.' as id');
|
||||
}
|
||||
, $this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar.' as id');
|
||||
}
|
||||
|
||||
function testQualifiedColumnNameGetsEscaped(){
|
||||
$this->_test("xe_members.member_srl", NULL
|
||||
, $this->dbLeftEscapeChar.'xe_members'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar);
|
||||
}
|
||||
, $this->dbLeftEscapeChar.'xe_members'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar);
|
||||
}
|
||||
|
||||
function testQualifiedAliasedColumnNameGetsEscaped(){
|
||||
$this->_test("xe_members.member_srl","id"
|
||||
,$this->dbLeftEscapeChar.'xe_members'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar.' as id');
|
||||
,$this->dbLeftEscapeChar.'xe_members'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'member_srl'.$this->dbRightEscapeChar.' as id');
|
||||
}
|
||||
|
||||
|
||||
function testCountDoesntGetEscaped(){
|
||||
$this->_test("count(*)", NULL, 'count(*)');
|
||||
$this->_test("count(*)", NULL, 'count(*)');
|
||||
}
|
||||
|
||||
function testAliasedCountDoesntGetEscaped(){
|
||||
$this->_test("count(*)", "count", 'count(*) as count');
|
||||
}
|
||||
$this->_test("count(*)", "count", 'count(*) as count');
|
||||
}
|
||||
|
||||
function testUnqualifiedColumnExpressionWithOneParameterLessFunction(){
|
||||
$this->_test("substring(regdate)", NULL
|
||||
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')');
|
||||
}
|
||||
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')');
|
||||
}
|
||||
|
||||
function testAliasedUnqualifiedColumnExpressionWithOneParameterLessFunction(){
|
||||
$this->_test("substring(regdate)", "regdate"
|
||||
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.') as regdate');
|
||||
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.') as regdate');
|
||||
}
|
||||
|
||||
|
||||
function testQualifiedColumnExpressionWithOneParameterLessFunction(){
|
||||
$this->_test("substring(xe_member.regdate)", NULL
|
||||
$this->_test("substring(xe_member.regdate)", NULL
|
||||
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')');
|
||||
}
|
||||
}
|
||||
|
||||
function testAliasedQualifiedColumnExpressionWithOneParameterLessFunction(){
|
||||
$this->_test("substring(xe_member.regdate)", "regdate"
|
||||
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.') as regdate');
|
||||
}
|
||||
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.') as regdate');
|
||||
}
|
||||
|
||||
function testUnqualifiedColumnExpressionWithTwoParameterLessFunctions(){
|
||||
$this->_test("lpad(rpad(regdate))", NULL
|
||||
, 'lpad(rpad('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.'))');
|
||||
}
|
||||
}
|
||||
|
||||
function testAliasedUnqualifiedColumnExpressionWithTwoParameterLessFunctions(){
|
||||
$this->_test("lpad(rpad(regdate))", "regdate"
|
||||
, 'lpad(rpad('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')) as regdate');
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function testQualifiedColumnExpressionWithTwoParameterLessFunctions(){
|
||||
$this->_test("lpad(rpad(xe_member.regdate))", NULL
|
||||
, 'lpad(rpad('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.'))');
|
||||
}
|
||||
, 'lpad(rpad('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.'))');
|
||||
}
|
||||
|
||||
function testAliasedQualifiedColumnExpressionWithTwoParameterLessFunctions(){
|
||||
$this->_test("lpad(rpad(xe_member.regdate))", "regdate"
|
||||
, 'lpad(rpad('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.')) as regdate');
|
||||
}
|
||||
}
|
||||
|
||||
function testColumnAddition(){
|
||||
$this->_test("score1 + score2", "total"
|
||||
, $this->dbLeftEscapeChar.'score1'.$this->dbRightEscapeChar.' + '.$this->dbLeftEscapeChar.'score2'.$this->dbRightEscapeChar.' as total');
|
||||
, $this->dbLeftEscapeChar.'score1'.$this->dbRightEscapeChar.' + '.$this->dbLeftEscapeChar.'score2'.$this->dbRightEscapeChar.' as total');
|
||||
}
|
||||
|
||||
|
||||
function testMultipleParameterFunction(){
|
||||
$this->_test("substring(regdate, 1, 8)", NULL
|
||||
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.', 1, 8)');
|
||||
$this->_test("substring(regdate, 1, 8)", "regdate"
|
||||
, 'substring('.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.', 1, 8) as regdate');
|
||||
$this->_test("substring(xe_member.regdate, 1, 8)", NULL
|
||||
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.', 1, 8)');
|
||||
, 'substring('.$this->dbLeftEscapeChar.'xe_member'.$this->dbRightEscapeChar.'.'.$this->dbLeftEscapeChar.'regdate'.$this->dbRightEscapeChar.', 1, 8)');
|
||||
}
|
||||
|
||||
|
||||
function testFunctionAddition(){
|
||||
$this->_test("abs(score) + abs(totalscore)", NULL
|
||||
, 'abs('.$this->dbLeftEscapeChar.'score'.$this->dbRightEscapeChar.') + abs('.$this->dbLeftEscapeChar.'totalscore'.$this->dbRightEscapeChar.')');
|
||||
|
|
@ -1,21 +1,20 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class CubridDeleteTest extends CubridTest {
|
||||
class CubridDeleteTest extends CubridTest {
|
||||
|
||||
function _test($xml_file, $argsString, $expected){
|
||||
$this->_testQuery($xml_file, $argsString, $expected, 'getDeleteSql');
|
||||
}
|
||||
|
||||
function test_module_deleteActionForward(){
|
||||
|
||||
function test_module_deleteActionForward(){
|
||||
$xml_file = _XE_PATH_ . "modules/module/queries/deleteActionForward.xml";
|
||||
$argsString = '$args->module = "page";
|
||||
$args->type = "page";
|
||||
$args->act = "tata";';
|
||||
$expected = 'delete "action_forward" from "xe_action_forward" as "action_forward"
|
||||
where "module" = \'page\'
|
||||
and "type" = \'page\'
|
||||
$expected = 'delete "action_forward" from "xe_action_forward" as "action_forward"
|
||||
where "module" = \'page\'
|
||||
and "type" = \'page\'
|
||||
and "act" = \'tata\'';
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
$this->_test($xml_file, $argsString, $expected);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class CubridInsertTest extends CubridTest {
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class CubridSelectTest extends CubridTest {
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class CubridUpdateTest extends CubridTest {
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class MssqlSelectTest extends MssqlTest {
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class MssqlUpdateTest extends MssqlTest {
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class MysqlSelectTest extends MysqlTest {
|
||||
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class MysqlUpdateTest extends MysqlTest {
|
||||
class MysqlUpdateTest extends MysqlTest {
|
||||
|
||||
function _test($xml_file, $argsString, $expected, $columnList = null){
|
||||
$this->_testQuery($xml_file, $argsString, $expected, 'getUpdateSql', $columnList);
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class SqliteDeleteTest extends SqliteTest {
|
||||
|
||||
|
|
@ -1,5 +1,4 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
class SqliteUpdateTest extends SqliteTest {
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue