summaryrefslogtreecommitdiff
path: root/tests/unit/Data/SqlMap
diff options
context:
space:
mode:
Diffstat (limited to 'tests/unit/Data/SqlMap')
-rw-r--r--tests/unit/Data/SqlMap/AllTests.php60
-rw-r--r--tests/unit/Data/SqlMap/DynamicParameterTest.php216
2 files changed, 138 insertions, 138 deletions
diff --git a/tests/unit/Data/SqlMap/AllTests.php b/tests/unit/Data/SqlMap/AllTests.php
index 66f02608..2f820f83 100644
--- a/tests/unit/Data/SqlMap/AllTests.php
+++ b/tests/unit/Data/SqlMap/AllTests.php
@@ -1,30 +1,30 @@
-<?php
-require_once dirname(__FILE__).'/../../phpunit.php';
-
-if(!defined('PHPUnit_MAIN_METHOD')) {
- define('PHPUnit_MAIN_METHOD', 'Data_SqlMap_AllTests::main');
-}
-
-require_once 'DynamicParameterTest.php';
-require_once 'DataMapper/AllTests.php';
-
-class Data_SqlMap_AllTests {
-
- public static function main() {
- PHPUnit_TextUI_TestRunner::run(self::suite());
- }
-
- public static function suite() {
- $suite = new PHPUnit_Framework_TestSuite('System.Data.SqlMap');
-
- $suite->addTestSuite('DynamicParameterTest');
- $suite -> addTest( Data_SqlMap_DataMapper_AllTests::suite() );
-
- return $suite;
- }
-}
-
-if(PHPUnit_MAIN_METHOD == 'Data_SqlMap_AllTests::main') {
- Data_SqlMap_AllTests::main();
-}
-?>
+<?php
+require_once dirname(__FILE__).'/../../phpunit.php';
+
+if(!defined('PHPUnit_MAIN_METHOD')) {
+ define('PHPUnit_MAIN_METHOD', 'Data_SqlMap_AllTests::main');
+}
+
+require_once 'DynamicParameterTest.php';
+require_once 'DataMapper/AllTests.php';
+
+class Data_SqlMap_AllTests {
+
+ public static function main() {
+ PHPUnit_TextUI_TestRunner::run(self::suite());
+ }
+
+ public static function suite() {
+ $suite = new PHPUnit_Framework_TestSuite('System.Data.SqlMap');
+
+ $suite->addTestSuite('DynamicParameterTest');
+ $suite -> addTest( Data_SqlMap_DataMapper_AllTests::suite() );
+
+ return $suite;
+ }
+}
+
+if(PHPUnit_MAIN_METHOD == 'Data_SqlMap_AllTests::main') {
+ Data_SqlMap_AllTests::main();
+}
+?>
diff --git a/tests/unit/Data/SqlMap/DynamicParameterTest.php b/tests/unit/Data/SqlMap/DynamicParameterTest.php
index f9b39b96..0bd5334e 100644
--- a/tests/unit/Data/SqlMap/DynamicParameterTest.php
+++ b/tests/unit/Data/SqlMap/DynamicParameterTest.php
@@ -1,109 +1,109 @@
-<?php
-require_once dirname(__FILE__).'/../../phpunit.php';
-
-Prado::using('System.Data.*');
-Prado::using('System.Data.SqlMap.*');
-
-/**
- * @package System.Data.SqlMap
- */
-class DynamicParameterTest extends PHPUnit_Framework_TestCase
-{
-
- protected function getMysqlSqlMapManager()
- {
- static $conn;
- static $sqlMapManager;
-
- if(Prado::getApplication() === null)
- Prado::setApplication(new TApplication(dirname(__FILE__).'/app'));
-
- if($conn === null)
- $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest');
-
- $conn->setActive(true);
-
- if($sqlMapManager === null)
- {
- $sqlMapManager = new TSqlMapManager($conn);
- $sqlMapManager->configureXml( dirname(__FILE__) . '/DynamicParameterTestMap.xml');
- }
-
- return $sqlMapManager;
- }
-
- public function testMysqlSelectStaticSql()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectStaticSql1');
- self::assertEquals('staticsql1', $value);
-
- $value = $gateway->queryForObject('SelectStaticSql2');
- self::assertEquals('staticsql2', $value);
- }
-
- public function testMysqlSelectDynamicTable()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest1');
- self::assertEquals('dynamictableparametertest1', $value);
-
- $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest2');
- self::assertEquals('dynamictableparametertest2', $value);
- }
-
- public function testMysqlSelectDynamicComplex()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $aParams = array(
- 'tablename' => 'dynamicparametertest1',
- 'testname' => 'dynamictable'
- );
- $value = $gateway->queryForObject('SelectDynamicComplex', $aParams);
- self::assertEquals('#dynamictableparametertest1$', $value);
-
- $aParams = array(
- 'tablename' => 'dynamicparametertest2',
- 'testname' => 'dynamictable'
- );
- $value = $gateway->queryForObject('SelectDynamicComplex', $aParams);
- self::assertEquals('#dynamictableparametertest2$', $value);
- }
-
- public function testMysqlSelectNoDynamic()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectNoDynamic', 'dynamictable');
- self::assertEquals('dynamictableparametertest1', $value);
-
- $value = $gateway->queryForObject('SelectNoDynamic', 'staticsql');
- self::assertEquals('staticsql1', $value);
- }
-
- /**
- * Issue#209 test
- */
- public function testMysqlInlineEscapeParam()
- {
- $mapper = $this->getMysqlSqlMapManager();
- $gateway = $mapper->getSqlmapGateway();
-
- $value = $gateway->queryForObject('SelectInlineEscapeParam', "'1234567*123$456789$012345' AS foobar");
- self::assertEquals('1234567*123$456789$012345', $value);
-
- $value = $gateway->queryForObject('SelectInlineEscapeParam', '"1234567*123$456789$012345" AS foobar');
- self::assertEquals('1234567*123$456789$012345', $value);
-
- }
-
-}
-
+<?php
+require_once dirname(__FILE__).'/../../phpunit.php';
+
+Prado::using('System.Data.*');
+Prado::using('System.Data.SqlMap.*');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class DynamicParameterTest extends PHPUnit_Framework_TestCase
+{
+
+ protected function getMysqlSqlMapManager()
+ {
+ static $conn;
+ static $sqlMapManager;
+
+ if(Prado::getApplication() === null)
+ Prado::setApplication(new TApplication(dirname(__FILE__).'/app'));
+
+ if($conn === null)
+ $conn = new TDbConnection('mysql:host=localhost;dbname=prado_system_data_sqlmap', 'prado_unitest', 'prado_system_data_sqlmap_unitest');
+
+ $conn->setActive(true);
+
+ if($sqlMapManager === null)
+ {
+ $sqlMapManager = new TSqlMapManager($conn);
+ $sqlMapManager->configureXml( dirname(__FILE__) . '/DynamicParameterTestMap.xml');
+ }
+
+ return $sqlMapManager;
+ }
+
+ public function testMysqlSelectStaticSql()
+ {
+ $mapper = $this->getMysqlSqlMapManager();
+ $gateway = $mapper->getSqlmapGateway();
+
+ $value = $gateway->queryForObject('SelectStaticSql1');
+ self::assertEquals('staticsql1', $value);
+
+ $value = $gateway->queryForObject('SelectStaticSql2');
+ self::assertEquals('staticsql2', $value);
+ }
+
+ public function testMysqlSelectDynamicTable()
+ {
+ $mapper = $this->getMysqlSqlMapManager();
+ $gateway = $mapper->getSqlmapGateway();
+
+ $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest1');
+ self::assertEquals('dynamictableparametertest1', $value);
+
+ $value = $gateway->queryForObject('SelectDynamicTable', 'dynamicparametertest2');
+ self::assertEquals('dynamictableparametertest2', $value);
+ }
+
+ public function testMysqlSelectDynamicComplex()
+ {
+ $mapper = $this->getMysqlSqlMapManager();
+ $gateway = $mapper->getSqlmapGateway();
+
+ $aParams = array(
+ 'tablename' => 'dynamicparametertest1',
+ 'testname' => 'dynamictable'
+ );
+ $value = $gateway->queryForObject('SelectDynamicComplex', $aParams);
+ self::assertEquals('#dynamictableparametertest1$', $value);
+
+ $aParams = array(
+ 'tablename' => 'dynamicparametertest2',
+ 'testname' => 'dynamictable'
+ );
+ $value = $gateway->queryForObject('SelectDynamicComplex', $aParams);
+ self::assertEquals('#dynamictableparametertest2$', $value);
+ }
+
+ public function testMysqlSelectNoDynamic()
+ {
+ $mapper = $this->getMysqlSqlMapManager();
+ $gateway = $mapper->getSqlmapGateway();
+
+ $value = $gateway->queryForObject('SelectNoDynamic', 'dynamictable');
+ self::assertEquals('dynamictableparametertest1', $value);
+
+ $value = $gateway->queryForObject('SelectNoDynamic', 'staticsql');
+ self::assertEquals('staticsql1', $value);
+ }
+
+ /**
+ * Issue#209 test
+ */
+ public function testMysqlInlineEscapeParam()
+ {
+ $mapper = $this->getMysqlSqlMapManager();
+ $gateway = $mapper->getSqlmapGateway();
+
+ $value = $gateway->queryForObject('SelectInlineEscapeParam', "'1234567*123$456789$012345' AS foobar");
+ self::assertEquals('1234567*123$456789$012345', $value);
+
+ $value = $gateway->queryForObject('SelectInlineEscapeParam', '"1234567*123$456789$012345" AS foobar');
+ self::assertEquals('1234567*123$456789$012345', $value);
+
+ }
+
+}
+
?> \ No newline at end of file