Skip to content

Commit a25c340

Browse files
committed
Enable strict coverage reporting
1 parent 7443ee9 commit a25c340

12 files changed

+79
-60
lines changed

composer.json

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@
3030
"phpstan/phpstan-strict-rules": "^2.0",
3131
"phpunit/phpunit": "^10.5 || ^11.5",
3232
"slevomat/coding-standard": "^8.16",
33-
"symfony/var-exporter": "^6.4 || ^7.0"
33+
"symfony/var-exporter": "^6.4 || ^7.0",
34+
"webmozart/assert": "^1.12"
3435
},
3536
"autoload": {
3637
"psr-4": {
@@ -39,7 +40,8 @@
3940
},
4041
"autoload-dev": {
4142
"psr-4": {
42-
"Axlon\\PostalCodeValidation\\Tests\\": "tests/"
43+
"Axlon\\PostalCodeValidation\\": "build/",
44+
"Tests\\": "tests/"
4345
}
4446
},
4547
"config": {

phpcs.xml.dist

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,14 @@
9898
</rule>
9999
<rule ref="SlevomatCodingStandard.ControlStructures.UselessTernaryOperator"/>
100100
<rule ref="SlevomatCodingStandard.Exceptions.RequireNonCapturingCatch"/>
101+
<rule ref="SlevomatCodingStandard.Files.TypeNameMatchesFileName">
102+
<properties>
103+
<property name="rootNamespaces" type="array">
104+
<element key="src" value="Axlon\PostalCodeValidation" />
105+
<element key="tests" value="Tests" />
106+
</property>
107+
</properties>
108+
</rule>
101109
<rule ref="SlevomatCodingStandard.Functions.ArrowFunctionDeclaration">
102110
<properties>
103111
<property name="spacesCountAfterKeyword" value="1"/>

phpunit.xml.dist

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,26 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
3-
backupGlobals="false"
4-
bootstrap="./vendor/autoload.php"
5-
colors="true"
6-
processIsolation="false"
7-
stopOnFailure="false"
8-
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd" cacheDirectory=".phpunit.cache"
9-
backupStaticProperties="false">
10-
<coverage/>
3+
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
4+
bootstrap="vendor/autoload.php"
5+
cacheDirectory=".phpunit.cache"
6+
executionOrder="depends,defects"
7+
shortenArraysForExportThreshold="10"
8+
requireCoverageMetadata="true"
9+
beStrictAboutCoverageMetadata="true"
10+
beStrictAboutOutputDuringTests="true"
11+
displayDetailsOnPhpunitDeprecations="true"
12+
failOnPhpunitDeprecation="true"
13+
failOnRisky="true"
14+
failOnWarning="true">
1115
<testsuites>
12-
<testsuite name="Integration">
13-
<directory suffix="Test.php">./tests/Integration</directory>
14-
</testsuite>
15-
<testsuite name="Unit">
16-
<directory suffix="Test.php">./tests/Unit</directory>
16+
<testsuite name="Tests">
17+
<directory>tests</directory>
1718
</testsuite>
1819
</testsuites>
19-
<source>
20+
21+
<source ignoreIndirectDeprecations="true" restrictNotices="true" restrictWarnings="true">
2022
<include>
21-
<directory suffix=".php">./src</directory>
23+
<directory>src</directory>
2224
</include>
2325
</source>
2426
</phpunit>

tests/Integration/PostalCodeForTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Axlon\PostalCodeValidation\Tests\Integration;
5+
namespace Tests\Integration;
66

77
use Illuminate\Support\Facades\Validator;
88
use InvalidArgumentException;
9+
use PHPUnit\Framework\Attributes\CoversNothing;
910

11+
#[CoversNothing]
1012
final class PostalCodeForTest extends TestCase
1113
{
1214
/**

tests/Integration/PostalCodeTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Axlon\PostalCodeValidation\Tests\Integration;
5+
namespace Tests\Integration;
66

77
use Illuminate\Support\Facades\Validator;
88
use InvalidArgumentException;
9+
use PHPUnit\Framework\Attributes\CoversNothing;
910

11+
#[CoversNothing]
1012
final class PostalCodeTest extends TestCase
1113
{
1214
/**

tests/Integration/PostalCodeWithTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Axlon\PostalCodeValidation\Tests\Integration;
5+
namespace Tests\Integration;
66

77
use Illuminate\Support\Facades\Validator;
88
use InvalidArgumentException;
9+
use PHPUnit\Framework\Attributes\CoversNothing;
910

11+
#[CoversNothing]
1012
final class PostalCodeWithTest extends TestCase
1113
{
1214
/**

tests/Integration/ReplacerTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Axlon\PostalCodeValidation\Tests\Integration;
5+
namespace Tests\Integration;
66

77
use Illuminate\Support\Facades\Lang;
88
use Illuminate\Support\Facades\Validator;
9+
use PHPUnit\Framework\Attributes\CoversNothing;
910

11+
#[CoversNothing]
1012
final class ReplacerTest extends TestCase
1113
{
1214
/**

tests/Integration/TestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
declare(strict_types=1);
44

5-
namespace Axlon\PostalCodeValidation\Tests\Integration;
5+
namespace Tests\Integration;
66

77
use Axlon\PostalCodeValidation\ValidationServiceProvider;
88
use Orchestra\Testbench\TestCase as BaseTestCase;
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Tests\Unit;
6+
7+
use Generator;
8+
use Webmozart\Assert\Assert;
9+
10+
final class PostalCodeDataProvider
11+
{
12+
public static function examplesByCountry(): Generator
13+
{
14+
$data = require __DIR__ . '/../../resources/examples.php';
15+
Assert::isArray($data);
16+
17+
foreach ($data as $countryCode => $example) {
18+
yield $countryCode => [$countryCode, $example];
19+
}
20+
21+
/** @link https://github.com/axlon/laravel-postal-code-validation/issues/35 */
22+
yield 'IC' => ['IC', '38580'];
23+
}
24+
}

tests/Unit/PostalCodeExamplesTest.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace Axlon\PostalCodeValidation\Tests\Unit;
5+
namespace Tests\Unit;
66

77
use Axlon\PostalCodeValidation\Support\PostalCodeExamples;
8+
use PHPUnit\Framework\Attributes\CoversClass;
89
use PHPUnit\Framework\TestCase;
910

11+
#[CoversClass(PostalCodeExamples::class)]
1012
final class PostalCodeExamplesTest extends TestCase
1113
{
1214
/**

0 commit comments

Comments
 (0)