File tree Expand file tree Collapse file tree 11 files changed +74
-40
lines changed
src/Standards/Generic/Tests/Debug Expand file tree Collapse file tree 11 files changed +74
-40
lines changed Original file line number Diff line number Diff line change @@ -36,31 +36,33 @@ class ESLintUnitTest extends AbstractSniffUnitTest
36
36
/**
37
37
* Sets up this unit test.
38
38
*
39
+ * @before
40
+ *
39
41
* @return void
40
42
*/
41
- protected function setUp ()
43
+ protected function setUpPrerequisites ()
42
44
{
43
- parent ::setUp ();
45
+ parent ::setUpPrerequisites ();
44
46
45
47
$ cwd = getcwd ();
46
48
file_put_contents ($ cwd .'/.eslintrc.json ' , self ::ESLINT_CONFIG );
47
49
48
- }//end setUp ()
50
+ }//end setUpPrerequisites ()
49
51
50
52
51
53
/**
52
54
* Remove artifact.
53
55
*
56
+ * @after
57
+ *
54
58
* @return void
55
59
*/
56
- protected function tearDown ()
60
+ protected function resetProperties ()
57
61
{
58
- parent ::tearDown ();
59
-
60
62
$ cwd = getcwd ();
61
63
unlink ($ cwd .'/.eslintrc.json ' );
62
64
63
- }//end tearDown ()
65
+ }//end resetProperties ()
64
66
65
67
66
68
/**
Original file line number Diff line number Diff line change @@ -41,9 +41,11 @@ abstract class AbstractMethodUnitTest extends TestCase
41
41
* The test case file for a unit test class has to be in the same directory
42
42
* directory and use the same file name as the test class, using the .inc extension.
43
43
*
44
+ * @beforeClass
45
+ *
44
46
* @return void
45
47
*/
46
- public static function setUpBeforeClass ()
48
+ public static function initializeFile ()
47
49
{
48
50
$ config = new Config ();
49
51
$ config ->standards = ['PSR1 ' ];
@@ -62,19 +64,21 @@ public static function setUpBeforeClass()
62
64
self ::$ phpcsFile = new DummyFile ($ contents , $ ruleset , $ config );
63
65
self ::$ phpcsFile ->process ();
64
66
65
- }//end setUpBeforeClass ()
67
+ }//end initializeFile ()
66
68
67
69
68
70
/**
69
71
* Clean up after finished test.
70
72
*
73
+ * @afterClass
74
+ *
71
75
* @return void
72
76
*/
73
- public static function tearDownAfterClass ()
77
+ public static function resetFile ()
74
78
{
75
79
self ::$ phpcsFile = null ;
76
80
77
- }//end tearDownAfterClass ()
81
+ }//end resetFile ()
78
82
79
83
80
84
/**
Original file line number Diff line number Diff line change @@ -19,13 +19,15 @@ class DetermineLoadedClassTest extends TestCase
19
19
/**
20
20
* Load the test files.
21
21
*
22
+ * @beforeClass
23
+ *
22
24
* @return void
23
25
*/
24
- public static function setUpBeforeClass ()
26
+ public static function includeFixture ()
25
27
{
26
28
include __DIR__ .'/TestFiles/Sub/C.inc ' ;
27
29
28
- }//end setUpBeforeClass ()
30
+ }//end includeFixture ()
29
31
30
32
31
33
/**
Original file line number Diff line number Diff line change @@ -36,9 +36,11 @@ class AcceptTest extends TestCase
36
36
/**
37
37
* Initialize the test.
38
38
*
39
+ * @before
40
+ *
39
41
* @return void
40
42
*/
41
- public function setUp ()
43
+ public function skipOnPEAR ()
42
44
{
43
45
if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
44
46
// PEAR installs test and sniff files into different locations
@@ -47,15 +49,17 @@ public function setUp()
47
49
$ this ->markTestSkipped ('Test cannot run from a PEAR install ' );
48
50
}
49
51
50
- }//end setUp ()
52
+ }//end skipOnPEAR ()
51
53
52
54
53
55
/**
54
56
* Initialize the config and ruleset objects based on the `AcceptTest.xml` ruleset file.
55
57
*
58
+ * @beforeClass
59
+ *
56
60
* @return void
57
61
*/
58
- public static function setUpBeforeClass ()
62
+ public static function initializeConfigAndRuleset ()
59
63
{
60
64
if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
61
65
// This test will be skipped.
@@ -66,7 +70,7 @@ public static function setUpBeforeClass()
66
70
self ::$ config = new Config (["--standard= $ standard " , "--ignore=*/somethingelse/* " ]);
67
71
self ::$ ruleset = new Ruleset (self ::$ config );
68
72
69
- }//end setUpBeforeClass ()
73
+ }//end initializeConfigAndRuleset ()
70
74
71
75
72
76
/**
Original file line number Diff line number Diff line change @@ -41,9 +41,11 @@ class RuleInclusionAbsoluteLinuxTest extends TestCase
41
41
/**
42
42
* Initialize the config and ruleset objects.
43
43
*
44
+ * @before
45
+ *
44
46
* @return void
45
47
*/
46
- public function setUp ()
48
+ public function initializeConfigAndRuleset ()
47
49
{
48
50
if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
49
51
// PEAR installs test and sniff files into different locations
@@ -74,19 +76,21 @@ public function setUp()
74
76
$ config = new Config (["--standard= {$ this ->standard }" ]);
75
77
$ this ->ruleset = new Ruleset ($ config );
76
78
77
- }//end setUp ()
79
+ }//end initializeConfigAndRuleset ()
78
80
79
81
80
82
/**
81
83
* Reset ruleset file.
82
84
*
85
+ * @after
86
+ *
83
87
* @return void
84
88
*/
85
- public function tearDown ()
89
+ public function resetRuleset ()
86
90
{
87
91
file_put_contents ($ this ->standard , $ this ->contents );
88
92
89
- }//end tearDown ()
93
+ }//end resetRuleset ()
90
94
91
95
92
96
/**
Original file line number Diff line number Diff line change @@ -41,9 +41,11 @@ class RuleInclusionAbsoluteWindowsTest extends TestCase
41
41
/**
42
42
* Initialize the config and ruleset objects.
43
43
*
44
+ * @before
45
+ *
44
46
* @return void
45
47
*/
46
- public function setUp ()
48
+ public function initializeConfigAndRuleset ()
47
49
{
48
50
if (DIRECTORY_SEPARATOR === '/ ' ) {
49
51
$ this ->markTestSkipped ('Windows specific test ' );
@@ -73,21 +75,23 @@ public function setUp()
73
75
$ config = new Config (["--standard= {$ this ->standard }" ]);
74
76
$ this ->ruleset = new Ruleset ($ config );
75
77
76
- }//end setUp ()
78
+ }//end initializeConfigAndRuleset ()
77
79
78
80
79
81
/**
80
82
* Reset ruleset file.
81
83
*
84
+ * @after
85
+ *
82
86
* @return void
83
87
*/
84
- public function tearDown ()
88
+ public function resetRuleset ()
85
89
{
86
90
if (DIRECTORY_SEPARATOR !== '/ ' ) {
87
91
file_put_contents ($ this ->standard , $ this ->contents );
88
92
}
89
93
90
- }//end tearDown ()
94
+ }//end resetRuleset ()
91
95
92
96
93
97
/**
Original file line number Diff line number Diff line change @@ -42,9 +42,11 @@ class RuleInclusionTest extends TestCase
42
42
/**
43
43
* Initialize the test.
44
44
*
45
+ * @before
46
+ *
45
47
* @return void
46
48
*/
47
- public function setUp ()
49
+ public function skipOnPEAR ()
48
50
{
49
51
if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
50
52
// PEAR installs test and sniff files into different locations
@@ -53,15 +55,17 @@ public function setUp()
53
55
$ this ->markTestSkipped ('Test cannot run from a PEAR install ' );
54
56
}
55
57
56
- }//end setUp ()
58
+ }//end skipOnPEAR ()
57
59
58
60
59
61
/**
60
62
* Initialize the config and ruleset objects based on the `RuleInclusionTest.xml` ruleset file.
61
63
*
64
+ * @beforeClass
65
+ *
62
66
* @return void
63
67
*/
64
- public static function setUpBeforeClass ()
68
+ public static function initializeConfigAndRuleset ()
65
69
{
66
70
if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
67
71
// This test will be skipped.
@@ -92,19 +96,21 @@ public static function setUpBeforeClass()
92
96
$ config = new Config (["--standard= $ standard " ]);
93
97
self ::$ ruleset = new Ruleset ($ config );
94
98
95
- }//end setUpBeforeClass ()
99
+ }//end initializeConfigAndRuleset ()
96
100
97
101
98
102
/**
99
103
* Reset ruleset file.
100
104
*
105
+ * @after
106
+ *
101
107
* @return void
102
108
*/
103
- public function tearDown ()
109
+ public function resetRuleset ()
104
110
{
105
111
file_put_contents (self ::$ standard , self ::$ contents );
106
112
107
- }//end tearDown ()
113
+ }//end resetRuleset ()
108
114
109
115
110
116
/**
Original file line number Diff line number Diff line change @@ -26,9 +26,11 @@ class SetSniffPropertyTest extends TestCase
26
26
/**
27
27
* Initialize the test.
28
28
*
29
+ * @before
30
+ *
29
31
* @return void
30
32
*/
31
- public function setUp ()
33
+ public function skipOnPEAR ()
32
34
{
33
35
if ($ GLOBALS ['PHP_CODESNIFFER_PEAR ' ] === true ) {
34
36
// PEAR installs test and sniff files into different locations
@@ -37,7 +39,7 @@ public function setUp()
37
39
$ this ->markTestSkipped ('Test cannot run from a PEAR install ' );
38
40
}
39
41
40
- }//end setUp ()
42
+ }//end skipOnPEAR ()
41
43
42
44
43
45
/**
Original file line number Diff line number Diff line change @@ -31,14 +31,16 @@ class AbstractArraySniffTest extends AbstractMethodUnitTest
31
31
* The test case file for a unit test class has to be in the same directory
32
32
* directory and use the same file name as the test class, using the .inc extension.
33
33
*
34
+ * @beforeClass
35
+ *
34
36
* @return void
35
37
*/
36
- public static function setUpBeforeClass ()
38
+ public static function initializeFile ()
37
39
{
38
40
self ::$ sniff = new AbstractArraySniffTestable ();
39
- parent ::setUpBeforeClass ();
41
+ parent ::initializeFile ();
40
42
41
- }//end setUpBeforeClass ()
43
+ }//end initializeFile ()
42
44
43
45
44
46
/**
Original file line number Diff line number Diff line change @@ -29,9 +29,11 @@ class HeredocNowdocCloserTest extends AbstractMethodUnitTest
29
29
* {@internal This is a near duplicate of the original method. Only difference is that
30
30
* tab replacement is enabled for this test.}
31
31
*
32
+ * @beforeClass
33
+ *
32
34
* @return void
33
35
*/
34
- public static function setUpBeforeClass ()
36
+ public static function initializeFile ()
35
37
{
36
38
$ config = new Config ();
37
39
$ config ->standards = ['PSR1 ' ];
@@ -51,7 +53,7 @@ public static function setUpBeforeClass()
51
53
self ::$ phpcsFile = new DummyFile ($ contents , $ ruleset , $ config );
52
54
self ::$ phpcsFile ->process ();
53
55
54
- }//end setUpBeforeClass ()
56
+ }//end initializeFile ()
55
57
56
58
57
59
/**
Original file line number Diff line number Diff line change @@ -50,15 +50,17 @@ abstract class AbstractSniffUnitTest extends TestCase
50
50
/**
51
51
* Sets up this unit test.
52
52
*
53
+ * @before
54
+ *
53
55
* @return void
54
56
*/
55
- protected function setUp ()
57
+ protected function setUpPrerequisites ()
56
58
{
57
59
$ class = get_class ($ this );
58
60
$ this ->standardsDir = $ GLOBALS ['PHP_CODESNIFFER_STANDARD_DIRS ' ][$ class ];
59
61
$ this ->testsDir = $ GLOBALS ['PHP_CODESNIFFER_TEST_DIRS ' ][$ class ];
60
62
61
- }//end setUp ()
63
+ }//end setUpPrerequisites ()
62
64
63
65
64
66
/**
You can’t perform that action at this time.
0 commit comments