We upgraded our systems to PHP7.0. This required us to upgrade PHPUnit to 5.5, as 4.8 doesn't properly support PHP7. This produces the following error, which nets a failure in phpunit in our CI
PHPUnit_Framework_TestCase::getMock() is deprecated,
use PHPUnit_Framework_TestCase::createMock() or
PHPUnit_Framework_TestCase::getMockBuilder() instead
What it looks like now is that we have to touch 1200+ unit tests to refactor how we build our mocks.
Is there either a way to suppress that warning, or, quickly convert our uses of getMock
to createMock
, which seems to work differently enough that a global find/replace won't cut it?
You could create additional test class called TestAdapter which will extend PHPUnit_Framework_TestCase
class TestAdapter extends PHPUnit_Framework_TestCase
{
/**
* Override your deprecated method
*/
public function getMock()
{
return $this->createMock();
}
}
Then you just need to extend all of your tests from this class.
Had the same issue. I did run a regex replace to fix getMock()
deprecated entries.
->getMock\(([^)]+)\)
replaced with->getMockBuilder($1)->getMock()
Hope that helps
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With