Skip to content

Commit d39a10c

Browse files
authored
Tests: Use Stubs instead of Mocks
1 parent c08e658 commit d39a10c

12 files changed

+21
-21
lines changed

tests/PHPStan/Command/AnalyseApplicationIntegrationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ private function runPath(string $path, int $expectedStatusCode): string
6262

6363
$symfonyOutput = new SymfonyOutput(
6464
$output,
65-
new \PHPStan\Command\Symfony\SymfonyStyle(new SymfonyStyle($this->createMock(InputInterface::class), $output)),
65+
new \PHPStan\Command\Symfony\SymfonyStyle(new SymfonyStyle($this->createStub(InputInterface::class), $output)),
6666
);
6767

6868
$relativePathHelper = new FuzzyRelativePathHelper(new NullRelativePathHelper(), __DIR__, [], DIRECTORY_SEPARATOR);
@@ -88,7 +88,7 @@ private function runPath(string $path, int $expectedStatusCode): string
8888
null,
8989
null,
9090
null,
91-
$this->createMock(InputInterface::class),
91+
$this->createStub(InputInterface::class),
9292
);
9393
$statusCode = $errorFormatter->formatErrors($analysisResult, $symfonyOutput);
9494

tests/PHPStan/Parser/CachedParserTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
use PHPStan\File\FileReader;
1010
use PHPStan\Testing\PHPStanTestCase;
1111
use PHPUnit\Framework\Attributes\DataProvider;
12-
use PHPUnit\Framework\MockObject\MockObject;
12+
use PHPUnit\Framework\MockObject\Stub;
1313

1414
class CachedParserTest extends PHPStanTestCase
1515
{
@@ -21,7 +21,7 @@ public function testParseFileClearCache(
2121
): void
2222
{
2323
$parser = new CachedParser(
24-
$this->getParserMock(),
24+
$this->getParserStub(),
2525
$cachedNodesByStringCountMax,
2626
);
2727

@@ -62,19 +62,19 @@ public static function dataParseFileClearCache(): Generator
6262
];
6363
}
6464

65-
private function getParserMock(): Parser&MockObject
65+
private function getParserStub(): Parser&Stub
6666
{
67-
$mock = $this->createMock(Parser::class);
67+
$mock = $this->createStub(Parser::class);
6868

69-
$mock->method('parseFile')->willReturn([$this->getPhpParserNodeMock()]);
70-
$mock->method('parseString')->willReturn([$this->getPhpParserNodeMock()]);
69+
$mock->method('parseFile')->willReturn([$this->getPhpParserNodeStub()]);
70+
$mock->method('parseString')->willReturn([$this->getPhpParserNodeStub()]);
7171

7272
return $mock;
7373
}
7474

75-
private function getPhpParserNodeMock(): Node&MockObject
75+
private function getPhpParserNodeStub(): Node&Stub
7676
{
77-
return $this->createMock(Node::class);
77+
return $this->createStub(Node::class);
7878
}
7979

8080
public function testParseTheSameFileWithDifferentMethod(): void

