Browse Source

PhpUnitDedicateAssertFixer must run before NoUnusedImportsFixer

Kuba Werłos 3 years ago
parent
commit
14d5458def

+ 1 - 1
dev-tools/install.sh

@@ -20,7 +20,7 @@ cd "$(dirname "$0")"
 
 mkdir -p bin
 
-VERSION_CB="2.21.3"
+VERSION_CB="2.21.4"
 VERSION_SC="stable"
 
 echo λλλ checkbashisms

+ 1 - 1
src/Fixer/Import/NoUnusedImportsFixer.php

@@ -49,7 +49,7 @@ final class NoUnusedImportsFixer extends AbstractFixer
      * {@inheritdoc}
      *
      * Must run before BlankLineAfterNamespaceFixer, NoExtraBlankLinesFixer, NoLeadingImportSlashFixer, SingleLineAfterImportsFixer.
-     * Must run after ClassKeywordRemoveFixer, GlobalNamespaceImportFixer, PhpUnitFqcnAnnotationFixer, SingleImportPerStatementFixer.
+     * Must run after ClassKeywordRemoveFixer, GlobalNamespaceImportFixer, PhpUnitDedicateAssertFixer, PhpUnitFqcnAnnotationFixer, SingleImportPerStatementFixer.
      */
     public function getPriority(): int
     {

+ 1 - 1
src/Fixer/PhpUnit/PhpUnitConstructFixer.php

@@ -96,7 +96,7 @@ final class FooTest extends \PHPUnit_Framework_TestCase {
      */
     public function getPriority(): int
     {
-        return -10;
+        return -8;
     }
 
     /**

+ 2 - 2
src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php

@@ -225,12 +225,12 @@ final class MyTest extends \PHPUnit_Framework_TestCase
     /**
      * {@inheritdoc}
      *
-     * Must run before PhpUnitDedicateAssertInternalTypeFixer.
+     * Must run before NoUnusedImportsFixer, PhpUnitDedicateAssertInternalTypeFixer.
      * Must run after ModernizeStrposFixer, NoAliasFunctionsFixer, PhpUnitConstructFixer.
      */
     public function getPriority(): int
     {
-        return -15;
+        return -9;
     }
 
     /**

+ 1 - 0
tests/AutoReview/FixerFactoryTest.php

@@ -224,6 +224,7 @@ final class FixerFactoryTest extends TestCase
             [$fixers['ordered_class_elements'], $fixers['no_blank_lines_after_class_opening']],
             [$fixers['ordered_class_elements'], $fixers['space_after_semicolon']],
             [$fixers['php_unit_construct'], $fixers['php_unit_dedicate_assert']],
+            [$fixers['php_unit_dedicate_assert'], $fixers['no_unused_imports']],
             [$fixers['php_unit_dedicate_assert'], $fixers['php_unit_dedicate_assert_internal_type']],
             [$fixers['php_unit_fqcn_annotation'], $fixers['no_unused_imports']],
             [$fixers['php_unit_fqcn_annotation'], $fixers['phpdoc_order_by_value']],

+ 22 - 0
tests/Fixtures/Integration/priority/php_unit_dedicate_assert,no_unused_imports.test

@@ -0,0 +1,22 @@
+--TEST--
+Integration of fixers: php_unit_dedicate_assert,no_unused_imports.
+--RULESET--
+{"php_unit_dedicate_assert": true, "no_unused_imports": true}
+--EXPECT--
+<?php
+class FooTest extends \PHPUnit\Framework\TestCase {
+    public function testMe()
+    {
+        self::assertCount(10, $collection);
+    }
+}
+
+--INPUT--
+<?php
+use function count;
+class FooTest extends \PHPUnit\Framework\TestCase {
+    public function testMe()
+    {
+        self::assertSame(10, count($collection));
+    }
+}