phpunit avoid constructor arguments for mock

后端 未结 7 1085
有刺的猬
有刺的猬 2021-01-30 08:24

What is the way to avoid phpunit having to call the constructor for a mock object? Otherwise I would need a mock object as constructor argument, another one for that etc. The ap

相关标签:
7条回答
  • 2021-01-30 08:51

    Here you go:

        // Get a Mock Soap Client object to work with.
        $classToMock = 'SoapClient';
        $methodsToMock = array('__getFunctions');
        $mockConstructorParams = array('fake wsdl url', array());
        $mockClassName = 'MyMockSoapClient';
        $callMockConstructor = false;
        $mockSoapClient = $this->getMock($classToMock,
                                         $methodsToMock,
                                         $mockConstructorParams,
                                         $mockClassName,
                                         $callMockConstructor);
    
    0 讨论(0)
提交回复
热议问题