Skip to content

Commit 429d9e5

Browse files
committed
do not use PHPUnit mock objects without configured expectations
1 parent 421c958 commit 429d9e5

File tree

1 file changed

+4
-10
lines changed

1 file changed

+4
-10
lines changed

Tests/Command/ErrorDumpCommandTest.php

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111

1212
namespace Symfony\Component\ErrorHandler\Tests\Command;
1313

14-
use PHPUnit\Framework\MockObject\MockObject;
1514
use Symfony\Bundle\FrameworkBundle\Console\Application;
1615
use Symfony\Bundle\TwigBundle\Tests\TestCase;
1716
use Symfony\Component\Console\Tester\CommandTester;
@@ -37,7 +36,7 @@ protected function setUp(): void
3736

3837
public function testDumpPages()
3938
{
40-
$tester = $this->getCommandTester($this->getKernel(), []);
39+
$tester = $this->getCommandTester($this->createStub(KernelInterface::class), []);
4140
$tester->execute([
4241
'path' => $this->tmpDir,
4342
]);
@@ -52,7 +51,7 @@ public function testDumpPagesOnlyForGivenStatusCodes()
5251
$fs->mkdir($this->tmpDir);
5352
$fs->touch($this->tmpDir.\DIRECTORY_SEPARATOR.'test.html');
5453

55-
$tester = $this->getCommandTester($this->getKernel());
54+
$tester = $this->getCommandTester($this->createStub(KernelInterface::class));
5655
$tester->execute([
5756
'path' => $this->tmpDir,
5857
'status-codes' => ['400', '500'],
@@ -71,7 +70,7 @@ public function testForceRemovalPages()
7170
$fs->mkdir($this->tmpDir);
7271
$fs->touch($this->tmpDir.\DIRECTORY_SEPARATOR.'test.html');
7372

74-
$tester = $this->getCommandTester($this->getKernel());
73+
$tester = $this->getCommandTester($this->createStub(KernelInterface::class));
7574
$tester->execute([
7675
'path' => $this->tmpDir,
7776
'--force' => true,
@@ -81,11 +80,6 @@ public function testForceRemovalPages()
8180
$this->assertFileExists($this->tmpDir.\DIRECTORY_SEPARATOR.'404.html');
8281
}
8382

84-
private function getKernel(): MockObject&KernelInterface
85-
{
86-
return $this->createMock(KernelInterface::class);
87-
}
88-
8983
private function getCommandTester(KernelInterface $kernel): CommandTester
9084
{
9185
$errorRenderer = $this->createStub(ErrorRendererInterface::class);
@@ -99,7 +93,7 @@ private function getCommandTester(KernelInterface $kernel): CommandTester
9993
})
10094
;
10195

102-
$entrypointLookup = $this->createMock(EntrypointLookupInterface::class);
96+
$entrypointLookup = $this->createStub(EntrypointLookupInterface::class);
10397

10498
$application = new Application($kernel);
10599
$application->add(new ErrorDumpCommand(

0 commit comments

Comments
 (0)