-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathDbaInferenceTest.php
More file actions
91 lines (73 loc) · 3.52 KB
/
DbaInferenceTest.php
File metadata and controls
91 lines (73 loc) · 3.52 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
<?php
namespace staabm\PHPStanDba\Tests;
use Composer\InstalledVersions;
use Composer\Semver\VersionParser;
use function getenv;
use PHPStan\Testing\TypeInferenceTestCase;
class DbaInferenceTest extends TypeInferenceTestCase
{
public function dataFileAsserts(): iterable
{
yield from $this->gatherAssertTypes(__DIR__.'/data/doctrine-dbal.php');
// make sure class constants can be resolved
require_once __DIR__.'/data/pdo.php';
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo.php');
if ('pdo-pgsql' === getenv('DBA_REFLECTOR')) {
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-pgsql.php');
} else {
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-mysql.php');
}
// make sure class constants can be resolved
require_once __DIR__.'/data/pdo-quote.php';
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-quote.php');
// make sure class constants can be resolved
require_once __DIR__.'/data/pdo-prepare.php';
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-prepare.php');
// make sure class constants can be resolved
require_once __DIR__.'/data/pdo-stmt-fetch.php';
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-stmt-fetch.php');
// make sure class constants can be resolved
require_once __DIR__.'/data/pdo-fetch-types.php';
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-fetch-types.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-column-count.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-stmt-execute.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/mysqli.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/mysqli-escape.php');
// make sure class definitions within the test files are known to reflection
require_once __DIR__.'/data/runMysqlQuery.php';
yield from $this->gatherAssertTypes(__DIR__.'/data/runMysqlQuery.php');
// XXX cases which are not yet supported by the PdoQueryReflector
if ('pdo-mysql' !== getenv('DBA_REFLECTOR') && 'pdo-pgsql' !== getenv('DBA_REFLECTOR')) {
yield from $this->gatherAssertTypes(__DIR__.'/data/query-alias.php');
}
yield from $this->gatherAssertTypes(__DIR__.'/data/bug254.php');
if (InstalledVersions::satisfies(new VersionParser(), 'phpstan/phpstan', '^1.4.7')) {
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-stmt-set-fetch-mode.php');
}
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-union-result.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/mysqli-union-result.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/pdo-default-fetch-types.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/bug372.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/inference-placeholder.php');
yield from $this->gatherAssertTypes(__DIR__.'/data/bug394.php');
}
/**
* @dataProvider dataFileAsserts
*
* @param mixed ...$args
*/
public function testFileAsserts(
string $assertType,
string $file,
...$args
): void {
$this->assertFileAsserts($assertType, $file, ...$args);
}
public static function getAdditionalConfigFiles(): array
{
return [
__DIR__.'/../../config/stubFiles.neon',
__DIR__.'/../../config/extensions.neon',
];
}
}