@@ -10,34 +10,23 @@ class MainTest extends TestCase
10
10
{
11
11
public function testHappyPath (): void
12
12
{
13
- $ expectedTotalErrors = 4 ;
13
+ $ expectedTotalErrors = 12 ;
14
14
$ expectedErrorsPerFile = [
15
+ 'file_exists_but_path_is_relative.php ' => [
16
+ 'errors ' => 4 ,
17
+ 'lines ' => [5 , 6 , 7 , 8 ]
18
+ ],
15
19
'included_file_does_not_exist.php ' => [
16
20
'errors ' => 4 ,
17
- 'messages ' => [
18
- [
19
- 'message ' => 'Included or required file "a_file_that_does_not_exist.php" does not exist. ' ,
20
- 'line ' => 5 ,
21
- 'ignorable ' => true
22
- ],
23
- [
24
- 'message ' => 'Included or required file "a_file_that_does_not_exist_once.php" does not exist. ' ,
25
- 'line ' => 6 ,
26
- 'ignorable ' => true
27
- ],
28
- [
29
- 'message ' => 'Included or required file "a_file_that_does_not_exist.php" does not exist. ' ,
30
- 'line ' => 7 ,
31
- 'ignorable ' => true
32
- ],
33
- [
34
- 'message ' => 'Included or required file "a_file_that_does_not_exist_once.php" does not exist. ' ,
35
- 'line ' => 8 ,
36
- 'ignorable ' => true
37
- ],
38
- ]
21
+ 'lines ' => [5 , 6 , 7 , 8 ]
22
+ ],
23
+ 'included_file_does_not_exist_using_class_const.php ' => [
24
+ 'errors ' => 4 ,
25
+ 'lines ' => [7 , 8 , 9 , 10 ]
39
26
],
40
27
];
28
+ $ errorStartsWith = 'Included or required file " ' ;
29
+ $ errorEndsWith = '" does not exist. ' ;
41
30
42
31
$ output = [];
43
32
exec ('php vendor/bin/phpstan analyse -c tests/phpstan-testing.neon --error-format=json ' , $ output );
@@ -51,8 +40,16 @@ public function testHappyPath(): void
51
40
$ basename = basename ($ filename );
52
41
53
42
$ this ->assertArrayHasKey ($ basename , $ expectedErrorsPerFile );
54
- $ this ->assertSame ($ expectedErrorsPerFile [$ basename ]['errors ' ], $ errors ['errors ' ]);
55
- $ this ->assertSame ($ expectedErrorsPerFile [$ basename ]['messages ' ], $ errors ['messages ' ]);
43
+
44
+ $ expectedError = $ expectedErrorsPerFile [$ basename ];
45
+ $ this ->assertSame ($ expectedError ['errors ' ], $ errors ['errors ' ]);
46
+
47
+ foreach ($ errors ['messages ' ] as $ index => $ error ) {
48
+ $ this ->assertStringStartsWith ($ errorStartsWith , $ error ['message ' ]);
49
+ $ this ->assertStringEndsWith ($ errorEndsWith , $ error ['message ' ]);
50
+
51
+ $ this ->assertSame ($ expectedError ['lines ' ][$ index ], $ error ['line ' ]);
52
+ }
56
53
}
57
54
}
58
55
}
0 commit comments