考虑以下代码:
<?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;
}
}
?>
&#39; 2,3&#39; == $ foo-&gt; bar(2)因为PHP允许这样做。这个测试通过!但在某些情况下这是错误的(&#39; 2,3&#39;字符串与2整数不同。
EqualExpectation类的SimpleTest测试方法:
function test($compare) {
return (($this->value == $compare) && ($compare == $this->value));
}
有没有一种方法可以在SimpleTest中测试?而不是==,使用===的方法... 谢谢。
答案 0 :(得分:1)
assertIdentical($x, $y) Fail if $x == $y is false or a type mismatch