1 | <?php |
||
20 | trait PHPUnitTestTrait { |
||
21 | |||
22 | /** |
||
23 | * Set of PHPUnit base classes, without leading backslash |
||
24 | * @var string[] |
||
25 | */ |
||
26 | private static $PHPUNIT_CLASSES = [ |
||
27 | // @phan-suppress-previous-line PhanReadOnlyPrivateProperty Traits cannot have constants |
||
28 | 'MediaWikiTestCase' => 'MediaWikiTestCase', |
||
29 | 'MediaWikiUnitTestCase' => 'MediaWikiUnitTestCase', |
||
30 | 'MediaWikiIntegrationTestCase' => 'MediaWikiIntegrationTestCase', |
||
31 | 'PHPUnit_Framework_TestCase' => 'PHPUnit_Framework_TestCase', |
||
32 | // This class may be 'use'd, but checking for that would be complicated |
||
33 | 'PHPUnit\\Framework\\TestCase' => 'PHPUnit\\Framework\\TestCase', |
||
34 | // HACK: Add WordPress classes |
||
35 | 'WP_UnitTestCase' => 'WP_UnitTestCase', |
||
36 | 'WP_UnitTestCase_Base' => 'WP_UnitTestCase_Base', |
||
37 | ]; |
||
38 | |||
39 | /** |
||
40 | * @param File $phpcsFile |
||
41 | * @param int|false $stackPtr |
||
42 | * |
||
43 | * @return bool |
||
44 | */ |
||
45 | private function isTestFile( File $phpcsFile, $stackPtr = false ) { |
||
50 | |||
51 | /** |
||
52 | * @param File $phpcsFile |
||
53 | * @param int|false $classToken Must point at a T_CLASS token |
||
54 | * |
||
55 | * @return bool |
||
56 | */ |
||
57 | private function isTestClass( File $phpcsFile, $classToken ) { |
||
72 | |||
73 | /** |
||
74 | * @param File $phpcsFile |
||
75 | * @param int $functionToken Token position of the function declaration |
||
76 | * @return bool |
||
77 | */ |
||
78 | private function isTestFunction( File $phpcsFile, $functionToken ) { |
||
82 | |||
83 | /** |
||
84 | * @param File $phpcsFile |
||
85 | * @param int|false $stackPtr Should point at the T_CLASS token or a token in the class |
||
86 | * |
||
87 | * @return int|false |
||
88 | */ |
||
89 | private function getClassToken( File $phpcsFile, $stackPtr ) { |
||
107 | |||
108 | } |
||
109 |
In PHP, under loose comparison (like
==
, or!=
, orswitch
conditions), values of different types might be equal.For
integer
values, zero is a special case, in particular the following results might be unexpected: