forked from phpstan/phpstan-phpunit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAssertSameMethodDifferentTypesRuleTest.php
86 lines (79 loc) · 2.57 KB
/
AssertSameMethodDifferentTypesRuleTest.php
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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
<?php declare(strict_types = 1);
namespace PHPStan\Rules\PHPUnit;
use PHPStan\Rules\Comparison\ImpossibleCheckTypeMethodCallRule;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
/**
* @extends RuleTestCase<ImpossibleCheckTypeMethodCallRule>
*/
final class AssertSameMethodDifferentTypesRuleTest extends RuleTestCase
{
protected function getRule(): Rule
{
return self::getContainer()->getByType(ImpossibleCheckTypeMethodCallRule::class);
}
public function testRule(): void
{
$this->analyse([__DIR__ . '/data/assert-same.php'], [
[
'Call to method PHPUnit\Framework\Assert::assertSame() with \'1\' and 1 will always evaluate to false.',
10,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with \'1\' and stdClass will always evaluate to false.',
11,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with 1 and string will always evaluate to false.',
12,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with \'1\' and int will always evaluate to false.',
13,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with array{\'a\', \'b\'} and array{1, 2} will always evaluate to false.',
14,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with array<string> and array<int> will always evaluate to false.',
39,
'Because the type is coming from a PHPDoc, you can turn off this check by setting <fg=cyan>treatPhpDocTypesAsCertain: false</> in your <fg=cyan>%configurationFile%</>.',
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with 1 and 1 will always evaluate to true.',
44,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with array{\'a\'} and array{\'a\', \'b\'} will always evaluate to false.',
45,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with \'1\' and \'1\' will always evaluate to true.',
46,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with \'1\' and \'2\' will always evaluate to false.',
47,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with array{\'a\'} and array{\'a\', 1} will always evaluate to false.',
51,
],
[
'Call to method PHPUnit\Framework\Assert::assertSame() with array{\'a\', 2, 3.0} and array{\'a\', 1} will always evaluate to false.',
52,
],
]);
}
/**
* @return string[]
*/
public static function getAdditionalConfigFiles(): array
{
return [
__DIR__ . '/../../../extension.neon',
__DIR__ . '/../../../vendor/phpstan/phpstan-strict-rules/rules.neon',
];
}
}