forked from phpstan/phpstan-src
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInvalidIgnoredErrorExceptionTest.php
More file actions
88 lines (79 loc) · 2.79 KB
/
InvalidIgnoredErrorExceptionTest.php
File metadata and controls
88 lines (79 loc) · 2.79 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
<?php declare(strict_types = 1);
namespace PHPStan\DependencyInjection;
use PHPStan\Testing\PHPStanTestCase;
use PHPUnit\Framework\Attributes\DataProvider;
class InvalidIgnoredErrorExceptionTest extends PHPStanTestCase
{
private static ?string $configFile = null;
/**
* @return iterable<array{string, string}>
*/
public static function dataValidateIgnoreErrors(): iterable
{
yield [
__DIR__ . '/invalidIgnoreErrors/message-and-messages.neon',
'An ignoreErrors entry cannot contain both message and messages fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/rawMessage-and-message.neon',
'An ignoreErrors entry cannot contain both rawMessage and message fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/rawMessage-and-messages.neon',
'An ignoreErrors entry cannot contain both rawMessage and messages fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/rawMessage-and-rawMessages.neon',
'An ignoreErrors entry cannot contain both rawMessage and rawMessages fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/rawMessages-and-message.neon',
'An ignoreErrors entry cannot contain both rawMessages and message fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/rawMessages-and-messages.neon',
'An ignoreErrors entry cannot contain both rawMessages and messages fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/identifier-and-identifiers.neon',
'An ignoreErrors entry cannot contain both identifier and identifiers fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/path-and-paths.neon',
'An ignoreErrors entry cannot contain both path and paths fields.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/missing-main-key.neon',
'An ignoreErrors entry must contain at least one of the following fields: message, messages, rawMessage, rawMessages, identifier, identifiers, path, paths.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/count-without-path.neon',
'An ignoreErrors entry with count field must also contain path field.',
];
yield [
__DIR__ . '/invalidIgnoreErrors/path-with-array-value.neon',
"Key 'path' of ignoreErrors expects a string, array given. Did you mean 'paths'?",
];
yield [
__DIR__ . '/invalidIgnoreErrors/paths-with-string-value.neon',
"Key 'paths' of ignoreErrors expects an array, string given. Did you mean 'path'?",
];
}
#[DataProvider('dataValidateIgnoreErrors')]
public function testValidateIgnoreErrors(string $file, string $expectedMessage): void
{
self::$configFile = $file;
$this->expectExceptionMessage($expectedMessage);
self::getContainer();
}
public static function getAdditionalConfigFiles(): array
{
$files = [
__DIR__ . '/../../../conf/bleedingEdge.neon',
];
if (self::$configFile !== null) {
$files[] = self::$configFile;
}
return $files;
}
}