summaryrefslogtreecommitdiff
path: root/tests/unit/SQLMap/PropertyAccessTest.php
diff options
context:
space:
mode:
authorwei <>2006-04-14 11:23:56 +0000
committerwei <>2006-04-14 11:23:56 +0000
commitf6a5e7589396854e10e023c25237b47e512ff047 (patch)
tree2b313bb8b66869235ee06b9cae2af2f7645cf5c9 /tests/unit/SQLMap/PropertyAccessTest.php
parent3d3f8d3832921f99daf8ce1953304763c2e76c62 (diff)
Adding SQLMap unit tests. Allow sqlmap to use Prado's caching module to cache records.
Diffstat (limited to 'tests/unit/SQLMap/PropertyAccessTest.php')
-rw-r--r--tests/unit/SQLMap/PropertyAccessTest.php78
1 files changed, 78 insertions, 0 deletions
diff --git a/tests/unit/SQLMap/PropertyAccessTest.php b/tests/unit/SQLMap/PropertyAccessTest.php
new file mode 100644
index 00000000..96b942dc
--- /dev/null
+++ b/tests/unit/SQLMap/PropertyAccessTest.php
@@ -0,0 +1,78 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseTest.php');
+
+/**
+ * @package System.DataAccess.SQLMap
+ */
+class PropertyAccessTest extends BaseTest
+{
+
+ function testGetPublicProperty()
+ {
+ $account = new AccountBis();
+
+ $account->Id = 10;
+ $account->FirstName = "Luky";
+ $account->LastName = "Luke";
+ $account->EmailAddress = "luly.luke@somewhere.com";
+
+ $two = new AccountBis();
+ $two->Id = 12;
+ $two->FirstName = "Mini Me!";
+ $account->More = $two;
+
+ $account6 = $this->NewAccount6();
+ $two->More = $account6;
+
+ $this->assertEquals(10, TPropertyAccess::get($account, 'Id'));
+ $this->assertEquals(12, TPropertyAccess::get($account, 'More.Id'));
+ $this->assertEquals(6, TPropertyAccess::get($account, 'More.More.Id'));
+ }
+
+ function testSetPublicProperty()
+ {
+ $account = new AccountBis();
+
+ $account->Id = 10;
+ $account->FirstName = "Luky";
+ $account->LastName = "Luke";
+ $account->EmailAddress = "luly.luke@somewhere.com";
+
+ $two = new AccountBis();
+ $two->Id = 12;
+ $two->FirstName = "Mini Me!";
+ TPropertyAccess::set($account, 'More', $two);
+
+ $account6 = $this->NewAccount6();
+ TPropertyAccess::set($account, 'More.More', $account6);
+
+ TPropertyAccess::set($account, 'More.More.EmailAddress', 'hahaha');
+
+ $this->assertEquals(10, TPropertyAccess::get($account, 'Id'));
+ $this->assertEquals(12, TPropertyAccess::get($account, 'More.Id'));
+ $this->assertEquals(6, TPropertyAccess::get($account, 'More.More.Id'));
+
+ $this->assertEquals('hahaha',
+ TPropertyAccess::get($account, 'More.More.EmailAddress'));
+ }
+
+ function testArrayAccessProperty()
+ {
+ $account = new AccountBis();
+ $things['more'] = 1;
+ $things['accounts'] = $this->NewAccount6();
+ $account->More = $things;
+
+ $this->assertEquals(6, TPropertyAccess::get($account, 'More.accounts.ID'));
+
+ TPropertyAccess::set($account, 'More.accounts.EmailAddress', 'adssd');
+ $this->assertEquals('adssd', TPropertyAccess::get($account, 'More.accounts.EmailAddress'));
+
+ $this->assertEquals(1, TPropertyAccess::get($things, 'more'));
+ }
+
+}
+
+
+?> \ No newline at end of file