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