Fork me on GitHub
a Sensio Labs Product

I ate three cookies πŸͺ (v3.40.2) edition

Rule php_unit_set_up_tear_down_visibilityΒΆ

Changes the visibility of the setUp() and tearDown() functions of PHPUnit to protected, to match the PHPUnit TestCase.

WarningΒΆ

Using this rule is riskyΒΆ

This fixer may change functions named setUp() or tearDown() outside of PHPUnit tests, when a class is wrongly seen as a PHPUnit test.

ExamplesΒΆ

Example #1ΒΆ

--- Original
+++ New
 <?php
 final class MyTest extends \PHPUnit_Framework_TestCase
 {
     private $hello;
-    public function setUp()
+    protected function setUp()
     {
         $this->hello = "hello";
     }

-    public function tearDown()
+    protected function tearDown()
     {
         $this->hello = null;
     }
 }

Rule setsΒΆ

The rule is part of the following rule sets:

Source classΒΆ

PhpCsFixer\Fixer\PhpUnit\PhpUnitSetUpTearDownVisibilityFixer