From 55c4ac1bfe565f1ca7f537fdd8b7a201be28e581 Mon Sep 17 00:00:00 2001 From: xue <> Date: Thu, 10 Nov 2005 12:47:19 +0000 Subject: Initial import of prado framework --- tests/UnitTests/simpletest/test/options_test.php | 95 ++++++++++++++++++++++++ 1 file changed, 95 insertions(+) create mode 100644 tests/UnitTests/simpletest/test/options_test.php (limited to 'tests/UnitTests/simpletest/test/options_test.php') diff --git a/tests/UnitTests/simpletest/test/options_test.php b/tests/UnitTests/simpletest/test/options_test.php new file mode 100644 index 00000000..8535f739 --- /dev/null +++ b/tests/UnitTests/simpletest/test/options_test.php @@ -0,0 +1,95 @@ +assertEqual(SimpleTestOptions::getMockBaseClass(), 'Fred'); + SimpleTestOptions::setMockBaseClass($old_class); + } + + function testStubBase() { + $old_class = SimpleTestOptions::getStubBaseClass(); + SimpleTestOptions::setStubBaseClass('Fred'); + $this->assertEqual(SimpleTestOptions::getStubBaseClass(), 'Fred'); + SimpleTestOptions::setStubBaseClass($old_class); + } + + function testIgnoreList() { + $this->assertFalse(SimpleTestOptions::isIgnored('ImaginaryTestCase')); + SimpleTestOptions::ignore('ImaginaryTestCase'); + $this->assertTrue(SimpleTestOptions::isIgnored('ImaginaryTestCase')); + } + } + + class ComparisonClass { + } + + class ComparisonSubclass extends ComparisonClass { + } + + class TestOfCompatibility extends UnitTestCase { + + function testIsA() { + $this->assertTrue(SimpleTestCompatibility::isA( + new ComparisonClass(), + 'ComparisonClass')); + $this->assertFalse(SimpleTestCompatibility::isA( + new ComparisonClass(), + 'ComparisonSubclass')); + $this->assertTrue(SimpleTestCompatibility::isA( + new ComparisonSubclass(), + 'ComparisonClass')); + } + + function testIdentityOfObjects() { + $object1 = new ComparisonClass(); + $object2 = new ComparisonClass(); + $this->assertIdentical($object1, $object2); + } + + function testReferences () { + $thing = "Hello"; + $thing_reference = &$thing; + $thing_copy = $thing; + $this->assertTrue(SimpleTestCompatibility::isReference( + $thing, + $thing)); + $this->assertTrue(SimpleTestCompatibility::isReference( + $thing, + $thing_reference)); + $this->assertFalse(SimpleTestCompatibility::isReference( + $thing, + $thing_copy)); + } + + function testObjectReferences () { + $object = &new ComparisonClass(); + $object_reference = &$object; + $object_copy = new ComparisonClass(); + $object_assignment = $object; + $this->assertTrue(SimpleTestCompatibility::isReference( + $object, + $object)); + $this->assertTrue(SimpleTestCompatibility::isReference( + $object, + $object_reference)); + $this->assertFalse(SimpleTestCompatibility::isReference( + $object, + $object_copy)); + if (version_compare(phpversion(), '5', '>=')) { + $this->assertTrue(SimpleTestCompatibility::isReference( + $object, + $object_assignment)); + } else { + $this->assertFalse(SimpleTestCompatibility::isReference( + $object, + $object_assignment)); + } + } + } +?> \ No newline at end of file -- cgit v1.2.3