File tree Expand file tree Collapse file tree 10 files changed +70
-38
lines changed
src/Standards/Generic/Tests/Debug Expand file tree Collapse file tree 10 files changed +70
-38
lines changed Original file line number Diff line number Diff line change @@ -36,31 +36,33 @@ class ESLintUnitTest extends AbstractSniffUnitTest
3636 /**
3737 * Sets up this unit test.
3838 *
39+ * @before
40+ *
3941 * @return void
4042 */
41- protected function setUp ()
43+ protected function setUpPrerequisites ()
4244 {
43- parent ::setUp ();
45+ parent ::setUpPrerequisites ();
4446
4547 $ cwd = getcwd ();
4648 file_put_contents ($ cwd .'/.eslintrc.json ' , self ::ESLINT_CONFIG );
4749
48- }//end setUp ()
50+ }//end setUpPrerequisites ()
4951
5052
5153 /**
5254 * Remove artifact.
5355 *
56+ * @after
57+ *
5458 * @return void
5559 */
56- protected function tearDown ()
60+ protected function resetProperties ()
5761 {
58- parent ::tearDown ();
59-
6062 $ cwd = getcwd ();
6163 unlink ($ cwd .'/.eslintrc.json ' );
6264
63- }//end tearDown ()
65+ }//end resetProperties ()
6466
6567
6668 /**
Original file line number Diff line number Diff line change @@ -41,9 +41,11 @@ abstract class AbstractMethodUnitTest extends TestCase
4141 * The test case file for a unit test class has to be in the same directory
4242 * directory and use the same file name as the test class, using the .inc extension.
4343 *
44+ * @beforeClass
45+ *
4446 * @return void
4547 */
46- public static function setUpBeforeClass ()
48+ public static function initializeFile ()
4749 {
4850 $ config = new Config ();
4951 $ config ->standards = ['PSR1 ' ];
@@ -62,19 +64,21 @@ public static function setUpBeforeClass()
6264 self ::$ phpcsFile = new DummyFile ($ contents , $ ruleset , $ config );
6365 self ::$ phpcsFile ->process ();
6466
65- }//end setUpBeforeClass ()
67+ }//end initializeFile ()
6668
6769
6870 /**
6971 * Clean up after finished test.
7072 *
73+ * @afterClass
74+ *
7175 * @return void
7276 */
73- public static function tearDownAfterClass ()
77+ public static function resetFile ()
7478 {
7579 self ::$ phpcsFile = null ;
7680
77- }//end tearDownAfterClass ()
81+ }//end resetFile ()
7882
7983
8084 /**
Original file line number Diff line number Diff line change @@ -19,13 +19,15 @@ class DetermineLoadedClassTest extends TestCase
1919 /**
2020 * Load the test files.
2121 *
22+ * @beforeClass
23+ *
2224 * @return void
2325 */
24- public static function setUpBeforeClass ()
26+ public static function includeFixture ()
2527 {
2628 include __DIR__ .'/TestFiles/Sub/C.inc ' ;
2729
28- }//end setUpBeforeClass ()
30+ }//end includeFixture ()
2931
3032
3133 /**
Original file line number Diff line number Diff line change @@ -36,9 +36,11 @@ class AcceptTest extends TestCase
3636 /**
3737 * Initialize the test.
3838 *
39+ * @before
40+ *
3941 * @return void
4042 */
41- public function setUp ()
43+ public function skipOnPEAR ()
4244 {
4345 if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
4446 // PEAR installs test and sniff files into different locations
@@ -47,15 +49,17 @@ public function setUp()
4749 $ this ->markTestSkipped ('Test cannot run from a PEAR install ' );
4850 }
4951
50- }//end setUp ()
52+ }//end skipOnPEAR ()
5153
5254
5355 /**
5456 * Initialize the config and ruleset objects based on the `AcceptTest.xml` ruleset file.
5557 *
58+ * @beforeClass
59+ *
5660 * @return void
5761 */
58- public static function setUpBeforeClass ()
62+ public static function initializeConfigAndRuleset ()
5963 {
6064 if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
6165 // This test will be skipped.
@@ -66,7 +70,7 @@ public static function setUpBeforeClass()
6670 self ::$ config = new Config (["--standard= $ standard " , "--ignore=*/somethingelse/* " ]);
6771 self ::$ ruleset = new Ruleset (self ::$ config );
6872
69- }//end setUpBeforeClass ()
73+ }//end initializeConfigAndRuleset ()
7074
7175
7276 /**
Original file line number Diff line number Diff line change @@ -41,9 +41,11 @@ class RuleInclusionAbsoluteLinuxTest extends TestCase
4141 /**
4242 * Initialize the config and ruleset objects.
4343 *
44+ * @before
45+ *
4446 * @return void
4547 */
46- public function setUp ()
48+ public function initializeConfigAndRuleset ()
4749 {
4850 if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
4951 // PEAR installs test and sniff files into different locations
@@ -74,19 +76,21 @@ public function setUp()
7476 $ config = new Config (["--standard= {$ this ->standard }" ]);
7577 $ this ->ruleset = new Ruleset ($ config );
7678
77- }//end setUp ()
79+ }//end initializeConfigAndRuleset ()
7880
7981
8082 /**
8183 * Reset ruleset file.
8284 *
85+ * @after
86+ *
8387 * @return void
8488 */
85- public function tearDown ()
89+ public function resetRuleset ()
8690 {
8791 file_put_contents ($ this ->standard , $ this ->contents );
8892
89- }//end tearDown ()
93+ }//end resetRuleset ()
9094
9195
9296 /**
Original file line number Diff line number Diff line change @@ -41,9 +41,11 @@ class RuleInclusionAbsoluteWindowsTest extends TestCase
4141 /**
4242 * Initialize the config and ruleset objects.
4343 *
44+ * @before
45+ *
4446 * @return void
4547 */
46- public function setUp ()
48+ public function initializeConfigAndRuleset ()
4749 {
4850 if (DIRECTORY_SEPARATOR === '/ ' ) {
4951 $ this ->markTestSkipped ('Windows specific test ' );
@@ -73,21 +75,23 @@ public function setUp()
7375 $ config = new Config (["--standard= {$ this ->standard }" ]);
7476 $ this ->ruleset = new Ruleset ($ config );
7577
76- }//end setUp ()
78+ }//end initializeConfigAndRuleset ()
7779
7880
7981 /**
8082 * Reset ruleset file.
8183 *
84+ * @after
85+ *
8286 * @return void
8387 */
84- public function tearDown ()
88+ public function resetRuleset ()
8589 {
8690 if (DIRECTORY_SEPARATOR !== '/ ' ) {
8791 file_put_contents ($ this ->standard , $ this ->contents );
8892 }
8993
90- }//end tearDown ()
94+ }//end resetRuleset ()
9195
9296
9397 /**
Original file line number Diff line number Diff line change @@ -42,9 +42,11 @@ class RuleInclusionTest extends TestCase
4242 /**
4343 * Initialize the test.
4444 *
45+ * @before
46+ *
4547 * @return void
4648 */
47- public function setUp ()
49+ public function skipOnPEAR ()
4850 {
4951 if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
5052 // PEAR installs test and sniff files into different locations
@@ -53,15 +55,17 @@ public function setUp()
5355 $ this ->markTestSkipped ('Test cannot run from a PEAR install ' );
5456 }
5557
56- }//end setUp ()
58+ }//end skipOnPEAR ()
5759
5860
5961 /**
6062 * Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file.
6163 *
64+ * @beforeClass
65+ *
6266 * @return void
6367 */
64- public static function setUpBeforeClass ()
68+ public static function initializeConfigAndRuleset ()
6569 {
6670 if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
6771 // This test will be skipped.
@@ -92,19 +96,21 @@ public static function setUpBeforeClass()
9296 $ config = new Config (["--standard= $ standard " ]);
9397 self ::$ ruleset = new Ruleset ($ config );
9498
95- }//end setUpBeforeClass ()
99+ }//end initializeConfigAndRuleset ()
96100
97101
98102 /**
99103 * Reset ruleset file.
100104 *
105+ * @after
106+ *
101107 * @return void
102108 */
103- public function tearDown ()
109+ public function resetRuleset ()
104110 {
105111 file_put_contents (self ::$ standard , self ::$ contents );
106112
107- }//end tearDown ()
113+ }//end resetRuleset ()
108114
109115
110116 /**
Original file line number Diff line number Diff line change @@ -31,14 +31,16 @@ class AbstractArraySniffTest extends AbstractMethodUnitTest
3131 * The test case file for a unit test class has to be in the same directory
3232 * directory and use the same file name as the test class, using the .inc extension.
3333 *
34+ * @beforeClass
35+ *
3436 * @return void
3537 */
36- public static function setUpBeforeClass ()
38+ public static function initializeFile ()
3739 {
3840 self ::$ sniff = new AbstractArraySniffTestable ();
39- parent ::setUpBeforeClass ();
41+ parent ::initializeFile ();
4042
41- }//end setUpBeforeClass ()
43+ }//end initializeFile ()
4244
4345
4446 /**
Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ class HeredocNowdocCloserTest extends AbstractMethodUnitTest
2929 * {@internal This is a near duplicate of the original method. Only difference is that
3030 * tab replacement is enabled for this test.}
3131 *
32+ * @beforeClass
33+ *
3234 * @return void
3335 */
34- public static function setUpBeforeClass ()
36+ public static function initializeFile ()
3537 {
3638 $ config = new Config ();
3739 $ config ->standards = ['PSR1 ' ];
@@ -51,7 +53,7 @@ public static function setUpBeforeClass()
5153 self ::$ phpcsFile = new DummyFile ($ contents , $ ruleset , $ config );
5254 self ::$ phpcsFile ->process ();
5355
54- }//end setUpBeforeClass ()
56+ }//end initializeFile ()
5557
5658
5759 /**
Original file line number Diff line number Diff line change @@ -50,15 +50,17 @@ abstract class AbstractSniffUnitTest extends TestCase
5050 /**
5151 * Sets up this unit test.
5252 *
53+ * @before
54+ *
5355 * @return void
5456 */
55- protected function setUp ()
57+ protected function setUpPrerequisites ()
5658 {
5759 $ class = get_class ($ this );
5860 $ this ->standardsDir = $ GLOBALS ['PHP_CODESNIFFER_STANDARD_DIRS ' ][$ class ];
5961 $ this ->testsDir = $ GLOBALS ['PHP_CODESNIFFER_TEST_DIRS ' ][$ class ];
6062
61- }//end setUp ()
63+ }//end setUpPrerequisites ()
6264
6365
6466 /**
You can’t perform that action at this time.
0 commit comments