From 903ae8a581fac1e6917fc3e31d2ad8fb91df80c3 Mon Sep 17 00:00:00 2001 From: ctrlaltca <> Date: Thu, 12 Jul 2012 11:21:01 +0000 Subject: standardize the use of unix eol; use svn properties to enforce native eol --- tests/unit/SQLMap/ParameterMapTest.php | 496 ++++++++++++++++----------------- 1 file changed, 248 insertions(+), 248 deletions(-) (limited to 'tests/unit/SQLMap/ParameterMapTest.php') 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 @@ -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 - /// - /// - /// map.Add("Item", Item); - /// map.Add("Order", Order); - /// - /// - /// ... #Item.prop1#...#Order.prop2# - /// - /// - /// - 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()); - } -/**/ -} - +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 + /// + /// + /// map.Add("Item", Item); + /// map.Add("Order", Order); + /// + /// + /// ... #Item.prop1#...#Order.prop2# + /// + /// + /// + 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 -- cgit v1.2.3