Skip to content

Commit 170bf5e

Browse files
committed
Fix tests
1 parent 171db40 commit 170bf5e

11 files changed

Lines changed: 52 additions & 45 deletions

.github/workflows/audit.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,12 @@ jobs:
1414
- name: Checkout (Push)
1515
uses: actions/checkout@v4
1616
if: github.event_name == 'push'
17-
with:
18-
fetch-depth: 0
1917

2018
- name: Checkout (PR)
2119
uses: actions/checkout@v4
2220
if: github.event_name == 'pull_request'
2321
with:
2422
ref: ${{ github.event.pull_request.head.ref }}
25-
fetch-depth: 0
2623

2724
- name: Setup PHP
2825
uses: shivammathur/setup-php@v2

.php-cs-fixer.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,9 @@
3131
],
3232
'comment_to_phpdoc' => [
3333
'ignored_tags' => [
34+
'codeCoverageIgnoreStart',
35+
'codeCoverageIgnoreEnd',
36+
'codeCoverageIgnore',
3437
'phan-suppress-current-line',
3538
'phan-suppress-next-line',
3639
'see',

composer.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"symfony/http-kernel": "^7"
2525
},
2626
"require-dev": {
27+
"phpunit/phpunit": "^11.5",
2728
"roave/security-advisories": "dev-latest",
2829
"symfony/phpunit-bridge": "^7"
2930
},

phpstan.neon

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ parameters:
33
paths:
44
- src
55
- tests
6-
bootstrapFiles:
7-
- vendor/bin/.phpunit/phpunit/vendor/autoload.php
86

97
ignoreErrors:
108
-

phpunit.xml.dist

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,33 +1,40 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
32
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
4-
xsi:noNamespaceSchemaLocation="vendor/bin/.phpunit/phpunit.xsd"
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
54
colors="true"
65
bootstrap="vendor/autoload.php"
7-
>
6+
cacheDirectory=".phpunit.cache"
7+
requireCoverageMetadata="true"
8+
beStrictAboutCoverageMetadata="true"
9+
beStrictAboutOutputDuringTests="true"
10+
displayDetailsOnPhpunitDeprecations="true"
11+
failOnPhpunitDeprecation="true"
12+
failOnRisky="true"
13+
failOnWarning="true"
14+
>
815

916
<php>
1017
<ini name="error_reporting" value="-1" />
11-
<server name="SYMFONY_PHPUNIT_VERSION" value="9.5" />
12-
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[indirect]=1" />
18+
<server name="SYMFONY_PHPUNIT_VERSION" value="11.5" />
19+
<env name="SYMFONY_DEPRECATIONS_HELPER" value="max[total]=13&amp;max[indirect]=6" />
1320
</php>
1421

1522
<testsuites>
1623
<testsuite name="NbgroupEnvBundle Test Suite">
17-
<directory>./tests/</directory>
24+
<directory>tests</directory>
1825
</testsuite>
1926
</testsuites>
2027

21-
<coverage cacheDirectory=".phpunit.cache/code-coverage"
22-
processUncoveredFiles="true"
28+
<source ignoreIndirectDeprecations="true"
29+
restrictNotices="true"
30+
restrictWarnings="true"
2331
>
2432
<include>
25-
<directory suffix=".php">src</directory>
33+
<directory>src</directory>
2634
</include>
27-
<exclude>
28-
<file>src/CsvEnvVarProcessor.php</file>
29-
<file>src/NbgroupEnvBundle.php</file>
30-
</exclude>
35+
</source>
36+
37+
<coverage>
3138
<report>
3239
<clover outputFile="clover.xml" />
3340
</report>

psalm.xml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@
1717
</projectFiles>
1818

1919
<issueHandlers>
20-
<UndefinedClass>
20+
<!-- PHPUnit -->
21+
<PropertyNotSetInConstructor>
2122
<errorLevel type="suppress">
2223
<directory name="tests" />
23-
<file name=".php-cs-fixer.php" />
2424
</errorLevel>
25-
</UndefinedClass>
25+
</PropertyNotSetInConstructor>
2626
</issueHandlers>
2727

2828
<plugins>

src/CsvEnvVarProcessor.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,11 @@
99
use Symfony\Component\DependencyInjection\Exception\BadMethodCallException;
1010
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1111

12+
// @codeCoverageIgnoreStart
1213
if (class_exists(CsvEnvVarProcessor::class, false)) {
1314
return;
1415
}
16+
// @codeCoverageIgnoreEnd
1517

1618
final class CsvEnvVarProcessor implements EnvVarProcessorInterface
1719
{

tests/ArrayCastEnvVarProcessorTest.php

Lines changed: 6 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,18 @@
66
namespace Nbgrp\Tests\EnvBundle;
77

88
use Nbgrp\EnvBundle\ArrayCastEnvVarProcessor;
9+
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\DataProvider;
911
use PHPUnit\Framework\TestCase;
1012
use Symfony\Component\DependencyInjection\Exception\RuntimeException;
1113

1214
/**
13-
* @covers \Nbgrp\EnvBundle\ArrayCastEnvVarProcessor
14-
*
1515
* @internal
1616
*/
17+
#[CoversClass(ArrayCastEnvVarProcessor::class)]
1718
final class ArrayCastEnvVarProcessorTest extends TestCase
1819
{
19-
/**
20-
* @dataProvider provideSuccessCases
21-
*/
20+
#[DataProvider('provideSuccessCases')]
2221
public function testSuccess(string $prefix, array $envValue, array $expected): void
2322
{
2423
$processor = new ArrayCastEnvVarProcessor();
@@ -74,9 +73,7 @@ public static function provideSuccessCases(): iterable
7473
];
7574
}
7675

77-
/**
78-
* @dataProvider provideInvalidNumericCases
79-
*/
76+
#[DataProvider('provideInvalidNumericCases')]
8077
public function testInvalidNumeric(string $prefix, array $envValue, string $expectedMessageFormat): void
8178
{
8279
$processor = new ArrayCastEnvVarProcessor();
@@ -105,9 +102,7 @@ public static function provideInvalidNumericCases(): iterable
105102
];
106103
}
107104

108-
/**
109-
* @dataProvider provideInvalidBase64Cases
110-
*/
105+
#[DataProvider('provideInvalidBase64Cases')]
111106
public function testInvalidBase64(string $prefix, array $envValue, string $expectedMessageFormat): void
112107
{
113108
$processor = new ArrayCastEnvVarProcessor();

tests/DependencyInjection/ConfigurationTest.php

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,28 +6,28 @@
66
namespace Nbgrp\Tests\EnvBundle\DependencyInjection;
77

88
use Nbgrp\EnvBundle\DependencyInjection\Configuration;
9+
use PHPUnit\Framework\Attributes\CoversClass;
10+
use PHPUnit\Framework\Attributes\DataProvider;
911
use PHPUnit\Framework\TestCase;
1012
use Symfony\Component\Config\Definition\Exception\InvalidConfigurationException;
1113
use Symfony\Component\Config\Definition\Processor;
1214

1315
/**
14-
* @covers \Nbgrp\EnvBundle\DependencyInjection\Configuration
15-
*
1616
* @internal
1717
*/
18+
#[CoversClass(Configuration::class)]
1819
final class ConfigurationTest extends TestCase
1920
{
2021
/** @var Processor */
2122
private $processor;
2223

24+
#[\Override]
2325
protected function setUp(): void
2426
{
2527
$this->processor = new Processor();
2628
}
2729

28-
/**
29-
* @dataProvider provideValidConfigCases
30-
*/
30+
#[DataProvider('provideValidConfigCases')]
3131
public function testValidConfig(array $config, array $expected, string $description): void
3232
{
3333
self::assertSame($expected, $this->processor->processConfiguration(new Configuration(), [$config]), $description);
@@ -109,9 +109,7 @@ public static function provideValidConfigCases(): iterable
109109
];
110110
}
111111

112-
/**
113-
* @dataProvider provideInvalidConfigCases
114-
*/
112+
#[DataProvider('provideInvalidConfigCases')]
115113
public function testInvalidConfig(array $config, string $expectedMessage): void
116114
{
117115
$this->expectException(InvalidConfigurationException::class);

tests/DependencyInjection/NbgroupEnvExtensionTest.php

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,15 +5,19 @@
55

66
namespace Nbgrp\Tests\EnvBundle\DependencyInjection;
77

8+
use Nbgrp\EnvBundle\ArrayCastEnvVarProcessor;
9+
use Nbgrp\EnvBundle\DependencyInjection\Configuration;
810
use Nbgrp\EnvBundle\DependencyInjection\NbgroupEnvExtension;
11+
use PHPUnit\Framework\Attributes\CoversClass;
912
use PHPUnit\Framework\TestCase;
1013
use Symfony\Component\DependencyInjection\ContainerBuilder;
1114

1215
/**
13-
* @covers \Nbgrp\EnvBundle\DependencyInjection\NbgroupEnvExtension
14-
*
1516
* @internal
1617
*/
18+
#[CoversClass(NbgroupEnvExtension::class)]
19+
#[CoversClass(ArrayCastEnvVarProcessor::class)]
20+
#[CoversClass(Configuration::class)]
1721
final class NbgroupEnvExtensionTest extends TestCase
1822
{
1923
public function testComplexUsage(): void

0 commit comments

Comments
 (0)