Skip to content

Commit ea2327a

Browse files
committed
Skip SkipConstraintValidatorTest
1 parent 838ffd3 commit ea2327a

File tree

5 files changed

+36
-0
lines changed

5 files changed

+36
-0
lines changed

src/Enum/SymfonyClass.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,4 +38,6 @@ final class SymfonyClass
3838
public const URL_GENERATOR = 'Symfony\Component\Routing\Generator\UrlGeneratorInterface';
3939

4040
public const COMMAND = 'Symfony\Component\Console\Command\Command';
41+
42+
public const VALIDATOR_TEST_CASE = 'Symfony\Component\Validator\Test\ConstraintValidatorTestCase';
4143
}

src/Rules/PHPUnit/NoMockOnlyTestRule.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
use PHPStan\Rules\RuleErrorBuilder;
1414
use Symplify\PHPStanRules\Enum\ClassName;
1515
use Symplify\PHPStanRules\Enum\PHPUnitRuleIdentifier;
16+
use Symplify\PHPStanRules\Enum\SymfonyClass;
1617
use Symplify\PHPStanRules\Testing\PHPUnitTestAnalyser;
1718

1819
/**
@@ -46,6 +47,10 @@ public function processNode(Node $node, Scope $scope): array
4647
return [];
4748
}
4849

50+
if ($classLike->extends instanceof Name && $classLike->extends->toString() === SymfonyClass::VALIDATOR_TEST_CASE) {
51+
return [];
52+
}
53+
4954
if ($classLike->getProperties() === []) {
5055
return [];
5156
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<?php
2+
3+
namespace Symfony\Component\Validator\Test;
4+
5+
use PHPUnit\Framework\TestCase;
6+
7+
abstract class ConstraintValidatorTestCase extends TestCase
8+
{
9+
10+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
<?php
2+
3+
namespace Symplify\PHPStanRules\Tests\Rules\PHPUnit\NoMockOnlyTestRule\Fixture;
4+
5+
use Symfony\Component\Validator\Test\ConstraintValidatorTestCase;
6+
7+
final class SkipConstraintValidatorTest extends ConstraintValidatorTestCase
8+
{
9+
private \PHPUnit\Framework\MockObject\MockObject $firstMock;
10+
11+
private \PHPUnit\Framework\MockObject\MockObject $secondMock;
12+
13+
public function test()
14+
{
15+
$this->firstMock = $this->createMock('A');
16+
$this->secondMock = $this->createMock('B');
17+
}
18+
}

tests/Rules/PHPUnit/NoMockOnlyTestRule/NoMockOnlyTestRuleTest.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ public static function provideData(): Iterator
2828
yield [__DIR__ . '/Fixture/SkipTestWithClass.php', []];
2929
yield [__DIR__ . '/Fixture/SkipNoProperty.php', []];
3030
yield [__DIR__ . '/Fixture/SkipSoleProperty.php', []];
31+
yield [__DIR__ . '/Fixture/SkipConstraintValidatorTest.php', []];
3132
}
3233

3334
protected function getRule(): Rule

0 commit comments

Comments
 (0)