我是 PHPUnit 的新手,事实上我是从今天开始的。而且,就我一直在阅读的内容而言,我开始了解这个脚本的作用。
class UserTest extends PHPUnit_Framework_TestCase
{
     protected $user;
    // test the talk method
    protected function setUp() {
        $this->user = new User();
        $this->user->setName("Tom");
    }
    protected function tearDown() {
        unset($this->user);
    }
 public function testTalk() {
        $expected = "Hello world!";
        $actual = $this->user->talk();
        $this->assertEquals($expected, $actual);
    }
}
对于这个类:
<?php
class User {
    protected $name;
    public function getName() {
        return $this->name;
    }
    public function setName($name) {
        $this->name = $name;
    }
    public function talk() {
        return "Hello world!";
    }
} 
好的,所以我已经确定测试基于测试的相等性返回一个 Ok/Fail 语句,但我正在寻找更多。我需要一种实际的方法来测试一个更复杂的类,它的结果与这个例子不同,不能轻易猜到。
比如说,我编写了一个执行轮询的脚本。我将如何或以什么方式测试方法/类是否可以工作?上面的代码只显示了一个方法的结果是否只有'Hello World'但是,这太容易测试了,因为我需要测试复杂的东西,而且没有太多的教程。