我开始学习PhpUnit并进行测试。我有一个返回字符串的方法,我如何编写一个测试来检查这个方法是否返回字符串。下面是我在这一刻代码:PhpUnit和字符串
方法:
/**
* @return string
*/
public function living()
{
return 'Happy!';
}
测试:
public $real;
public $expected;
public function testLiving()
{
$this->expected = 'Happy';
$this->real = 'Speechless';
$this->assertTrue($this->expected == $this->real);
}
它们在通过时是一样的,但是当assertEquals失败时,它会告诉你它们在哪里,而assertTrue会告诉你false是不正确的。 – gontrollez 2014-11-04 13:47:28