-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: authorize adding custom rules, no override of standard ones
- Loading branch information
1 parent
72708c4
commit f64f227
Showing
7 changed files
with
108 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,4 @@ | ||
vendor/ | ||
composer.lock | ||
*.phar | ||
.phpunit.result.cache |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/8.0/phpunit.xsd" | ||
bootstrap="vendor/autoload.php" | ||
executionOrder="depends,defects" | ||
forceCoversAnnotation="true" | ||
beStrictAboutCoversAnnotation="true" | ||
beStrictAboutOutputDuringTests="true" | ||
beStrictAboutTodoAnnotatedTests="true" | ||
verbose="true"> | ||
<testsuites> | ||
<testsuite name="default"> | ||
<directory suffix="Test.php">tests</directory> | ||
</testsuite> | ||
</testsuites> | ||
|
||
<filter> | ||
<whitelist processUncoveredFilesFromWhitelist="true"> | ||
<directory suffix=".php">src</directory> | ||
</whitelist> | ||
</filter> | ||
</phpunit> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
use M6Web\CS\Config\BedrockStreaming; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
class BedrockStreamingTest extends TestCase | ||
{ | ||
/** | ||
* @test | ||
* @covers M6Web\CS\Config\BedrockStreaming::getRules | ||
*/ | ||
public function RulesOrderShoulNotBeAltered() | ||
{ | ||
$extraRules = [ | ||
'braces' => [ | ||
'allow_single_line_closure' => false, | ||
], | ||
'dummy_rule' => 'dummy_value', | ||
'@Symfony' => false, | ||
]; | ||
$rules = (new BedrockStreaming($extraRules))->getRules(); | ||
|
||
self::assertEquals('array', gettype($rules)); | ||
|
||
// Make sure the new rule is added before the standard ones to prevent any regression | ||
$firstValue = reset($rules); | ||
$firstKey = key($rules); | ||
self::assertEquals('dummy_rule', $firstKey, 'The new rules should be added before standard ones'); | ||
self::assertEquals('dummy_value', $firstValue); | ||
|
||
// Make sure the first standard rule comes after the custom rules | ||
self::assertArrayHasKey('@Symfony', $rules, 'The @Symfony rule should not be deleted'); | ||
$nextValue = next($rules); | ||
$nextKey = key($rules); | ||
self::assertEquals('@Symfony', $nextKey, 'The first rule should always remain @Symfony'); | ||
self::assertTrue($nextValue, 'The standard root rules value should never change'); | ||
|
||
// Make sure a nested rule cannot be overriden | ||
self::assertArrayHasKey('braces', $rules); | ||
self::assertArrayHasKey('allow_single_line_closure', $rules['braces']); | ||
self::assertTrue($rules['braces']['allow_single_line_closure'], 'The standard nested rules should never change'); | ||
} | ||
} |