- 添加标准对象比较处理器测试用例 - 创建多个类实例验证相等性判断逻辑 - 测试相同类不同实例间的比较行为 - 验证不同类对象间的比较结果 - 添加继承关系对象的比较测试 - 验证对象处理器不同的比较场景pull/1/head
parent
53958c67c3
commit
3a3c8eb6b6
2 changed files with 79 additions and 0 deletions
@ -0,0 +1,57 @@ |
|||||||
|
--TEST-- |
||||||
|
Test standard 'compare' object handler |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
class class1{} |
||||||
|
|
||||||
|
class class2{} |
||||||
|
|
||||||
|
class class3{ |
||||||
|
public $aaa; |
||||||
|
private $bbb; |
||||||
|
protected $ccc; |
||||||
|
} |
||||||
|
|
||||||
|
class class4 extends class3{ |
||||||
|
} |
||||||
|
|
||||||
|
class class5 extends class3{ |
||||||
|
public $ddd; |
||||||
|
private $eee; |
||||||
|
} |
||||||
|
|
||||||
|
function main() { |
||||||
|
echo "Simple test for standard compare object handler\n"; |
||||||
|
// Define a bunch of objects all of which will use standard compare object handler |
||||||
|
$obj1 = new class1(); |
||||||
|
$obj2 = new class2(); |
||||||
|
$obj3 = new class3(); |
||||||
|
$obj4 = new class4(); |
||||||
|
$obj5 = new class5(); |
||||||
|
|
||||||
|
echo "\n-- The following compare should return TRUE --\n"; |
||||||
|
var_dump($obj1 == $obj1); |
||||||
|
|
||||||
|
echo "\n-- All the following compares should return FALSE --\n"; |
||||||
|
var_dump($obj1 == $obj2); |
||||||
|
var_dump($obj1 == $obj3); |
||||||
|
var_dump($obj1 == $obj4); |
||||||
|
var_dump($obj1 == $obj5); |
||||||
|
var_dump($obj4 == $obj3); |
||||||
|
var_dump($obj5 == $obj3); |
||||||
|
} |
||||||
|
|
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
Simple test for standard compare object handler |
||||||
|
|
||||||
|
-- The following compare should return TRUE -- |
||||||
|
bool(true) |
||||||
|
|
||||||
|
-- All the following compares should return FALSE -- |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
|
bool(false) |
||||||
@ -0,0 +1,22 @@ |
|||||||
|
--TEST-- |
||||||
|
Test object compare when object handler different |
||||||
|
--FILE-- |
||||||
|
<?php |
||||||
|
|
||||||
|
class X { |
||||||
|
} |
||||||
|
|
||||||
|
function main() { |
||||||
|
//Set the default time zone |
||||||
|
date_default_timezone_set("Europe/London"); |
||||||
|
|
||||||
|
echo "Simple test comparing two objects with different compare callback handler\n"; |
||||||
|
$obj1 = new X(); |
||||||
|
$obj2 = new DateTime(("2009-02-12 12:47:41 GMT")); |
||||||
|
|
||||||
|
var_dump($obj1 == $obj2); |
||||||
|
} |
||||||
|
?> |
||||||
|
--EXPECT-- |
||||||
|
Simple test comparing two objects with different compare callback handler |
||||||
|
bool(false) |
||||||
Loading…
Reference in new issue