考虑以下代码:
<?php
class Foo extends UnitTestCase {
public function testFoo() {
$foo = new Foo();
$this->assertEqual('2, 3', $foo->bar(3));
}
}
?>
<?php
class Foo {
public function bar() {
return 2;
}
}
?>'2,3‘PHP $foo->bar (2)因为==允许这样做。这个测试通过了!但在某些情况下是错误的('2,3‘字符串与2整数不同。
来自EqualExpectation类的SimpleTest测试方法:
function test($compare) {
return (($this->value == $compare) && ($compare == $this->value));
}有没有一种方法可以在SimpleTest中进行测试?使用===的方法代替了== ...谢谢。
发布于 2011-05-27 17:14:13
从SimpleTest documents
assertIdentical($x, $y) Fail if $x == $y is false or a type mismatchhttps://stackoverflow.com/questions/4751703
复制相似问题