mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-14 00:39:57 +09:00
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:
parent
5d1eb1c21e
commit
1353ade0c2
41 changed files with 661 additions and 256 deletions
134
test-phpUnit/classes/xml/xmlquery/tags/table/TableTagTest.php
Normal file
134
test-phpUnit/classes/xml/xmlquery/tags/table/TableTagTest.php
Normal file
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
require(_XE_PATH_ . 'test-phpUnit/config/config.inc.php');
|
||||
|
||||
/**
|
||||
* Test class for TableTag.
|
||||
*/
|
||||
class TableTagTest extends CubridTest {
|
||||
|
||||
var $xmlPath = "data/";
|
||||
|
||||
function TableTagTest(){
|
||||
$this->xmlPath = str_replace('TableTagTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a simple <table> tag:
|
||||
* <table name="modules" />
|
||||
*/
|
||||
function testTableTagWithName(){
|
||||
$xml_file = $this->xmlPath . "table_name.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$expected = "new Table('\"xe_modules\"', '\"modules\"')";
|
||||
$actual = $tag->getTableString();
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a <table> tag with name and alias
|
||||
* <table name="modules" alias="mod" />
|
||||
*/
|
||||
function testTableTagWithNameAndAlias(){
|
||||
$xml_file = $this->xmlPath . "table_name_alias.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$expected = "new Table('\"xe_modules\"', '\"mod\"')";
|
||||
$actual = $tag->getTableString();
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a <table> tag used for joins
|
||||
* <table name="module_categories" alias="module_categories" type="left join">
|
||||
* <conditions>
|
||||
* <condition operation="equal" column="module_categories.module_category_srl" default="modules.module_category_srl" />
|
||||
* </conditions>
|
||||
* </table>
|
||||
*
|
||||
*/
|
||||
function testTableTagWithJoinCondition(){
|
||||
$xml_file = $this->xmlPath . "table_name_alias_type.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$actual = $tag->getTableString();
|
||||
|
||||
$expected = 'new JoinTable(\'"xe_module_categories"\', \'"module_categories"\', "left join", array(
|
||||
new ConditionGroup(array(
|
||||
new Condition(\'"module_categories"."module_category_srl"\',\'"modules"."module_category_srl"\',"equal")
|
||||
))
|
||||
))';
|
||||
$actual = Helper::cleanQuery($actual);
|
||||
$expected = Helper::cleanQuery($expected);
|
||||
|
||||
$this->assertEquals($expected, $actual);
|
||||
}
|
||||
|
||||
/**
|
||||
* If a table tag has the type attribute and condition children
|
||||
* it means it is meant to be used inside a join
|
||||
*/
|
||||
function testTagWithTypeIsJoinTable(){
|
||||
$xml_file = $this->xmlPath . "table_name_alias_type.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$this->assertEquals(true, $tag->isJoinTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a simple table tag is not a join table
|
||||
*/
|
||||
function testTagWithoutTypeIsNotJoinTable(){
|
||||
$xml_file = $this->xmlPath . "table_name_alias.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$this->assertEquals(false, $tag->isJoinTable());
|
||||
}
|
||||
|
||||
/**
|
||||
* If no alias is specified, test that table name is used
|
||||
*/
|
||||
function testTableAliasWhenAliasNotSpecified(){
|
||||
$xml_file = $this->xmlPath . "table_name.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$this->assertEquals("modules", $tag->getTableAlias());
|
||||
}
|
||||
|
||||
/**
|
||||
* If alias is specified, test that it is used
|
||||
*/
|
||||
function testTableAliasWhenAliasSpecified(){
|
||||
$xml_file = $this->xmlPath . "table_name_alias.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$this->assertEquals("mod", $tag->getTableAlias());
|
||||
}
|
||||
|
||||
/**
|
||||
* Table name propery should returned unescaped and unprefixed table name
|
||||
* (The one in the XML file)
|
||||
*/
|
||||
function testTableName(){
|
||||
$xml_file = $this->xmlPath . "table_name_alias.xml";
|
||||
$xml_obj = Helper::getXmlObject($xml_file);
|
||||
|
||||
$tag = new TableTag($xml_obj->table);
|
||||
|
||||
$this->assertEquals("modules", $tag->getTableName());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1 @@
|
|||
<table name="modules" />
|
||||
|
|
@ -0,0 +1 @@
|
|||
<table name="modules" alias="mod" />
|
||||
|
|
@ -0,0 +1,5 @@
|
|||
<table name="module_categories" alias="module_categories" type="left join">
|
||||
<conditions>
|
||||
<condition operation="equal" column="module_categories.module_category_srl" default="modules.module_category_srl" />
|
||||
</conditions>
|
||||
</table>
|
||||
Loading…
Add table
Add a link
Reference in a new issue