Phpunit testing with database

前端 未结 3 712
心在旅途
心在旅途 2020-12-24 00:23

I am trying to focus a bit on unit testing using PHPunit.

I have found a very good tutorial over here http://blog.nickbelhomme.com/php/phpunit-training-course-for-fre

3条回答
  •  孤独总比滥情好
    2020-12-24 01:09

    I think you can use tearDown() method to clean your saved data.

    protected $_user;
    
    public function testCanCreateUser()
    {
        ...
    
        $this->_user = new Model_User($userData);
        $this->_user->save();
    }
    
    public function tearDown()
    {
        $this->_user->delete();
    }
    

提交回复
热议问题