Browse Source

feat: support PHPUnit v9.1 naming for some asserts (#7997)

Krzysztof Ciszewski 7 months ago
parent
commit
7bb9c2654c

+ 1 - 1
doc/ruleSets/PHPUnit100MigrationRisky.rst

@@ -15,7 +15,7 @@ Using this rule set may lead to changes in your code's logic and behaviour. Use
 Rules
 -----
 
-- `@PHPUnit84Migration:risky <./PHPUnit84MigrationRisky.rst>`_
+- `@PHPUnit91Migration:risky <./PHPUnit91MigrationRisky.rst>`_
 - `php_unit_data_provider_static <./../rules/php_unit/php_unit_data_provider_static.rst>`_ with config:
 
   ``['force' => true]``

+ 19 - 0
doc/ruleSets/PHPUnit91MigrationRisky.rst

@@ -0,0 +1,19 @@
+======================================
+Rule set ``@PHPUnit91Migration:risky``
+======================================
+
+Rules to improve tests code for PHPUnit 9.1 compatibility.
+
+Warning
+-------
+
+This set contains rules that are risky
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+Using this rule set may lead to changes in your code's logic and behaviour. Use it with caution and review changes before incorporating them into your code base.
+
+Rules
+-----
+
+- `@PHPUnit84Migration:risky <./PHPUnit84MigrationRisky.rst>`_
+- `php_unit_assert_new_names <./../rules/php_unit/php_unit_assert_new_names.rst>`_

+ 1 - 0
doc/ruleSets/index.rst

@@ -39,6 +39,7 @@ List of Available Rule sets
 - `@PHPUnit60Migration:risky <./PHPUnit60MigrationRisky.rst>`_
 - `@PHPUnit75Migration:risky <./PHPUnit75MigrationRisky.rst>`_
 - `@PHPUnit84Migration:risky <./PHPUnit84MigrationRisky.rst>`_
+- `@PHPUnit91Migration:risky <./PHPUnit91MigrationRisky.rst>`_
 - `@PHPUnit100Migration:risky <./PHPUnit100MigrationRisky.rst>`_
 - `@PSR1 <./PSR1.rst>`_
 - `@PSR2 <./PSR2.rst>`_

+ 3 - 0
doc/rules/index.rst

@@ -640,6 +640,9 @@ PHP Tag
 PHPUnit
 -------
 
+- `php_unit_assert_new_names <./php_unit/php_unit_assert_new_names.rst>`_ *(risky)*
+
+  Rename deprecated PHPUnit assertions like ``assertFileNotExists`` to new methods like ``assertFileDoesNotExist``.
 - `php_unit_attributes <./php_unit/php_unit_attributes.rst>`_
 
   PHPUnit attributes must be used over their respective PHPDoc-based annotations.

+ 52 - 0
doc/rules/php_unit/php_unit_assert_new_names.rst

@@ -0,0 +1,52 @@
+==================================
+Rule ``php_unit_assert_new_names``
+==================================
+
+Rename deprecated PHPUnit assertions like ``assertFileNotExists`` to new methods
+like ``assertFileDoesNotExist``.
+
+Warning
+-------
+
+Using this rule is risky
+~~~~~~~~~~~~~~~~~~~~~~~~
+
+Fixer could be risky if one is overriding PHPUnit's native methods.
+
+Examples
+--------
+
+Example #1
+~~~~~~~~~~
+
+.. code-block:: diff
+
+   --- Original
+   +++ New
+    <?php
+    final class MyTest extends \PHPUnit_Framework_TestCase
+    {
+        public function testSomeTest()
+        {
+   -        $this->assertFileNotExists("test.php");
+   -        $this->assertNotIsWritable("path.php");
+   +        $this->assertFileDoesNotExist("test.php");
+   +        $this->assertIsNotWritable("path.php");
+        }
+    }
+
+Rule sets
+---------
+
+The rule is part of the following rule sets:
+
+- `@PHPUnit91Migration:risky <./../../ruleSets/PHPUnit91MigrationRisky.rst>`_
+- `@PHPUnit100Migration:risky <./../../ruleSets/PHPUnit100MigrationRisky.rst>`_
+
+References
+----------
+
+- Fixer class: `PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitAssertNewNamesFixer <./../../../src/Fixer/PhpUnit/PhpUnitAssertNewNamesFixer.php>`_
+- Test class: `PhpCsFixer\\Tests\\Fixer\\PhpUnit\\PhpUnitAssertNewNamesFixerTest <./../../../tests/Fixer/PhpUnit/PhpUnitAssertNewNamesFixerTest.php>`_
+
+The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.

+ 4 - 0
doc/rules/php_unit/php_unit_dedicate_assert.rst

@@ -133,6 +133,10 @@ The rule is part of the following rule sets:
 
   ``['target' => '5.6']``
 
+- `@PHPUnit91Migration:risky <./../../ruleSets/PHPUnit91MigrationRisky.rst>`_ with config:
+
+  ``['target' => '5.6']``
+
 - `@PHPUnit100Migration:risky <./../../ruleSets/PHPUnit100MigrationRisky.rst>`_ with config:
 
   ``['target' => '5.6']``

+ 4 - 0
doc/rules/php_unit/php_unit_dedicate_assert_internal_type.rst

@@ -84,6 +84,10 @@ The rule is part of the following rule sets:
 
   ``['target' => '7.5']``
 
+- `@PHPUnit91Migration:risky <./../../ruleSets/PHPUnit91MigrationRisky.rst>`_ with config:
+
+  ``['target' => '7.5']``
+
 - `@PHPUnit100Migration:risky <./../../ruleSets/PHPUnit100MigrationRisky.rst>`_ with config:
 
   ``['target' => '7.5']``

+ 4 - 0
doc/rules/php_unit/php_unit_expectation.rst

@@ -185,6 +185,10 @@ The rule is part of the following rule sets:
 
   ``['target' => '8.4']``
 
+- `@PHPUnit91Migration:risky <./../../ruleSets/PHPUnit91MigrationRisky.rst>`_ with config:
+
+  ``['target' => '8.4']``
+
 - `@PHPUnit100Migration:risky <./../../ruleSets/PHPUnit100MigrationRisky.rst>`_ with config:
 
   ``['target' => '8.4']``

+ 4 - 0
doc/rules/php_unit/php_unit_mock.rst

@@ -106,6 +106,10 @@ The rule is part of the following rule sets:
 
   ``['target' => '5.5']``
 
+- `@PHPUnit91Migration:risky <./../../ruleSets/PHPUnit91MigrationRisky.rst>`_ with config:
+
+  ``['target' => '5.5']``
+
 - `@PHPUnit100Migration:risky <./../../ruleSets/PHPUnit100MigrationRisky.rst>`_ with config:
 
   ``['target' => '5.5']``

+ 4 - 0
doc/rules/php_unit/php_unit_namespaced.rst

@@ -126,6 +126,10 @@ The rule is part of the following rule sets:
 
   ``['target' => '6.0']``
 
+- `@PHPUnit91Migration:risky <./../../ruleSets/PHPUnit91MigrationRisky.rst>`_ with config:
+
+  ``['target' => '6.0']``
+
 - `@PHPUnit100Migration:risky <./../../ruleSets/PHPUnit100MigrationRisky.rst>`_ with config:
 
   ``['target' => '6.0']``

Some files were not shown because too many files changed in this diff