[英]SimpleTest: assertEquals and PHP types
考虑以下代码:
<?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'== $ foo-> bar(2),因为PHP允许这样做。 此测试通过! 但这在某些情况下是错误的('2,3'字符串不同于2整数。
EqualExpectation类的SimpleTest测试方法:
function test($compare) {
return (($this->value == $compare) && ($compare == $this->value));
}
有没有一种方法可以在SimpleTest中进行测试? 代替==,使用===的方法...谢谢。
assertIdentical($x, $y) Fail if $x == $y is false or a type mismatch
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.