Umbrella Umbrella - 2 months ago 13
PHP Question

Upgrading PHPUnit from 4.8 to 5.5

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
, 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()

Than you just need to extend all of your tests from this class.