mirror of
https://github.com/Lastorder-DC/rhymix.git
synced 2026-01-23 05:09:56 +09:00
#17528788 : unittest framework added
git-svn-id: http://xe-core.googlecode.com/svn/sandbox@6001 201d5d3c-b55e-5fd7-737f-ddc643e51545
This commit is contained in:
parent
ea7c87ec0d
commit
7619bce790
99 changed files with 31041 additions and 0 deletions
97
tests/simpletest/test/compatibility_test.php
Normal file
97
tests/simpletest/test/compatibility_test.php
Normal file
|
|
@ -0,0 +1,97 @@
|
|||
<?php
|
||||
// $Id: compatibility_test.php 1505 2007-04-30 23:39:59Z lastcraft $
|
||||
require_once(dirname(__FILE__) . '/../autorun.php');
|
||||
require_once(dirname(__FILE__) . '/../compatibility.php');
|
||||
|
||||
class ComparisonClass {
|
||||
}
|
||||
|
||||
class ComparisonSubclass extends ComparisonClass {
|
||||
}
|
||||
|
||||
if (version_compare(phpversion(), '5') >= 0) {
|
||||
eval('interface ComparisonInterface { }');
|
||||
eval('class ComparisonClassWithInterface implements ComparisonInterface { }');
|
||||
}
|
||||
|
||||
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 testIdentityOfNumericStrings() {
|
||||
$numericString1 = "123";
|
||||
$numericString2 = "00123";
|
||||
$this->assertNotIdentical($numericString1, $numericString2);
|
||||
}
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
|
||||
function testInteraceComparison() {
|
||||
if (version_compare(phpversion(), '5', '<')) {
|
||||
return;
|
||||
}
|
||||
|
||||
$object = new ComparisonClassWithInterface();
|
||||
$this->assertFalse(SimpleTestCompatibility::isA(
|
||||
new ComparisonClass(),
|
||||
'ComparisonInterface'));
|
||||
$this->assertTrue(SimpleTestCompatibility::isA(
|
||||
new ComparisonClassWithInterface(),
|
||||
'ComparisonInterface'));
|
||||
}
|
||||
}
|
||||
?>
|
||||
Loading…
Add table
Add a link
Reference in a new issue