Update to query argument naming - so that queries that have the same variable name specified in the XML will not fail.

git-svn-id: http://xe-core.googlecode.com/svn/branches/1.5.0-DB@8658 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
ucorina 2011-07-26 14:40:46 +00:00
parent 620b18e532
commit cfc7d32afd
15 changed files with 209 additions and 189 deletions

View file

@ -6,30 +6,10 @@
class QueryArgumentTest extends CubridTest {
var $xmlPath = "data/";
function QueryArgumentTest(){
$this->xmlPath = str_replace('QueryArgumentTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
function testNotNullConditionArgument(){
$xml_file = $this->xmlPath . "condition1.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new QueryArgument($xml_obj->condition);
$this->assertEquals("member_srl", $tag->getArgumentName());
$this->assertEquals("member_srl", $tag->getColumnName());
$this->assertEquals(true, $tag->isConditionArgument());
$actual = Helper::cleanString($tag->toString());
$expected = Helper::cleanString('$member_srl_argument = new ConditionArgument(\'member_srl\', $args->member_srl, \'equal\');
$member_srl_argument->checkNotNull();
$member_srl_argument->createConditionValue();
if(!$member_srl_argument->isValid()) return $member_srl_argument->getErrorMessage();');
$this->assertEquals($expected, $actual);
}
}
}
?>

View file

@ -6,11 +6,11 @@
class ConditionTagTest extends CubridTest {
var $xmlPath = "data/";
function ConditionTagTest(){
$this->xmlPath = str_replace('ConditionTagTest.php', '', str_replace('\\', '/', __FILE__)) . $this->xmlPath;
}
/**
* Tests a simple <condition> tag:
* <condition operation="equal" column="user_id" var="user_id" />
@ -19,15 +19,16 @@ class ConditionTagTest extends CubridTest {
$xml_file = $this->xmlPath . "condition1.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$expected = "new Condition('\"user_id\"',\$user_id_argument,\"equal\")";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$arguments = $tag->getArguments();
$expected = "new Condition('\"user_id\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\")";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$this->assertEquals(1, count($arguments));
}
}
/**
* Tests a condition tag for joins - that uses no argument
* <condition operation="equal" column="comments.user_id" default="member.user_id" filter="userid" />
@ -39,13 +40,13 @@ class ConditionTagTest extends CubridTest {
$expected = "new Condition('\"comments\".\"user_id\"','\"member\".\"user_id\"',\"equal\")";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$this->assertEquals($expected, $actual);
$arguments = $tag->getArguments();
$this->assertEquals(0, count($arguments));
}
$this->assertEquals(0, count($arguments));
}
/**
* Tests a <condition> tag with pipe:
* <condition operation="equal" column="type" var="type" notnull="notnull" pipe="and" />
@ -54,15 +55,16 @@ class ConditionTagTest extends CubridTest {
$xml_file = $this->xmlPath . "condition2.xml";
$xml_obj = Helper::getXmlObject($xml_file);
$tag = new ConditionTag($xml_obj->condition);
$expected = "new Condition('\"type\"',\$type_argument,\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$arguments = $tag->getArguments();
$expected = "new Condition('\"type\"',\$" . $arguments[0]->getArgumentName() . "_argument,\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$this->assertEquals(1, count($arguments));
}
}
/**
* Tests that even if the column name is given in the var attribute, it knows it's just a name and not an argument
* <condition operation="equal" column="modules.module_srl" var="documents.module_srl" pipe="and" />
@ -74,11 +76,11 @@ class ConditionTagTest extends CubridTest {
$expected = "new Condition('\"modules\".\"module_srl\"','\"documents\".\"module_srl\"',\"equal\", 'and')";
$actual = $tag->getConditionString();
$this->assertEquals($expected, $actual);
$this->assertEquals($expected, $actual);
$arguments = $tag->getArguments();
$this->assertEquals(0, count($arguments));
}
$this->assertEquals(0, count($arguments));
}
}