summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorwei <>2007-02-02 05:29:00 +0000
committerwei <>2007-02-02 05:29:00 +0000
commitebe35517b35dc87eaec1333263cb78e9bd4ef2e1 (patch)
tree922abab3dd85415624269640cc600c487b338186
parent72ead8d5896b9a24df4841f9c31cff1dc2fcd878 (diff)
add unit test for sqlmap statement extends
-rw-r--r--.gitattributes2
-rw-r--r--framework/Data/SqlMap/Statements/TMappedStatement.php5
-rw-r--r--tests/simple_unit/SqlMap/StatementExtendsTest.php29
-rw-r--r--tests/simple_unit/SqlMap/common.php4
-rw-r--r--tests/simple_unit/SqlMap/maps/tests.xml19
5 files changed, 57 insertions, 2 deletions
diff --git a/.gitattributes b/.gitattributes
index 651baea6..6c06a23e 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -2454,6 +2454,7 @@ tests/simple_unit/SqlMap/ResultClassTest.php -text
tests/simple_unit/SqlMap/ResultMapTest.php -text
tests/simple_unit/SqlMap/SelectKeyTest.php -text
tests/simple_unit/SqlMap/SqlMapCacheTest.php -text
+tests/simple_unit/SqlMap/StatementExtendsTest.php -text
tests/simple_unit/SqlMap/StatementTest.php -text
tests/simple_unit/SqlMap/common.php -text
tests/simple_unit/SqlMap/domain/A.php -text
@@ -2511,6 +2512,7 @@ tests/simple_unit/SqlMap/maps/sqlite/LineItem.xml -text
tests/simple_unit/SqlMap/maps/sqlite/Order.xml -text
tests/simple_unit/SqlMap/maps/sqlite/Other.xml -text
tests/simple_unit/SqlMap/maps/sqlite/ResultClass.xml -text
+tests/simple_unit/SqlMap/maps/tests.xml -text
tests/simple_unit/SqlMap/mssql.xml -text
tests/simple_unit/SqlMap/mysql.xml -text
tests/simple_unit/SqlMap/properties.config -text
diff --git a/framework/Data/SqlMap/Statements/TMappedStatement.php b/framework/Data/SqlMap/Statements/TMappedStatement.php
index feba00a4..e56e73ce 100644
--- a/framework/Data/SqlMap/Statements/TMappedStatement.php
+++ b/framework/Data/SqlMap/Statements/TMappedStatement.php
@@ -122,6 +122,11 @@ class TMappedStatement extends TComponent implements IMappedStatement
$this->initialGroupByResults();
}
+ public function getSqlString()
+ {
+ return $this->getStatement()->getSqlText()->getPreparedStatement()->getPreparedSql();
+ }
+
/**
* Execute SQL Query.
* @param IDbConnection database connection
diff --git a/tests/simple_unit/SqlMap/StatementExtendsTest.php b/tests/simple_unit/SqlMap/StatementExtendsTest.php
new file mode 100644
index 00000000..4d87ca58
--- /dev/null
+++ b/tests/simple_unit/SqlMap/StatementExtendsTest.php
@@ -0,0 +1,29 @@
+<?php
+
+Prado::using('System.Data.SqlMap.TSqlMapConfig');
+class StatementExtendsTest extends UnitTestCase
+{
+ protected $sqlmap;
+
+ function setup()
+ {
+ $config = new TSqlMapConfig();
+ $config->ConfigFile = dirname(__FILE__).'/maps/tests.xml';
+ $this->sqlmap = $config->getClient();
+ }
+
+ function test_extends1()
+ {
+ $manager = $this->sqlmap->SqlMapManager;
+ $sql = $manager->getMappedStatement('test')->getSqlString();
+
+ $this->assertPattern('/img_request/', $sql);
+ $this->assertNoPattern('/img_progress/', $sql);
+
+ $sql2 = $manager->getMappedStatement('GetAllProgress')->getSqlString();
+ $this->assertPattern('/img_request/', $sql2);
+ $this->assertPattern('/img_progress/', $sql2);
+ }
+}
+
+?> \ No newline at end of file
diff --git a/tests/simple_unit/SqlMap/common.php b/tests/simple_unit/SqlMap/common.php
index aed11671..f414ad50 100644
--- a/tests/simple_unit/SqlMap/common.php
+++ b/tests/simple_unit/SqlMap/common.php
@@ -143,9 +143,9 @@ class BaseTestConfig
{
//change this to connection to a different database
- return new MySQLBaseTestConfig();
+ //return new MySQLBaseTestConfig();
- //return new SQLiteBaseTestConfig();
+ return new SQLiteBaseTestConfig();
//return new MSSQLBaseTestConfig();
}
diff --git a/tests/simple_unit/SqlMap/maps/tests.xml b/tests/simple_unit/SqlMap/maps/tests.xml
new file mode 100644
index 00000000..5e93cae4
--- /dev/null
+++ b/tests/simple_unit/SqlMap/maps/tests.xml
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8" ?>
+<sqlmap>
+
+<statement id="test" parameterClass="array" >
+ <![CDATA[
+ SELECT a.*, b.*
+ FROM img_request a
+ left join hello_mst b on a.img_pat_id=b.pat_id
+ WHERE (img_requested_ap_dt >= #fromdt# and img_requested_ap_dt <= #todt#)
+ ]]>
+</statement>
+
+<select id="GetAllProgress" parameterClass="array" extends="test">
+ <![CDATA[
+ AND img_progress =#status#
+ ]]>
+</select>
+
+</sqlmap> \ No newline at end of file