Skip to content

Commit 6da6d3a

Browse files
committed
Tests: fix up some setup/teardown method signatures
The `setUpBeforeClass()` and `tearDownAfterClass()` type methods should have visibility `public` and should be static methods, even when invoked via the annotations. To be honest, I'm a bit surprised PHPUnit didn't flag some of these as errors, but either way, it's fixed now. Ref: https://docs.phpunit.de/en/9.6/fixtures.html#fixtures-examples-templatemethodstest-php
1 parent 95e3a35 commit 6da6d3a

5 files changed

+12
-12
lines changed

tests/Core/Config/ReportWidthTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ final class ReportWidthTest extends TestCase
2929
*
3030
* @return void
3131
*/
32-
public static function cleanConfig()
32+
protected function cleanConfig()
3333
{
3434
// Set to the property's default value to clear out potentially set values from other tests.
3535
self::setStaticProperty('executablePaths', []);
@@ -52,7 +52,7 @@ public static function cleanConfig()
5252
*
5353
* @return void
5454
*/
55-
public function resetConfig()
55+
protected function resetConfig()
5656
{
5757
$_SERVER['argv'] = [];
5858

tests/Core/Ruleset/ExpandRulesetReferenceHomePathTest.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,9 @@ final class ExpandRulesetReferenceHomePathTest extends AbstractRulesetTestCase
3636
*
3737
* @return void
3838
*/
39-
protected function storeHomePath()
39+
public static function storeHomePath()
4040
{
41-
$this->homepath = getenv('HOME');
41+
self::$homepath = getenv('HOME');
4242

4343
}//end storeHomePath()
4444

@@ -50,10 +50,10 @@ protected function storeHomePath()
5050
*
5151
* @return void
5252
*/
53-
protected function restoreHomePath()
53+
public static function restoreHomePath()
5454
{
55-
if (is_string($this->homepath) === true) {
56-
putenv('HOME='.$this->homepath);
55+
if (is_string(self::$homepath) === true) {
56+
putenv('HOME='.self::$homepath);
5757
} else {
5858
// Remove the environment variable as it didn't exist before.
5959
putenv('HOME');

tests/Core/Ruleset/RuleInclusionAbsoluteLinuxTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class RuleInclusionAbsoluteLinuxTest extends TestCase
5050
*
5151
* @return void
5252
*/
53-
public function initializeConfigAndRuleset()
53+
protected function initializeConfigAndRuleset()
5454
{
5555
$this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
5656
$repoRootDir = dirname(dirname(dirname(__DIR__)));
@@ -84,7 +84,7 @@ public function initializeConfigAndRuleset()
8484
*
8585
* @return void
8686
*/
87-
public function resetRuleset()
87+
protected function resetRuleset()
8888
{
8989
file_put_contents($this->standard, $this->contents);
9090

tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ final class RuleInclusionAbsoluteWindowsTest extends TestCase
5252
*
5353
* @return void
5454
*/
55-
public function initializeConfigAndRuleset()
55+
protected function initializeConfigAndRuleset()
5656
{
5757
$this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
5858
$repoRootDir = dirname(dirname(dirname(__DIR__)));
@@ -81,7 +81,7 @@ public function initializeConfigAndRuleset()
8181
*
8282
* @return void
8383
*/
84-
public function resetRuleset()
84+
protected function resetRuleset()
8585
{
8686
file_put_contents($this->standard, $this->contents);
8787

tests/Core/Ruleset/RuleInclusionTest.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class RuleInclusionTest extends AbstractRulesetTestCase
5050
*
5151
* @return void
5252
*/
53-
public static function initializeConfigAndRuleset()
53+
protected function initializeConfigAndRuleset()
5454
{
5555
if (self::$standard === '') {
5656
$standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';

0 commit comments

Comments
 (0)