php_unit_assert_new_names.rst 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. ==================================
  2. Rule ``php_unit_assert_new_names``
  3. ==================================
  4. Rename deprecated PHPUnit assertions like ``assertFileNotExists`` to new methods
  5. like ``assertFileDoesNotExist``.
  6. Warning
  7. -------
  8. Using this rule is risky
  9. ~~~~~~~~~~~~~~~~~~~~~~~~
  10. Fixer could be risky if one is overriding PHPUnit's native methods.
  11. Examples
  12. --------
  13. Example #1
  14. ~~~~~~~~~~
  15. .. code-block:: diff
  16. --- Original
  17. +++ New
  18. <?php
  19. final class MyTest extends \PHPUnit_Framework_TestCase
  20. {
  21. public function testSomeTest()
  22. {
  23. - $this->assertFileNotExists("test.php");
  24. - $this->assertNotIsWritable("path.php");
  25. + $this->assertFileDoesNotExist("test.php");
  26. + $this->assertIsNotWritable("path.php");
  27. }
  28. }
  29. Rule sets
  30. ---------
  31. The rule is part of the following rule sets:
  32. - `@PHPUnit91Migration:risky <./../../ruleSets/PHPUnit91MigrationRisky.rst>`_
  33. - `@PHPUnit100Migration:risky <./../../ruleSets/PHPUnit100MigrationRisky.rst>`_
  34. References
  35. ----------
  36. - Fixer class: `PhpCsFixer\\Fixer\\PhpUnit\\PhpUnitAssertNewNamesFixer <./../../../src/Fixer/PhpUnit/PhpUnitAssertNewNamesFixer.php>`_
  37. - Test class: `PhpCsFixer\\Tests\\Fixer\\PhpUnit\\PhpUnitAssertNewNamesFixerTest <./../../../tests/Fixer/PhpUnit/PhpUnitAssertNewNamesFixerTest.php>`_
  38. The test class defines officially supported behaviour. Each test case is a part of our backward compatibility promise.