$mock = Mockery::mock('MyNamespace\SomeSubFolder\MyInterface');
$mock->shouldReceive('method1')
->andReturn('foo')
->mock();
from : https://stackoverflow.com/questions/19479052/error-when-mocking-interfaces-in-php-using-mockery
分享 Linux/Apache/PHP+MySQL/Smarty/JQuery/RubyOnRails 的點點滴滴!
$mock = Mockery::mock('MyNamespace\SomeSubFolder\MyInterface');
$mock->shouldReceive('method1')
->andReturn('foo')
->mock();
header() will fail with the Cannot modify header information warning if anything has been written to stdout. When running your code via PHPUnit, content has been sent to stdout long before your code under test has been reached.@runInSeparateProcess annotation to fork a clean PHP process for your test:Unexpected non-MediaWiki exception encountered, of type "Exception", exception 'Exception' with message 'Serialization of 'Closure' is not allowed' in /usr/share/pear/PHPUnit/Util/GlobalState.php:354
$GLOBALS data before each test and restore it afterwards. MediaWikiTestCase turns this behavior off but it looks like your extension's tests are not. It seems likely that the configuration for your extension includes a closure and is causing the serialization failure. Adding a @backupGlobals disabled annotation to your PHPUnit_Framework_TestCase class should get you past this problem.