Skip to content

Commit 8384dcf

Browse files
committed
Configure PHPCS to check tests too
1 parent 27d2fec commit 8384dcf

20 files changed

+104
-51
lines changed

phpcs.xml.dist

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
<rule ref="PSR12"/>
1212

1313
<file>src/</file>
14+
<file>tests/</file>
1415

1516
<rule ref="Generic.PHP.ForbiddenFunctions">
1617
<properties>

tests/ConstantExtractorTest.php

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests;
46

@@ -45,15 +47,15 @@ public function testExtractSuccessful(string $pattern, array $expectedList): voi
4547
public function empty(): Generator
4648
{
4749
yield 'class without constant' => [
48-
ClassWithoutConstant::class.'::*',
50+
ClassWithoutConstant::class . '::*',
4951
'/Class .+ has no public constant/',
5052
];
5153
yield 'class without public constant' => [
52-
ClassWithNoPublicConstant::class.'::*',
54+
ClassWithNoPublicConstant::class . '::*',
5355
'/Class .+ has no public constant/',
5456
];
5557
yield 'class with constant but no match' => [
56-
ClassWithConstant::class.'::NO_MATCH*',
58+
ClassWithConstant::class . '::NO_MATCH*',
5759
'/Pattern matches no constant/',
5860
];
5961
}
@@ -74,42 +76,51 @@ public function malformed(): Generator
7476
$invalidPatternRegexp,
7577
];
7678
yield 'missing constant pattern' => [
77-
ClassWithConstant::class.'::',
79+
ClassWithConstant::class . '::',
7880
$invalidPatternRegexp,
7981
];
8082
yield 'two separator' => [
81-
ClassWithConstant::class.'::STATUS_*::',
83+
ClassWithConstant::class . '::STATUS_*::',
8284
$invalidPatternRegexp,
8385
];
8486
yield 'no * in pattern' => [
85-
ClassWithConstant::class.'::STATUS_ONLINE',
87+
ClassWithConstant::class . '::STATUS_ONLINE',
8688
$invalidPatternRegexp,
8789
];
8890
}
8991

9092
public function successful(): Generator
9193
{
9294
yield 'starting with status' => [
93-
ClassWithConstant::class.'::STATUS_*',
95+
ClassWithConstant::class . '::STATUS_*',
9496
[ClassWithConstant::STATUS_ONLINE, ClassWithConstant::STATUS_DRAFT],
9597
];
9698
yield 'ending with online' => [
97-
ClassWithConstant::class.'::*_ONLINE',
99+
ClassWithConstant::class . '::*_ONLINE',
98100
[ClassWithConstant::STATUS_ONLINE],
99101
];
100102
}
101103
}
102104

105+
/**
106+
* phpcs:disable
107+
*/
103108
class ClassWithoutConstant
104109
{
105110
}
106111

112+
/**
113+
* phpcs:disable
114+
*/
107115
class ClassWithNoPublicConstant
108116
{
109117
private const PROTECTED_CONST = 'protected';
110118
private const PRIVATE_CONST = 'private';
111119
}
112120