tests/PHPStan/Reflection/Annotations/AnnotationsMethodsClassReflectionExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -966,7 +966,7 @@ public function testMethods(string $className, array $methods): void
966966
{
967967
$reflectionProvider = self::createReflectionProvider();
968968
$class = $reflectionProvider->getClass($className);
969-
$scope = $this->createMock(Scope::class);
969+
$scope = $this->createStub(Scope::class);
970970
$scope->method('isInClass')->willReturn(true);
971971
$scope->method('getClassReflection')->willReturn($class);
972972
$scope->method('canCallMethod')->willReturn(true);

tests/PHPStan/Reflection/Annotations/AnnotationsPropertiesClassReflectionExtensionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ public function testProperties(string $className, array $properties): void
280280
{
281281
$reflectionProvider = self::createReflectionProvider();
282282
$class = $reflectionProvider->getClass($className);
283-
$scope = $this->createMock(Scope::class);
283+
$scope = $this->createStub(Scope::class);
284284
$scope->method('isInClass')->willReturn(true);
285285
$scope->method('getClassReflection')->willReturn($class);
286286
$scope->method('canAccessProperty')->willReturn(true);

tests/PHPStan/Reflection/Annotations/DeprecatedAnnotationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public function testDeprecatedAnnotations(bool $deprecated, string $className, ?
101101
{
102102
$reflectionProvider = self::createReflectionProvider();
103103
$class = $reflectionProvider->getClass($className);
104-
$scope = $this->createMock(Scope::class);
104+
$scope = $this->createStub(Scope::class);
105105
$scope->method('isInClass')->willReturn(true);
106106
$scope->method('getClassReflection')->willReturn($class);
107107
$scope->method('canAccessProperty')->willReturn(true);

tests/PHPStan/Reflection/Annotations/FinalAnnotationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testFinalAnnotations(bool $final, string $className, array $fina
4545
{
4646
$reflectionProvider = self::createReflectionProvider();
4747
$class = $reflectionProvider->getClass($className);
48-
$scope = $this->createMock(Scope::class);
48+
$scope = $this->createStub(Scope::class);
4949
$scope->method('isInClass')->willReturn(true);
5050
$scope->method('getClassReflection')->willReturn($class);
5151
$scope->method('canAccessProperty')->willReturn(true);

tests/PHPStan/Reflection/Annotations/InternalAnnotationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ public function testInternalAnnotations(bool $internal, string $className, array
126126
{
127127
$reflectionProvider = self::createReflectionProvider();
128128
$class = $reflectionProvider->getClass($className);
129-
$scope = $this->createMock(Scope::class);
129+
$scope = $this->createStub(Scope::class);
130130
$scope->method('isInClass')->willReturn(true);
131131
$scope->method('getClassReflection')->willReturn($class);
132132
$scope->method('canAccessProperty')->willReturn(true);

tests/PHPStan/Reflection/Annotations/ThrowsAnnotationsTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ public function testThrowsAnnotations(string $className, array $throwsAnnotation
7676
{
7777
$reflectionProvider = self::createReflectionProvider();
7878
$class = $reflectionProvider->getClass($className);
79-
$scope = $this->createMock(Scope::class);
79+
$scope = $this->createStub(Scope::class);
8080

8181
foreach ($throwsAnnotations as $methodName => $type) {
8282
$methodAnnotation = $class->getMethod($methodName, $scope);

tests/PHPStan/Reflection/FunctionReflectionTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ public function testMethodHasPhpdoc(string $className, string $methodName, ?stri
119119
{
120120
$reflectionProvider = self::createReflectionProvider();
121121
$class = $reflectionProvider->getClass($className);
122-
$scope = $this->createMock(Scope::class);
122+
$scope = $this->createStub(Scope::class);
123123
$scope->method('isInClass')->willReturn(true);
124124
$scope->method('getClassReflection')->willReturn($class);
125125
$scope->method('canAccessProperty')->willReturn(true);
@@ -180,7 +180,7 @@ public function testMethodReturnsByReference(string $className, string $methodNa
180180
{
181181
$reflectionProvider = self::createReflectionProvider();
182182
$class = $reflectionProvider->getClass($className);
183-
$scope = $this->createMock(Scope::class);
183+
$scope = $this->createStub(Scope::class);
184184
$scope->method('isInClass')->willReturn(true);
185185
$scope->method('getClassReflection')->willReturn($class);
186186
$scope->method('canAccessProperty')->willReturn(true);

tests/PHPStan/Reflection/Type/IntersectionTypeMethodReflectionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public function testMultipleDeprecationsAreJoined(): void
3838

3939
private function createDeprecatedMethod(TrinaryLogic $deprecated, ?string $deprecationText): ExtendedMethodReflection
4040
{
41-
$method = $this->createMock(ExtendedMethodReflection::class);
41+
$method = $this->createStub(ExtendedMethodReflection::class);
4242
$method->method('isDeprecated')->willReturn($deprecated);
4343
$method->method('getDeprecatedDescription')->willReturn($deprecationText);
4444
return $method;

0 commit comments

Comments
 (0)