Skip to content

Commit 2ea974b

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 cae50d8 commit 2ea974b

File tree

5 files changed

+12
-12
lines changed

5 files changed

+12
-12
lines changed

tests/Core/Config/ReportWidthTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ final class ReportWidthTest extends TestCase
2727
*
2828
* @return void
2929
*/
30-
public function setUp(): void
30+
protected function setUp(): void
3131
{
3232
// Set to the property's default value to clear out potentially set values from other tests.
3333
self::setStaticProperty('executablePaths', []);
@@ -45,7 +45,7 @@ public function setUp(): void
4545
*
4646
* @return void
4747
*/
48-
public function tearDown(): void
48+
protected function tearDown(): void
4949
{
5050
$_SERVER['argv'] = [];
5151

tests/Core/Ruleset/ExpandRulesetReferenceHomePathTest.php

Lines changed: 5 additions & 5 deletions
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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class RuleInclusionAbsoluteLinuxTest extends TestCase
4848
*
4949
* @return void
5050
*/
51-
public function setUp(): void
51+
protected function setUp(): void
5252
{
5353
$this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
5454
$repoRootDir = dirname(dirname(dirname(__DIR__)));
@@ -80,7 +80,7 @@ public function setUp(): void
8080
*
8181
* @return void
8282
*/
83-
public function tearDown(): void
83+
protected function tearDown(): void
8484
{
8585
file_put_contents($this->standard, $this->contents);
8686

tests/Core/Ruleset/RuleInclusionAbsoluteWindowsTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ final class RuleInclusionAbsoluteWindowsTest extends TestCase
5050
*
5151
* @return void
5252
*/
53-
public function setUp(): void
53+
protected function setUp(): void
5454
{
5555
$this->standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';
5656
$repoRootDir = dirname(dirname(dirname(__DIR__)));
@@ -77,7 +77,7 @@ public function setUp(): void
7777
*
7878
* @return void
7979
*/
80-
public function tearDown(): void
80+
protected function tearDown(): void
8181
{
8282
file_put_contents($this->standard, $this->contents);
8383

tests/Core/Ruleset/RuleInclusionTest.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ final class RuleInclusionTest extends AbstractRulesetTestCase
4848
*
4949
* @return void
5050
*/
51-
public function setUp(): void
51+
protected function setUp(): void
5252
{
5353
if (self::$standard === '') {
5454
$standard = __DIR__.'/'.basename(__FILE__, '.php').'.xml';

0 commit comments

Comments
 (0)