121+
/**
122+
* phpcs:disable
123+
*/
113124
class ClassWithConstant
114125
{
115126
public const STATUS_ONLINE = 'online';

tests/ConstantListEnumTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests;
46

@@ -19,7 +21,7 @@ public function getEnum(string $pattern, string $name): ConstantListEnum
1921

2022
public function testVehicleEnums(): void
2123
{
22-
$type = $this->getEnum(Vehicle::class.'::TYPE_*', 'vehicle.type');
24+
$type = $this->getEnum(Vehicle::class . '::TYPE_*', 'vehicle.type');
2325
self::assertSame('vehicle.type', $type->getName());
2426
self::assertSame(
2527
['bike' => 'bike', 'car' => 'car', 'bus' => 'bus'],
@@ -29,7 +31,7 @@ public function testVehicleEnums(): void
2931
self::assertSame('bike', $type->getLabel('bike'));
3032
self::assertSame('bus', $type->getLabel('bus'));
3133

32-
$engine = $this->getEnum(Vehicle::class.'::ENGINE_*', 'vehicle.engine');
34+
$engine = $this->getEnum(Vehicle::class . '::ENGINE_*', 'vehicle.engine');
3335
self::assertSame('vehicle.engine', $engine->getName());
3436
self::assertSame(
3537
['electic' => 'electic', 'combustion' => 'combustion'],
@@ -39,7 +41,7 @@ public function testVehicleEnums(): void
3941
self::assertSame('electic', $engine->getLabel('electic'));
4042
self::assertSame('combustion', $engine->getLabel('combustion'));
4143

42-
$brand = $this->getEnum(Vehicle::class.'::BRAND_*', 'vehicle.brand');
44+
$brand = $this->getEnum(Vehicle::class . '::BRAND_*', 'vehicle.brand');
4345
self::assertSame('vehicle.brand', $brand->getName());
4446
self::assertSame(
4547
['renault' => 'renault', 'volkswagen' => 'volkswagen', 'toyota' => 'toyota'],
@@ -54,7 +56,7 @@ public function testLabelNotFound(): void
5456
{
5557
$this->expectException(InvalidArgumentException::class);
5658

57-
$enum = $this->getEnum(Vehicle::class.'::TYPE_*', 'vehicle.type');
59+
$enum = $this->getEnum(Vehicle::class . '::TYPE_*', 'vehicle.type');
5860

5961
$enum->getLabel('unknown');
6062
}

tests/ConstantListTranslatedEnumTest.php

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests;
46

@@ -31,7 +33,7 @@ public function testVehicleEnums(): void
3133
'vehicle.brand.toyota' => 'Toyota',
3234
]);
3335

34-
$type = $this->getEnum(Vehicle::class.'::TYPE_*', 'vehicle.type', $translator);
36+
$type = $this->getEnum(Vehicle::class . '::TYPE_*', 'vehicle.type', $translator);
3537
self::assertSame('vehicle.type', $type->getName());
3638
self::assertSame(
3739
['Moto' => 'bike', 'Voiture' => 'car', 'Bus' => 'bus'],
@@ -41,7 +43,7 @@ public function testVehicleEnums(): void
4143
self::assertSame('Moto', $type->getLabel('bike'));
4244
self::assertSame('Bus', $type->getLabel('bus'));
4345

44-
$engine = $this->getEnum(Vehicle::class.'::ENGINE_*', 'vehicle.engine', $translator);
46+
$engine = $this->getEnum(Vehicle::class . '::ENGINE_*', 'vehicle.engine', $translator);
4547
self::assertSame('vehicle.engine', $engine->getName());
4648
self::assertSame(
4749
['Electrique' => 'electic', 'Combustion' => 'combustion'],
@@ -51,7 +53,7 @@ public function testVehicleEnums(): void
5153
self::assertSame('Electrique', $engine->getLabel('electic'));
5254
self::assertSame('Combustion', $engine->getLabel('combustion'));
5355

54-
$brand = $this->getEnum(Vehicle::class.'::BRAND_*', 'vehicle.brand', $translator);
56+
$brand = $this->getEnum(Vehicle::class . '::BRAND_*', 'vehicle.brand', $translator);
5557
self::assertSame('vehicle.brand', $brand->getName());
5658
self::assertSame(
5759
['Renault' => 'renault', 'Volkswagen' => 'volkswagen', 'Toyota' => 'toyota'],
@@ -72,7 +74,7 @@ public function testLabelNotFound(): void
7274
'vehicle.type.bus' => 'Bus',
7375
]);
7476

75-
$enum = $this->getEnum(Vehicle::class.'::TYPE_*', 'vehicle.type', $translator);
77+
$enum = $this->getEnum(Vehicle::class . '::TYPE_*', 'vehicle.type', $translator);
7678

7779
$enum->getLabel('unknown');
7880
}

tests/DependencyInjection/CompilerPass/TaggedEnumCollectorCompilerPassTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests\DependencyInjection\CompilerPass;
46

tests/DependencyInjection/EnumExtensionTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests\DependencyInjection;
46

tests/EnumRegistryTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests;
46

tests/EnumTest.php

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests;
46

@@ -54,7 +56,8 @@ public function testEnumMustHaveChoices(): void
5456
public function testInheritedEnumMustHaveChoicesOrBuildMethod(): void
5557
{
5658
$this->expectException(LogicException::class);
57-
$fooEnum = new class ('foo', null) extends Enum {};
59+
$fooEnum = new class ('foo', null) extends Enum {
60+
};
5861
$fooEnum->getLabel('something');
5962
}
6063
}

tests/Fixtures/GenderEnum.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests\Fixtures;
46

tests/Fixtures/StateEnum.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
<?php declare(strict_types=1);
1+
<?php
2+
3+
declare(strict_types=1);
24

35
namespace Yokai\EnumBundle\Tests\Fixtures;
46

0 commit comments

Comments
 (0)