EcomDev / EcomDev_PHPUnit

Magento PHPUnit Integration
http://www.ecomdev.org/shop/code-testing/php-unit-test-suite.html
Open Software License 3.0
299 stars 166 forks source link

getModelMock #255

Closed ExtensionsStore closed 9 years ago

ExtensionsStore commented 9 years ago

I'm trying to get a mock of my observer, but nothing happens:


$mock = $this->getModelMock('mymodule/observer');

phpunit just silently exits. Please help.

sprankhub commented 7 years ago

How did you solve this issue @ExtensionsStore?

IvanChepurnyi commented 7 years ago

php -ddisplay_errors=1 bin/phpunit ?

sprankhub commented 7 years ago

Thanks @IvanChepurnyi. I enabled error displaying on all levels, but it still silently fails. For me, it silently fails on:

$orderCollectionMock = $this->getResourceModelMock('sales/order_collection', array('getSize', 'getFirstItem'));

But it also fails on something simple like this:

$orderMock = $this->getModelMock('sales/order', array('getIncrementId'));
IvanChepurnyi commented 7 years ago

In PHPStorm you can run unit tests with Debugger. Put a breakpoint before mock and then do Step IN to find where it fails.

sprankhub commented 7 years ago

I did. It basically failed on EcomDev_PHPUnit_Mock_Proxy::__construct. I tried various versions of phpunit. Latest 3.x, latest 5.x, latest 6.x did not work. But latest phpunit 4.x (4.8.36) indeed seems to work!

So EcomDev_PHPUnit only works with phpunit 4.x?