diff options
author | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
---|---|---|
committer | ctrlaltca <> | 2012-07-12 11:21:01 +0000 |
commit | 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 (patch) | |
tree | e08bf04f0823650a231227ac3499121270172a23 /tests/unit/SQLMap/ParameterMapTest.php | |
parent | 3e4e6e66aeb3f8fea4e1eb4237498ef9d2358f63 (diff) |
standardize the use of unix eol; use svn properties to enforce native eol
Diffstat (limited to 'tests/unit/SQLMap/ParameterMapTest.php')
-rw-r--r-- | tests/unit/SQLMap/ParameterMapTest.php | 496 |
1 files changed, 248 insertions, 248 deletions
diff --git a/tests/unit/SQLMap/ParameterMapTest.php b/tests/unit/SQLMap/ParameterMapTest.php index 5b3c3006..130b1505 100644 --- a/tests/unit/SQLMap/ParameterMapTest.php +++ b/tests/unit/SQLMap/ParameterMapTest.php @@ -1,249 +1,249 @@ -<?php
-
-require_once(dirname(__FILE__).'/BaseTest.php');
-
-/**
- * @package System.DataAccess.SQLMap
- */
-class ParameterMapTest extends BaseTest
-{
- function __construct()
- {
- parent::__construct();
- $this->initSqlMap();
- }
-
- function setup()
- {
- $this->initScript('account-init.sql');
-// $this->initScript('account-procedure.sql');
- $this->initScript('order-init.sql');
-// $this->initScript('line-item-init.sql');
- $this->initScript('category-init.sql');
- }
-
- /// Test null replacement in ParameterMap property
- function testNullValueReplacement()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
-
- $this->assertNull($account->getEmailAddress(), 'no_email@provided.com');
-
- $this->assertAccount6($account);
- }
-
- /// Test Test Null Value Replacement Inline
- function testNullValueReplacementInline()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaInlineParameters", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertNull($account->getEmailAddress());
-
- $this->assertAccount6($account);
- }
-
- /// Test Test Null Value Replacement Inline
- function testSpecifiedType()
- {
- $account = $this->newAccount6();
- $account->setEmailAddress(null);
- $this->sqlmap->insert("InsertAccountNullableEmail", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertAccount6($account);
- }
-
-
- /// Test Test Null Value Replacement Inline
- function testUnknownParameterClass()
- {
- $account = $this->newAccount6();
- $account->setEmailAddress(null);
- $this->sqlmap->insert("InsertAccountUknownParameterClass", $account);
- $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6);
- $this->assertAccount6($account);
- }
-
-
- /// Test null replacement in ParameterMap property
- /// for System.DateTime.MinValue
- function testNullValueReplacementForDateTimeMinValue()
- {
- $account = $this->newAccount6();
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(null);
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
-
- $this->assertEquals($order->getCity(), $orderTest->getCity());
- }
-
- /// Test null replacement in ParameterMap/Hahstable property
- /// for System.DateTime.MinValue
- function testNullValueReplacementForDateTimeWithHashtable()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate('0001-01-01 00:00:00'); //<-- null replacement
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderByHashTable", 99);
-
- $this->assertEquals($orderTest["Date"], '0001-01-01 00:00:00');
- }
-
- /// Test null replacement in ParameterMap property
- /// for Guid
- function testNullValueReplacementForGuidValue()
- {
- if($this->hasSupportFor('last_insert_id'))
- {
- $category = new Category();
- $category->setName("Totoasdasd");
- $category->setGuidString('00000000-0000-0000-0000-000000000000');
-
- $key = $this->sqlmap->insert("InsertCategoryNull", $category);
-
- $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key);
-
- $this->assertEquals($category->getName(), $categoryRead->getName());
- $this->assertEquals('', $categoryRead->getGuidString());
- }
- }
-
-
-
-/// Test complex mapping Via hasTable
- /// <example>
- ///
- /// map.Add("Item", Item);
- /// map.Add("Order", Order);
- ///
- /// <statement>
- /// ... #Item.prop1#...#Order.prop2#
- /// </statement>
- ///
- /// </example>
- function testComplexMappingViaHasTable()
- {
- $a = new Account();
- $a->setFirstName("Joe");
-
- $param["Account"] = $a;
-
- $o = new Order();
- $o->setCity("Dalton");
- $param["Order"] = $o;
-
- $accountTest = $this->sqlmap->queryForObject("GetAccountComplexMapping", $param);
-
- $this->assertAccount1($accountTest);
- }
-
-/*
- /// Test ByteArrayTypeHandler via Picture Property
- function testByteArrayTypeHandler()
- {
- $account = $this->newAccount6();
-
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(0);
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaParameterMap", $order);
-
- $item = new LineItem();
- $item->setId(99);
- $item->setCode("test");
- $item->setPrice(-99.99);
- $item->setQuantity(99);
- $item->setOrder($order);
- $item->setPicture(null);
-
- // Check insert
- $this->sqlmap->insert("InsertLineItemWithPicture", $item);
-
- // select
- $item = null;
-
- $param["LineItem_ID"] = 99;
- $param["Order_ID"] = 99;
-
- $item = $this->sqlmap->queryForObject("GetSpecificLineItemWithPicture", $param);
-
- $this->assertNotNull($item->getId());
-// $this->assertNotNull($item->getPicture());
-// $this->assertEquals( GetSize(item.Picture), this.GetSize( this.GetPicture() ));
- }
-*/
-
- /// Test extend parameter map capacity
- /// (Support Requests 1043181)
- function testInsertOrderViaExtendParameterMap()
- {
- $this->sqlmap->getTypeHandlerFactory()->register('HundredsBool', new HundredsBool());
-
- $account = $this->newAccount6();
- $this->sqlmap->insert("InsertAccountViaParameterMap", $account);
-
- $order = new Order();
- $order->setId(99);
- $order->setCardExpiry("09/11");
- $order->setAccount($account);
- $order->setCardNumber("154564656");
- $order->setCardType("Visa");
- $order->setCity("Lyon");
- $order->setDate(null); //<-- null replacement
- $order->setPostalCode("69004");
- $order->setProvince("Rhone");
- $order->setStreet("rue Durand");
-
- $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order);
-
- $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99);
-
- $this->assertEquals($order->getCity(), $orderTest->getCity());
- }
-/**/
-}
-
+<?php + +require_once(dirname(__FILE__).'/BaseTest.php'); + +/** + * @package System.DataAccess.SQLMap + */ +class ParameterMapTest extends BaseTest +{ + function __construct() + { + parent::__construct(); + $this->initSqlMap(); + } + + function setup() + { + $this->initScript('account-init.sql'); +// $this->initScript('account-procedure.sql'); + $this->initScript('order-init.sql'); +// $this->initScript('line-item-init.sql'); + $this->initScript('category-init.sql'); + } + + /// Test null replacement in ParameterMap property + function testNullValueReplacement() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + + $this->assertNull($account->getEmailAddress(), 'no_email@provided.com'); + + $this->assertAccount6($account); + } + + /// Test Test Null Value Replacement Inline + function testNullValueReplacementInline() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaInlineParameters", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertNull($account->getEmailAddress()); + + $this->assertAccount6($account); + } + + /// Test Test Null Value Replacement Inline + function testSpecifiedType() + { + $account = $this->newAccount6(); + $account->setEmailAddress(null); + $this->sqlmap->insert("InsertAccountNullableEmail", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertAccount6($account); + } + + + /// Test Test Null Value Replacement Inline + function testUnknownParameterClass() + { + $account = $this->newAccount6(); + $account->setEmailAddress(null); + $this->sqlmap->insert("InsertAccountUknownParameterClass", $account); + $account = $this->sqlmap->queryForObject("GetAccountNullableEmail", 6); + $this->assertAccount6($account); + } + + + /// Test null replacement in ParameterMap property + /// for System.DateTime.MinValue + function testNullValueReplacementForDateTimeMinValue() + { + $account = $this->newAccount6(); + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(null); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99); + + $this->assertEquals($order->getCity(), $orderTest->getCity()); + } + + /// Test null replacement in ParameterMap/Hahstable property + /// for System.DateTime.MinValue + function testNullValueReplacementForDateTimeWithHashtable() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate('0001-01-01 00:00:00'); //<-- null replacement + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderByHashTable", 99); + + $this->assertEquals($orderTest["Date"], '0001-01-01 00:00:00'); + } + + /// Test null replacement in ParameterMap property + /// for Guid + function testNullValueReplacementForGuidValue() + { + if($this->hasSupportFor('last_insert_id')) + { + $category = new Category(); + $category->setName("Totoasdasd"); + $category->setGuidString('00000000-0000-0000-0000-000000000000'); + + $key = $this->sqlmap->insert("InsertCategoryNull", $category); + + $categoryRead = $this->sqlmap->queryForObject("GetCategory", $key); + + $this->assertEquals($category->getName(), $categoryRead->getName()); + $this->assertEquals('', $categoryRead->getGuidString()); + } + } + + + +/// Test complex mapping Via hasTable + /// <example> + /// + /// map.Add("Item", Item); + /// map.Add("Order", Order); + /// + /// <statement> + /// ... #Item.prop1#...#Order.prop2# + /// </statement> + /// + /// </example> + function testComplexMappingViaHasTable() + { + $a = new Account(); + $a->setFirstName("Joe"); + + $param["Account"] = $a; + + $o = new Order(); + $o->setCity("Dalton"); + $param["Order"] = $o; + + $accountTest = $this->sqlmap->queryForObject("GetAccountComplexMapping", $param); + + $this->assertAccount1($accountTest); + } + +/* + /// Test ByteArrayTypeHandler via Picture Property + function testByteArrayTypeHandler() + { + $account = $this->newAccount6(); + + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(0); + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaParameterMap", $order); + + $item = new LineItem(); + $item->setId(99); + $item->setCode("test"); + $item->setPrice(-99.99); + $item->setQuantity(99); + $item->setOrder($order); + $item->setPicture(null); + + // Check insert + $this->sqlmap->insert("InsertLineItemWithPicture", $item); + + // select + $item = null; + + $param["LineItem_ID"] = 99; + $param["Order_ID"] = 99; + + $item = $this->sqlmap->queryForObject("GetSpecificLineItemWithPicture", $param); + + $this->assertNotNull($item->getId()); +// $this->assertNotNull($item->getPicture()); +// $this->assertEquals( GetSize(item.Picture), this.GetSize( this.GetPicture() )); + } +*/ + + /// Test extend parameter map capacity + /// (Support Requests 1043181) + function testInsertOrderViaExtendParameterMap() + { + $this->sqlmap->getTypeHandlerFactory()->register('HundredsBool', new HundredsBool()); + + $account = $this->newAccount6(); + $this->sqlmap->insert("InsertAccountViaParameterMap", $account); + + $order = new Order(); + $order->setId(99); + $order->setCardExpiry("09/11"); + $order->setAccount($account); + $order->setCardNumber("154564656"); + $order->setCardType("Visa"); + $order->setCity("Lyon"); + $order->setDate(null); //<-- null replacement + $order->setPostalCode("69004"); + $order->setProvince("Rhone"); + $order->setStreet("rue Durand"); + + $this->sqlmap->insert("InsertOrderViaExtendParameterMap", $order); + + $orderTest = $this->sqlmap->queryForObject("GetOrderLiteByColumnName", 99); + + $this->assertEquals($order->getCity(), $orderTest->getCity()); + } +/**/ +} + ?>
\ No newline at end of file |