Skip to content

Commit

Permalink
bug #6082 PhpUnitDedicateAssertFixer must run before NoUnusedImportsF…
Browse files Browse the repository at this point in the history
…ixer (kubawerlos)

This PR was merged into the master branch.

Discussion
----------

PhpUnitDedicateAssertFixer must run before NoUnusedImportsFixer

Commits
-------

14d5458 PhpUnitDedicateAssertFixer must run before NoUnusedImportsFixer
  • Loading branch information
SpacePossum committed Oct 27, 2021
2 parents 7f6aff4 + 14d5458 commit 9473b38
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/Fixer/Import/NoUnusedImportsFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public function getDefinition(): FixerDefinitionInterface
* {@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
{
Expand Down
2 changes: 1 addition & 1 deletion src/Fixer/PhpUnit/PhpUnitConstructFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public function testSomething() {
*/
public function getPriority(): int
{
return -10;
return -8;
}

/**
Expand Down
4 changes: 2 additions & 2 deletions src/Fixer/PhpUnit/PhpUnitDedicateAssertFixer.php
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,12 @@ public function testSomeTest()
/**
* {@inheritdoc}
*
* Must run before PhpUnitDedicateAssertInternalTypeFixer.
* Must run before NoUnusedImportsFixer, PhpUnitDedicateAssertInternalTypeFixer.
* Must run after ModernizeStrposFixer, NoAliasFunctionsFixer, PhpUnitConstructFixer.
*/
public function getPriority(): int
{
return -15;
return -9;
}

/**
Expand Down
1 change: 1 addition & 0 deletions tests/AutoReview/FixerFactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,7 @@ public function provideFixersPriorityCases(): array
[$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']],
Expand Down
Original file line number Diff line number Diff line change
@@ -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));
}
}

0 comments on commit 9473b38

Please sign in to comment.