Skip to content

Commit a0b166b

Browse files
Try
1 parent f902b24 commit a0b166b

File tree

2 files changed

+8
-2
lines changed

2 files changed

+8
-2
lines changed

src/Rules/PHPUnit/MockMethodCallRule.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,12 @@ public function processNode(Node $node, Scope $scope): array
5252
return $class !== MockObject::class;
5353
});
5454

55+
// `MockBuilder::setMethods` and `MockBuilder::addMethods` are not supported by this rule
56+
// so since a lot of the usage are with `stdClass`, we silent the error
57+
if (\implode('&', $mockClass) === 'stdClass') {
58+
return [];
59+
}
60+
5561
return [
5662
sprintf(
5763
'Trying to mock an undefined method %s() on class %s.',

tests/Rules/PHPUnit/data/mock-method-call.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,9 @@ public function testWithMockBuilder()
3131
$this->getMockBuilder(Bar::class)->getMock()->method('doBadThing');
3232
}
3333

34-
public function testWhenAddingMethod()
34+
public function testWhenAddingMethodToStdClass()
3535
{
36-
$this->getMockBuilder(Bar::class)->setMethods(['doBadThing'])->getMock()->method('doBadThing');
36+
$this->getMockBuilder(\stdClass::class)->setMethods(['doBadThing'])->getMock()->method('doBadThing');
3737
}
3838

3939
}

0 commit comments

Comments
 (0)