Usages of ->getMock
and ->getMockWithoutInvokingTheOriginalConstructor
methods MUST be replaced by ->createMock
or ->createPartialMock
methods.
Risky when PHPUnit classes are overridden or not accessible, or when project has PHPUnit incompatibilities.
Target version of PHPUnit.
Allowed values: '5.4'
, '5.5'
, 'newest'
Default value: 'newest'
Default configuration.
--- Original
+++ New
<?php
final class MyTest extends \PHPUnit_Framework_TestCase
{
public function testFoo()
{
- $mock = $this->getMockWithoutInvokingTheOriginalConstructor("Foo");
- $mock1 = $this->getMock("Foo");
- $mock1 = $this->getMock("Bar", ["aaa"]);
+ $mock = $this->createMock("Foo");
+ $mock1 = $this->createMock("Foo");
+ $mock1 = $this->createPartialMock("Bar", ["aaa"]);
$mock1 = $this->getMock("Baz", ["aaa"], ["argument"]); // version with more than 2 params is not supported
}
}
With configuration: ['target' => '5.4']
.
--- Original
+++ New
<?php
final class MyTest extends \PHPUnit_Framework_TestCase
{
public function testFoo()
{
- $mock1 = $this->getMock("Foo");
+ $mock1 = $this->createMock("Foo");
$mock1 = $this->getMock("Bar", ["aaa"]); // version with multiple params is not supported
}
}
The rule is part of the following rule sets:
- @PHPUnit54Migration:risky
Using the @PHPUnit54Migration:risky rule set will enable the
php_unit_mock
rule with the config below:['target' => '5.4']
- @PHPUnit55Migration:risky
Using the @PHPUnit55Migration:risky rule set will enable the
php_unit_mock
rule with the config below:['target' => '5.5']
- @PHPUnit56Migration:risky
Using the @PHPUnit56Migration:risky rule set will enable the
php_unit_mock
rule with the config below:['target' => '5.5']
- @PHPUnit57Migration:risky
Using the @PHPUnit57Migration:risky rule set will enable the
php_unit_mock
rule with the config below:['target' => '5.5']
- @PHPUnit60Migration:risky
Using the @PHPUnit60Migration:risky rule set will enable the
php_unit_mock
rule with the config below:['target' => '5.5']
- @PHPUnit75Migration:risky
Using the @PHPUnit75Migration:risky rule set will enable the
php_unit_mock
rule with the config below:['target' => '5.5']
- @PHPUnit84Migration:risky
Using the @PHPUnit84Migration:risky rule set will enable the
php_unit_mock
rule with the config below:['target' => '5.5']