2011-01-20 10 views
1

SimpleTestの次のコードを考えるのassertEqualsとPHPの種類

<?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->バー(2)PHPがそれを可能にするので。このテストパス! 。しかし、それはEqualExpectationクラスから

SimpleTestの試験方法(「2、3」文字列は2つの整数が異なるいくつかのケースでは間違っている:

function test($compare) { 
    return (($this->value == $compare) && ($compare == $this->value)); 
} 

SimpleTestの中でそれをテストする方法があるの代わりに? ==、===使用方法... はありがとう

答えて

関連する問題