PHP单位致命错误:调用未定义的方法PHPUnit_Framework_MockObject_InvocationMocker

问题描述:

我在与HHVM上的PHPUnit 27年8月4日未能一类具有以下消息PHP所在单位getmock()的一个问题

PHP单位致命错误:调用未定义的方法PHPUnit_Framework_MockObject_InvocationMocker

Fatal error: Call to undefined method PHPUnit_Framework_MockObject_InvocationMocker::getTableColumns() in /joomla-cms/libraries/joomla/table/table.php on line 241

测试代码否则位于https://github.com/photodude/joomla-cms/blob/patch-1/tests/unit/suites/libraries/cms/installer/JInstallerAdapterTest.php#L111 的测试代码这种“失败/错误”,没有致命错误测试

$mockTableExtension = $this->getMock('JTableExtension', array('find', 'load'), array($this->getMockDatabase())); 

,但如果我使用储值

$mockDatabase = $this->getMockDatabase(); 

and type cast the mockDatabase object to array我得到上面列出的致命错误。

$mockTableExtension = $this->getMock('JTableExtension', array('find', 'load'), (array) $mockDatabase); 

特拉维斯测试与投射到阵列的mockDatabase对象和对象类型var_dumped https://travis-ci.org/photodude/joomla-cms/jobs/172201634#L1427-L2178

一切的推移和工作在PHP就好了,这个问题是特定于HHVM 测试我做得不对的模拟设置?还是有其他的事情呢?

注意:我最近在php单元5.6上测试了这部分测试套件,并得到了同样的问题。所以我不确定我们在设置这些测试方面没有错。

我发现在hhvm的其中一项测试中发现了array($this->getMockDatabase())问题。用array(self::$driver)代替array($this->getMockDatabase())所有问题都已解决。

我也更换了直接使用getMockgetMockBuilder(为了兼容phpunit 5.6)