Skip to content

Commit

Permalink
Issue #25: enable ordered_imports.case_sensitive by default since Dru…
Browse files Browse the repository at this point in the history
…pal Coder (8.3.25) is now enforcing it (#29)

* Issue #25: ordered_importS is case sensitive since Coder 8.3.25.

* Issue #25: Fix review feedbacks.

* fix tests following changes

* add coverage of ordered_imports.case_sensitive

* enable ordered_imports.case_sensitive by default since Drupal Coder (8.3.25) is now enforcing it

---------

Co-authored-by: Florent Torregrosa <[email protected]>
  • Loading branch information
WengerK and FlorentTorregrosa authored Oct 1, 2024
1 parent 78fed0a commit ff36e84
Show file tree
Hide file tree
Showing 7 changed files with 84 additions and 0 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
### Added
- add running tests on PHP 8.3
- add rule declare_equal_normalize to support declare(strict_types=1) without spaces around equal for Drupal8
- enable ordered_imports.case_sensitive by default since Drupal Coder (8.3.25) is now enforcing it

## [2.1.0] - 2023-10-23
### Added
Expand Down
7 changes: 7 additions & 0 deletions config/drupal/phpcsfixer.rules.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,13 @@ parameters:
allow_mixed: true
allow_unused_params: true
remove_inheritdoc: false
ordered_imports:
case_sensitive: true
imports_order:
- class
- function
- const
sort_algorithm: alpha
phpdoc_add_missing_param_annotation: false
single_line_comment_style: true
single_quote:
Expand Down
42 changes: 42 additions & 0 deletions tests/Integration/Scenario7Test.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace drupol\PhpCsFixerConfigsDrupal\Tests\Integration;

use drupol\PhpCsFixerConfigsDrupal\Config\Drupal8;
use drupol\PhpCsFixerConfigsDrupal\Tests\IntegrationTestCase;
use PhpCsFixer\FixerFactory;
use PhpCsFixer\RuleSet\RuleSet;

/**
* @author Kevin Wenger <[email protected]>
*
* Covers the PHP-CS-Fixer rules ordered_imports.case_sensitive
*
* @internal
*/
final class Scenario7Test extends IntegrationTestCase
{
protected function getScenarioPath(): string
{
return __DIR__ . '/fixtures/scenario7';
}

public function testDrupal8Config(): void
{
$drupal8 = new Drupal8();
$rules = $drupal8->getRules();
$ruleset = new RuleSet($rules);

$factory = (new FixerFactory())
->registerBuiltInFixers()
->registerCustomFixers($drupal8->getCustomFixers())
->useRuleSet($ruleset);

$fixers = [];
foreach ($factory->getFixers() as $fixer) {
$fixers[$fixer->getName()] = $fixer;
}

$this->doTest($fixers);
}
}
16 changes: 16 additions & 0 deletions tests/Integration/fixtures/scenario7/bad.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use foo\Bar;
use Foo\Bar;

namespace foo;

class Bar {

}

namespace Foo;

class Bar {

}
16 changes: 16 additions & 0 deletions tests/Integration/fixtures/scenario7/good.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?php

use Foo\Bar;
use foo\Bar;

namespace foo;

class Bar {

}

namespace Foo;

class Bar {

}
1 change: 1 addition & 0 deletions tests/Unit/Config/Drupal7Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public function testConfigDefault(): void
'sort_algorithm' => 'alpha',
],
'ordered_imports' => [
'case_sensitive' => true,
'imports_order' => [
0 => 'class',
1 => 'function',
Expand Down
1 change: 1 addition & 0 deletions tests/Unit/Config/Drupal8Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -316,6 +316,7 @@ public function testConfigDefault(): void
'sort_algorithm' => 'alpha',
],
'ordered_imports' => [
'case_sensitive' => true,
'imports_order' => [
0 => 'class',
1 => 'function',
Expand Down

0 comments on commit ff36e84

Please sign in to comment.