summaryrefslogtreecommitdiff
path: root/tests/unit/Data/SqlMap/PropertyAccessTest.php
diff options
context:
space:
mode:
authorFabio Bas <ctrlaltca@gmail.com>2016-03-25 17:55:51 +0100
committerFabio Bas <ctrlaltca@gmail.com>2016-03-25 17:55:51 +0100
commita3388622287e218beddfa14a47ed677d4307b36b (patch)
tree1b4c7ac8597b1cc798b6683d4a81c90d38de12f6 /tests/unit/Data/SqlMap/PropertyAccessTest.php
parentc7fd3e1167b6f2fa7746edbd0fb8f8c1694c61f9 (diff)
Removed simpletest and moved all tests in the unit tree
Tests are executed now, but a lot of them need fixing.
Diffstat (limited to 'tests/unit/Data/SqlMap/PropertyAccessTest.php')
-rw-r--r--tests/unit/Data/SqlMap/PropertyAccessTest.php75
1 files changed, 75 insertions, 0 deletions
diff --git a/tests/unit/Data/SqlMap/PropertyAccessTest.php b/tests/unit/Data/SqlMap/PropertyAccessTest.php
new file mode 100644
index 00000000..eb8306d5
--- /dev/null
+++ b/tests/unit/Data/SqlMap/PropertyAccessTest.php
@@ -0,0 +1,75 @@
+<?php
+
+require_once(dirname(__FILE__).'/BaseCase.php');
+
+/**
+ * @package System.Data.SqlMap
+ */
+class PropertyAccessTest extends BaseCase
+{
+ 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->assertIdentical(10, TPropertyAccess::get($account, 'Id'));
+ $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id'));
+ $this->assertIdentical(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->assertIdentical(10, TPropertyAccess::get($account, 'Id'));
+ $this->assertIdentical(12, TPropertyAccess::get($account, 'More.Id'));
+ $this->assertIdentical(6, TPropertyAccess::get($account, 'More.More.Id'));
+
+ $this->assertIdentical('hahaha',
+ TPropertyAccess::get($account, 'More.More.EmailAddress'));
+ }
+
+ function testArrayAccessProperty()
+ {
+ $account = new AccountBis();
+ $things['more'] = 1;
+ $things['accounts'] = $this->NewAccount6();
+ $account->More = $things;
+
+ $this->assertIdentical(6, TPropertyAccess::get($account, 'More.accounts.ID'));
+
+ TPropertyAccess::set($account, 'More.accounts.EmailAddress', 'adssd');
+ $this->assertIdentical('adssd', TPropertyAccess::get($account, 'More.accounts.EmailAddress'));
+
+ $this->assertIdentical(1, TPropertyAccess::get($things, 'more'));
+ }
+
+}
+