@@ -6,31 +6,42 @@ final class DrupalIntegrationTest extends AnalyzerTestBase {
6
6
7
7
public function testInstallPhp () {
8
8
$ errors = $ this ->runAnalyze (__DIR__ . '/../fixtures/drupal/core/install.php ' );
9
- $ this ->assertCount (0 , $ errors );
9
+ $ this ->assertCount (0 , $ errors ->getErrors ());
10
+ $ this ->assertCount (0 , $ errors ->getInternalErrors ());
10
11
}
11
12
12
13
public function testTestSuiteAutoloading () {
13
14
$ paths = [
14
15
__DIR__ . '/../fixtures/drupal/core/tests/TestSuites/FunctionalJavascriptTestSuite.php ' ,
15
16
__DIR__ . '/../fixtures/drupal/core/tests/TestSuites/FunctionalTestSuite.php ' ,
16
17
__DIR__ . '/../fixtures/drupal/core/tests/TestSuites/KernelTestSuite.php ' ,
17
- __DIR__ . '/../fixtures/drupal/core/tests/TestSuites/TestSuiteBase.php ' ,
18
18
__DIR__ . '/../fixtures/drupal/core/tests/TestSuites/UnitTestSuite.php ' ,
19
19
];
20
20
foreach ($ paths as $ path ) {
21
21
$ errors = $ this ->runAnalyze ($ path );
22
- $ this ->assertCount (0 , $ errors , print_r ($ errors , true ));
22
+ $ this ->assertCount (1 , $ errors ->getErrors (), $ path );
23
+ $ this ->assertEquals ('Unsafe usage of new static(). ' , $ errors ->getErrors ()[0 ]->getMessage ());
24
+ $ this ->assertCount (0 , $ errors ->getInternalErrors (), print_r ($ errors ->getInternalErrors (), true ));
23
25
}
26
+
27
+ // Abstract doesn't warn on static constructor.
28
+ $ errors = $ this ->runAnalyze (__DIR__ . '/../fixtures/drupal/core/tests/TestSuites/TestSuiteBase.php ' );
29
+ $ this ->assertCount (0 , $ errors ->getErrors (), $ path );
30
+ $ this ->assertCount (0 , $ errors ->getInternalErrors (), print_r ($ errors ->getInternalErrors (), true ));
24
31
}
25
32
26
33
public function testDrupalTestInChildSiteContant () {
27
34
$ errors = $ this ->runAnalyze (__DIR__ . '/../fixtures/drupal/modules/phpstan_fixtures/src/DrupalTestInChildSiteContant.php ' );
28
- $ this ->assertCount (0 , $ errors );
35
+ $ this ->assertCount (0 , $ errors ->getErrors ());
36
+ $ this ->assertCount (0 , $ errors ->getInternalErrors ());
29
37
}
30
38
31
39
public function testExtensionReportsError () {
32
40
$ errors = $ this ->runAnalyze (__DIR__ . '/../fixtures/drupal/modules/phpstan_fixtures/phpstan_fixtures.module ' );
33
- $ this ->assertCount (2 , $ errors , var_export ($ errors , true ));
41
+ $ this ->assertCount (2 , $ errors ->getErrors (), var_export ($ errors , true ));
42
+ $ this ->assertCount (0 , $ errors ->getInternalErrors (), var_export ($ errors , true ));
43
+
44
+ $ errors = $ errors ->getErrors ();
34
45
$ error = array_shift ($ errors );
35
46
$ this ->assertEquals ('If condition is always false. ' , $ error ->getMessage ());
36
47
$ error = array_shift ($ errors );
@@ -45,7 +56,8 @@ public function testExtensionTestSuiteAutoloading() {
45
56
];
46
57
foreach ($ paths as $ path ) {
47
58
$ errors = $ this ->runAnalyze ($ path );
48
- $ this ->assertCount (0 , $ errors , print_r ($ errors , true ));
59
+ $ this ->assertCount (0 , $ errors ->getErrors (), print_r ($ errors , true ));
60
+ $ this ->assertCount (0 , $ errors ->getInternalErrors (), print_r ($ errors , true ));
49
61
}
50
62
}
51
63
@@ -55,20 +67,22 @@ public function testServiceMapping() {
55
67
'Call to an undefined method Drupal\Core\Entity\EntityManager::thisMethodDoesNotExist(). ' ,
56
68
];
57
69
$ errors = $ this ->runAnalyze (__DIR__ . '/../fixtures/drupal/modules/phpstan_fixtures/src/TestServicesMappingExtension.php ' );
58
- $ this ->assertCount (2 , $ errors );
59
- foreach ($ errors as $ key => $ error ) {
70
+ $ this ->assertCount (2 , $ errors ->getErrors ());
71
+ $ this ->assertCount (0 , $ errors ->getInternalErrors ());
72
+ foreach ($ errors ->getErrors () as $ key => $ error ) {
60
73
$ this ->assertEquals ($ errorMessages [$ key ], $ error ->getMessage ());
61
74
}
62
75
}
63
76
64
77
public function testAppRootPseudoService () {
65
- $ errorMessages = [];
66
78
$ errors = $ this ->runAnalyze (__DIR__ . '/../fixtures/drupal/modules/phpstan_fixtures/src/AppRootParameter.php ' );
67
- $ this ->assertCount (0 , $ errors , var_export ($ errors , TRUE ));
79
+ $ this ->assertCount (0 , $ errors ->getErrors (), var_export ($ errors , TRUE ));
80
+ $ this ->assertCount (0 , $ errors ->getInternalErrors (), var_export ($ errors , TRUE ));
68
81
}
69
82
70
83
public function testThemeSettingsFile () {
71
84
$ errors = $ this ->runAnalyze (__DIR__ . '/../fixtures/drupal/core/modules/system/tests/themes/test_theme_settings/theme-settings.php ' );
72
- $ this ->assertCount (0 , $ errors , var_export ($ errors , TRUE ));
85
+ $ this ->assertCount (0 , $ errors ->getErrors (), var_export ($ errors , TRUE ));
86
+ $ this ->assertCount (0 , $ errors ->getInternalErrors (), var_export ($ errors , TRUE ));
73
87
}
74
88
}
0 commit comments