-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathUnresolvableQueryMethodRuleTest.php
More file actions
99 lines (87 loc) · 2.88 KB
/
UnresolvableQueryMethodRuleTest.php
File metadata and controls
99 lines (87 loc) · 2.88 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
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
87
88
89
90
91
92
93
94
95
96
97
98
99
<?php
declare(strict_types=1);
namespace staabm\PHPStanDba\Tests;
use PHPStan\Rules\Rule;
use PHPStan\Testing\RuleTestCase;
use staabm\PHPStanDba\QueryReflection\QueryReflection;
use staabm\PHPStanDba\Rules\SyntaxErrorInQueryMethodRule;
use staabm\PHPStanDba\UnresolvableQueryDynamicFromException;
use staabm\PHPStanDba\UnresolvableQueryMixedTypeException;
use staabm\PHPStanDba\UnresolvableQueryStringTypeException;
/**
* @extends RuleTestCase<SyntaxErrorInQueryMethodRule>
*/
class UnresolvableQueryMethodRuleTest extends RuleTestCase
{
protected function setUp(): void
{
QueryReflection::getRuntimeConfiguration()->debugMode(true);
}
protected function tearDown(): void
{
QueryReflection::getRuntimeConfiguration()->debugMode(false);
}
protected function getRule(): Rule
{
return self::getContainer()->getByType(SyntaxErrorInQueryMethodRule::class);
}
public static function getAdditionalConfigFiles(): array
{
return [
__DIR__ . '/../../config/dba.neon',
];
}
public function testSyntaxErrorInQueryRule(): void
{
$this->analyse([__DIR__ . '/data/unresolvable-query-in-method.php'], [
[
'Unresolvable Query: Cannot simulate parameter value for type: mixed.',
11,
UnresolvableQueryMixedTypeException::getTip(),
],
[
'Unresolvable Query: Cannot simulate parameter value for type: mixed.',
17,
UnresolvableQueryMixedTypeException::getTip(),
],
[
'Unresolvable Query: Cannot resolve query with variable type: string.',
34,
UnresolvableQueryStringTypeException::getTip(),
],
[
'Unresolvable Query: Cannot resolve query with variable type: string.',
39,
UnresolvableQueryStringTypeException::getTip(),
],
]);
}
public function testBug536(): void
{
$this->analyse([__DIR__ . '/data/bug-536.php'], []);
}
public function testBug548(): void
{
$this->analyse([__DIR__ . '/data/bug-548.php'], [
[
'Unresolvable Query: Seems the query is too dynamic to be resolved by query simulation.',
10,
UnresolvableQueryDynamicFromException::getTip(),
],
]);
}
public function testBug547(): void
{
$this->analyse([__DIR__ . '/data/bug-547.php'], [
[
'Unresolvable Query: Seems the query is too dynamic to be resolved by query simulation.',
10,
UnresolvableQueryDynamicFromException::getTip(),
],
]);
}
public function testBug676(): void
{
$this->analyse([__DIR__ . '/data/bug-676.php'], []);
}
}