如何为 Doctrine 实体 class 编写测试 class?

How do I write a test class for a Doctrine entity class?

我正在使用 Symfony2 和 Doctrine 2。我正在尝试采用 TDD 方法。有人可以给我一个 Doctrine 实体 class 的单元测试 class 的基本示例吗?

真诚感谢任何帮助。

这是实体单元测试的简单示例:

class MessageTest extends \PHPUnit_Framework_TestCase {

    /**
     * @var Message
     */
    protected $object;

    /**
     * Sets up the fixture, for example, opens a network connection.
     * This method is called before a test is executed.
     */
    protected function setUp()
    {
        $this->object = new Message();
    }

    public function testGetterAndSetter() {

        $this->assertNull($this->object->getId());

        $date = new \DateTime();

        $this->object->setDate($date);
        $this->assertEquals($date, $this->object->getDate());

        $this->object->setMessage("message");
        $this->assertEquals("message", $this->object->getMessage());

        $this->object->setSuccess(true);
        $this->assertTrue($this->object->getSuccess());
    }
}