forked from mglaman/phpstan-drupal
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathNoRedundantTraitUseRuleTest.php
More file actions
58 lines (50 loc) · 1.55 KB
/
Copy pathNoRedundantTraitUseRuleTest.php
File metadata and controls
58 lines (50 loc) · 1.55 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php declare(strict_types=1);
namespace mglaman\PHPStanDrupal\Tests\Rules;
use mglaman\PHPStanDrupal\Rules\Drupal\NoRedundantTraitUseRule;
use mglaman\PHPStanDrupal\Tests\DrupalRuleTestCase;
use PHPStan\Reflection\ReflectionProvider;
final class NoRedundantTraitUseRuleTest extends DrupalRuleTestCase
{
protected function getRule(): \PHPStan\Rules\Rule
{
return new NoRedundantTraitUseRule($this->createReflectionProvider());
}
/**
* @dataProvider resultData
*
* @param list<array{0: string, 1: int, 2?: string|null}> $errorMessages
*/
public function testRule(string $path, array $errorMessages): void
{
$this->analyse([$path], $errorMessages);
}
public static function resultData(): \Generator
{
yield [
__DIR__ . '/data/no-redundant-trait-use.php',
[
[
'Class uses trait "BarTrait" redundantly as it is already included via trait "FooTrait".',
20
],
]
];
yield [
__DIR__ . '/data/no-redundant-trait-use-valid.php',
[]
];
yield [
__DIR__ . '/data/no-redundant-trait-use-single-trait.php',
[]
];
yield [
__DIR__ . '/data/no-redundant-trait-use-transitive.php',
[
[
'Class uses trait "BaseTrait" redundantly as it is already included via trait "WrapperTrait".',
20
],
]
];
}
}