PHPUnit Mock Objects and Static Methods

后端 未结 7 1427
梦谈多话
梦谈多话 2020-11-27 18:02

I am looking for the best way to go about testing the following static method (specifically using a Doctrine Model):

class Model_User extends Doctrine_Record         


        
7条回答
  •  自闭症患者
    2020-11-27 18:55

    There is now the AspectMock library to help with this:

    https://github.com/Codeception/AspectMock

    $this->assertEquals('users', UserModel::tableName());   
    $userModel = test::double('UserModel', ['tableName' => 'my_users']);
    $this->assertEquals('my_users', UserModel::tableName());
    $userModel->verifyInvoked('tableName'); 
    

提交回复
热议问题