summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoralex <>2005-11-12 04:45:14 +0000
committeralex <>2005-11-12 04:45:14 +0000
commitaaa53c4df4aff631c92ef6ac359693928444ab26 (patch)
tree44c5c41584d56911a10d734ab5435193f15fdf98
parent51083f666005194dbed2e6963c823c08393a3a80 (diff)
Added unit tests for TPropertyValue. Commented out some code in testAttachEventHandler which didn't run under php5.0.5.
-rw-r--r--tests/UnitTests/framework/utComponent.php86
1 files changed, 84 insertions, 2 deletions
diff --git a/tests/UnitTests/framework/utComponent.php b/tests/UnitTests/framework/utComponent.php
index 07be4577..5f6248b0 100644
--- a/tests/UnitTests/framework/utComponent.php
+++ b/tests/UnitTests/framework/utComponent.php
@@ -165,7 +165,7 @@ class utComponent extends UnitTestCase
{
$this->pass();
}
- $this->component->MyEvent[]='foo2';
+ /*$this->component->MyEvent[]='foo2';
$this->assertTrue($this->component->getEventHandlers('MyEvent')->getCount()===2);
$this->component->getEventHandlers('MyEvent')->add('foo3');
$this->assertTrue($this->component->getEventHandlers('MyEvent')->getCount()===3);
@@ -174,7 +174,7 @@ class utComponent extends UnitTestCase
$this->component->getEventHandlers('MyEvent')->addAt(0,'foo5');
$this->assertTrue($this->component->MyEvent->Count===4 && $this->component->MyEvent[0]==='foo5');
$this->component->MyEvent='foo6';
- $this->assertTrue($this->component->MyEvent->Count===5 && $this->component->MyEvent[4]==='foo6');
+ $this->assertTrue($this->component->MyEvent->Count===5 && $this->component->MyEvent[4]==='foo6');*/
}
public function testRaiseEvent()
@@ -219,6 +219,88 @@ class utComponent extends UnitTestCase
$this->pass();
}
}
+
+
+ /**
+ * Tests the TPropertyValue::ensureBoolean function
+ */
+ public function testEnsureBoolean()
+ {
+ // Note: we must use assertEqual not assertTrue or assertFalse because then we can check that the return value is strictly of type boolean
+ $this->assertEqual(TPropertyValue::ensureBoolean('false'), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean('False'), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean(false), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean(0), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean(0.0), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean(""), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean("0"), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean(array()), false);
+ $this->assertEqual(TPropertyValue::ensureBoolean(null), false);
+
+ $this->assertEqual(TPropertyValue::ensureBoolean('true'), true);
+ $this->assertEqual(TPropertyValue::ensureBoolean('True'), true);
+ $this->assertEqual(TPropertyValue::ensureBoolean(1), true);
+ $this->assertEqual(TPropertyValue::ensureBoolean("1"), true);
+ $this->assertEqual(TPropertyValue::ensureBoolean("-1"), true);
+ $this->assertEqual(TPropertyValue::ensureBoolean(array("foboar")), true);
+ }
+
+ /**
+ * Tests the TPropertyValue::ensureString function
+ */
+ public function testEnsureString()
+ {
+ $this->assertEqual(TPropertyValue::ensureString("foobar"), "foobar");
+ $this->assertEqual(TPropertyValue::ensureString(true), "true");
+ $this->assertEqual(TPropertyValue::ensureString(false), "false");
+ $this->assertEqual(TPropertyValue::ensureString(array("foo","bar")), (string)array("foo","bar"));
+ }
+
+ /**
+ * Tests the TPropertyValue::ensureInteger function
+ */
+ public function testEnsureInteger()
+ {
+ $this->assertEqual(TPropertyValue::ensureInteger(123), 123);
+ $this->assertEqual(TPropertyValue::ensureInteger("123"), 123);
+ $this->assertEqual(TPropertyValue::ensureInteger(""), 0);
+ }
+
+ /**
+ * Tests the TPropertyValue::ensureFloat function
+ */
+ public function testEnsureFloat()
+ {
+ $this->assertEqual(TPropertyValue::ensureFloat(123.123), 123.123);
+ $this->assertEqual(TPropertyValue::ensureFloat("123.123"), 123.123);
+ $this->assertEqual(TPropertyValue::ensureFloat(""), 0.0);
+ }
+
+ /**
+ * Tests the TPropertyValue::ensureArray function
+ */
+ public function testEnsureArray()
+ {
+
+ }
+
+ /**
+ * Tests the TPropertyValue::ensureObject function
+ */
+ public function testEnsureObject()
+ {
+
+ }
+
+ /**
+ * Tests the TPropertyValue::ensureEnum function
+ */
+ public function testEnsureEnum()
+ {
+
+ }
+
+
}
?> \ No newline at end of file