Navigation Menu

Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DX: UtilsTest - add missing teardown #5613

Merged
merged 1 commit into from Apr 11, 2021
Merged

Conversation

keradus
Copy link
Member

@keradus keradus commented Apr 9, 2021

showing the issue:

ker@dus:~/github/PHP-CS-Fixer λ git du
diff --git a/tests/UtilsTest.php b/tests/UtilsTest.php
index 122db36c7..4a0db6acc 100644
--- a/tests/UtilsTest.php
+++ b/tests/UtilsTest.php
@@ -298,6 +298,7 @@ public function provideCalculateBitmaskCases()
     public function testTriggerDeprecationWhenFutureModeIsOff()
     {
         putenv('PHP_CS_FIXER_FUTURE_MODE=0');
+        var_dump(["method" => __METHOD__, "PHP_CS_FIXER_FUTURE_MODE env var" => getenv('PHP_CS_FIXER_FUTURE_MODE')]);
 
         $this->expectDeprecation('The message');
 
@@ -307,6 +308,7 @@ public function testTriggerDeprecationWhenFutureModeIsOff()
     public function testTriggerDeprecationWhenFutureModeIsOn()
     {
         putenv('PHP_CS_FIXER_FUTURE_MODE=1');
+        var_dump(["method" => __METHOD__, "PHP_CS_FIXER_FUTURE_MODE env var" => getenv('PHP_CS_FIXER_FUTURE_MODE')]);
 
         $this->expectException(\DomainException::class);
         $this->expectExceptionMessage('The message');
@@ -314,6 +316,12 @@ public function testTriggerDeprecationWhenFutureModeIsOn()
         Utils::triggerDeprecation('The message', \DomainException::class);
     }
 
+    public function testXXX()
+    {
+        var_dump(["method" => __METHOD__, "PHP_CS_FIXER_FUTURE_MODE env var" => getenv('PHP_CS_FIXER_FUTURE_MODE')]);
+        $this->assertTrue(true);
+    }
+
     private function createFixerDouble($name, $priority)
     {
         $fixer = $this->prophesize(FixerInterface::class);

execution:

ker@dus:~/github/PHP-CS-Fixer λ vendor/bin/phpunit tests/UtilsTest.php 
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing PhpCsFixer\Tests\UtilsTest
......................................Rarray(2) {
  ["method"]=>
  string(69) "PhpCsFixer\Tests\UtilsTest::testTriggerDeprecationWhenFutureModeIsOff"
  ["PHP_CS_FIXER_FUTURE_MODE env var"]=>
  string(1) "0"
}
Rarray(2) {
  ["method"]=>
  string(68) "PhpCsFixer\Tests\UtilsTest::testTriggerDeprecationWhenFutureModeIsOn"
  ["PHP_CS_FIXER_FUTURE_MODE env var"]=>
  string(1) "1"
}
R                                                                                                                                                                                                                           41 / 41 (100%)array(2) {
  ["method"]=>
  string(35) "PhpCsFixer\Tests\UtilsTest::testXXX"
  ["PHP_CS_FIXER_FUTURE_MODE env var"]=>
  string(1) "1"
}

as we see, the new method testXXX is having non-default env-variable, because the previously executed method changed the global state

after fix:

ker@dus:~/github/PHP-CS-Fixer λ vendor/bin/phpunit tests/UtilsTest.php 
PHPUnit 9.5.4 by Sebastian Bergmann and contributors.

Warning:       Your XML configuration validates against a deprecated schema.
Suggestion:    Migrate your XML configuration using "--migrate-configuration"!

Testing PhpCsFixer\Tests\UtilsTest
......................................Rarray(2) {
  ["method"]=>
  string(69) "PhpCsFixer\Tests\UtilsTest::testTriggerDeprecationWhenFutureModeIsOff"
  ["PHP_CS_FIXER_FUTURE_MODE env var"]=>
  string(1) "0"
}
Rarray(2) {
  ["method"]=>
  string(68) "PhpCsFixer\Tests\UtilsTest::testTriggerDeprecationWhenFutureModeIsOn"
  ["PHP_CS_FIXER_FUTURE_MODE env var"]=>
  string(1) "1"
}
R                                                                                                                                                                                                                           41 / 41 (100%)array(2) {
  ["method"]=>
  string(35) "PhpCsFixer\Tests\UtilsTest::testXXX"
  ["PHP_CS_FIXER_FUTURE_MODE env var"]=>
  string(0) ""
}

@keradus keradus added this to the 2.19.0 milestone Apr 9, 2021
@keradus keradus requested a review from kubawerlos April 9, 2021 07:36
@coveralls
Copy link

coveralls commented Apr 9, 2021

Coverage Status

Coverage remained the same at 91.887% when pulling cbd400e on keradus:2.19-fix into 1e73620 on FriendsOfPHP:master.

tests/UtilsTest.php Outdated Show resolved Hide resolved
tests/UtilsTest.php Outdated Show resolved Hide resolved
@kubawerlos kubawerlos added kind/cleanup RTM Ready To Merge labels Apr 9, 2021
@keradus keradus removed the RTM Ready To Merge label Apr 11, 2021
@keradus keradus merged commit f4e7211 into PHP-CS-Fixer:master Apr 11, 2021
@keradus keradus deleted the 2.19-fix branch April 11, 2021 12:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants