Fork me on GitHub
a Sensio Labs Product

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

Rule php_unit_test_annotationΒΆ

Adds or removes @test annotations from tests, following configuration.

WarningΒΆ

Using this rule is riskyΒΆ

This fixer may change the name of your tests, and could cause incompatibility with abstract classes or interfaces.

ConfigurationΒΆ

styleΒΆ

Whether to use the @test annotation or not.

Allowed values: 'annotation' and 'prefix'

Default value: 'prefix'

ExamplesΒΆ

Example #1ΒΆ

Default configuration.

--- Original
+++ New
 <?php
 class Test extends \PhpUnit\FrameWork\TestCase
 {
     /**
-     * @test
+     *
      */
-    public function itDoesSomething() {} }
+    public function testItDoesSomething() {} }

Example #2ΒΆ

With configuration: ['style' => 'annotation'].

--- Original
+++ New
 <?php
 class Test extends \PhpUnit\FrameWork\TestCase
 {
-public function testItDoesSomething() {}}
+/**
+ * @test
+ */
+public function itDoesSomething() {}}

Rule setsΒΆ

The rule is part of the following rule sets:

Source classΒΆ

PhpCsFixer\Fixer\PhpUnit\PhpUnitTestAnnotationFixer