Skip to content

Commit

Permalink
Bump to phpunit v10.5
Browse files Browse the repository at this point in the history
  • Loading branch information
paulbalandan committed Dec 29, 2023
1 parent a06034d commit b44fc33
Show file tree
Hide file tree
Showing 11 changed files with 77 additions and 74 deletions.
4 changes: 2 additions & 2 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,12 @@
"friendsofphp/php-cs-fixer": "^3.43"
},
"require-dev": {
"nexusphp/tachycardia": "^1.4",
"nexusphp/tachycardia": "^2.1",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan": "^1.10",
"phpstan/phpstan-phpunit": "^1.3",
"phpstan/phpstan-strict-rules": "^1.5",
"phpunit/phpunit": "^9.6"
"phpunit/phpunit": "^10.5"
},
"conflict": {
"liaison/cs-config": "*"
Expand Down
5 changes: 0 additions & 5 deletions phpstan-baseline.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
'count' => 1,
'path' => __DIR__ . '/src/Test/AbstractCustomFixerTestCase.php',
];
$ignoreErrors[] = [
'message' => '#^Cannot access offset \'header\' on array\\<string, mixed\\>\\|bool\\.$#',
'count' => 1,
'path' => __DIR__ . '/tests/FactoryTest.php',
];
$ignoreErrors[] = [
'message' => '#^Method Nexus\\\\CsConfig\\\\Tests\\\\Fixer\\\\Comment\\\\NoCodeSeparatorCommentFixerTest\\:\\:provideFixCases\\(\\) return type has no value type specified in iterable type iterable\\.$#',
'count' => 1,
Expand Down
53 changes: 25 additions & 28 deletions phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -1,39 +1,36 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="vendor/phpunit/phpunit/phpunit.xsd"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/10.5/phpunit.xsd"
bootstrap="vendor/autoload.php"
cacheResultFile="build/phpunit/test-results"
colors="true"
columns="max"
executionOrder="random"
beStrictAboutOutputDuringTests="true"
failOnRisky="true"
failOnWarning="true"
forceCoversAnnotation="true"
beStrictAboutOutputDuringTests="true"
beStrictAboutTodoAnnotatedTests="true"
verbose="true"
cacheDirectory="build/phpunit/cache"
columns="max"
requireCoverageMetadata="true"
>
<testsuites>
<testsuite name="NexusPHP CS Config Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<testsuites>
<testsuite name="NexusPHP CS Config Test Suite">
<directory suffix="Test.php">tests</directory>
</testsuite>
</testsuites>

<coverage cacheDirectory="build/phpunit/code-coverage"
ignoreDeprecatedCodeUnits="true"
processUncoveredFiles="true"
>
<include>
<directory suffix=".php">src</directory>
</include>
<source>
<include>
<directory suffix=".php">src</directory>
</include>
</source>

<report>
<clover outputFile="build/phpunit/logs/clover.xml"/>
<html outputDirectory="build/phpunit/logs/html"/>
</report>
</coverage>
<coverage ignoreDeprecatedCodeUnits="true">
<report>
<clover outputFile="build/phpunit/logs/clover.xml"/>
<html outputDirectory="build/phpunit/logs/html"/>
</report>
</coverage>

<extensions>
<extension class="Nexus\PHPUnit\Extension\Tachycardia" />
</extensions>
<extensions>
<bootstrap class="Nexus\PHPUnit\Tachycardia\TachycardiaExtension" />
</extensions>
</phpunit>
11 changes: 8 additions & 3 deletions tests/FactoryTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,14 @@
use Nexus\CsConfig\Ruleset\RulesetInterface;
use PhpCsFixer\Config;
use PhpCsFixer\Finder;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @internal
*
* @covers \Nexus\CsConfig\Factory
*/
#[CoversClass(Factory::class)]
final class FactoryTest extends TestCase
{
public function testFactoryThrowsExceptionOnIncompatibleVersionId(): void
Expand Down Expand Up @@ -115,8 +115,13 @@ public function testFactoryConsumesPassedOptionsToIt(): void
public function testCreateForLibraryCreatesPreformattedLicense(): void
{
$config = Factory::create($this->mockRuleset())->forLibrary('Library', 'Foo Bar', 'foo@bar.com', 2020);
$header = $config->getRules()['header_comment']['header'];

$rules = $config->getRules();
self::assertArrayHasKey('header_comment', $rules);
self::assertIsArray($rules['header_comment']);
self::assertArrayHasKey('header', $rules['header_comment']);

$header = $rules['header_comment']['header'];
self::assertIsString($header);
self::assertStringContainsString('This file is part of Library.', $header);
self::assertStringContainsString('(c) 2020 Foo Bar <foo@bar.com>', $header);
Expand Down
15 changes: 8 additions & 7 deletions tests/Fixer/Comment/NoCodeSeparatorCommentFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@

namespace Nexus\CsConfig\Tests\Fixer\Comment;

use Nexus\CsConfig\Fixer\AbstractCustomFixer;
use Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer;
use Nexus\CsConfig\Test\AbstractCustomFixerTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @internal
*
* @covers \Nexus\CsConfig\Fixer\AbstractCustomFixer
* @covers \Nexus\CsConfig\Fixer\Comment\NoCodeSeparatorCommentFixer
* @covers \Nexus\CsConfig\Test\AbstractCustomFixerTestCase
*/
#[CoversClass(AbstractCustomFixer::class)]
#[CoversClass(NoCodeSeparatorCommentFixer::class)]
#[CoversClass(AbstractCustomFixerTestCase::class)]
final class NoCodeSeparatorCommentFixerTest extends AbstractCustomFixerTestCase
{
/**
* @dataProvider provideFixCases
*/
#[DataProvider('provideFixCases')]
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
Expand Down
15 changes: 8 additions & 7 deletions tests/Fixer/Comment/SpaceAfterCommentStartFixerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,21 @@

namespace Nexus\CsConfig\Tests\Fixer\Comment;

use Nexus\CsConfig\Fixer\AbstractCustomFixer;
use Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer;
use Nexus\CsConfig\Test\AbstractCustomFixerTestCase;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;

/**
* @internal
*
* @covers \Nexus\CsConfig\Fixer\AbstractCustomFixer
* @covers \Nexus\CsConfig\Fixer\Comment\SpaceAfterCommentStartFixer
* @covers \Nexus\CsConfig\Test\AbstractCustomFixerTestCase
*/
#[CoversClass(AbstractCustomFixer::class)]
#[CoversClass(SpaceAfterCommentStartFixer::class)]
#[CoversClass(AbstractCustomFixerTestCase::class)]
final class SpaceAfterCommentStartFixerTest extends AbstractCustomFixerTestCase
{
/**
* @dataProvider provideFixCases
*/
#[DataProvider('provideFixCases')]
public function testFix(string $expected, ?string $input = null): void
{
$this->doTest($expected, $input);
Expand Down
9 changes: 4 additions & 5 deletions tests/FixerGeneratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,18 +14,17 @@
namespace Nexus\CsConfig\Tests;

use Nexus\CsConfig\FixerGenerator;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;

/**
* @internal
*
* @covers \Nexus\CsConfig\FixerGenerator
*/
#[CoversClass(FixerGenerator::class)]
final class FixerGeneratorTest extends TestCase
{
/**
* @dataProvider provideInvalidParametersThrowRuntimeExceptionCases
*/
#[DataProvider('provideInvalidParametersThrowRuntimeExceptionCases')]
public function testInvalidParametersThrowRuntimeException(string $path, string $vendor, string $message): void
{
$this->expectException(\RuntimeException::class);
Expand Down
10 changes: 6 additions & 4 deletions tests/Ruleset/Nexus80Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

namespace Nexus\CsConfig\Tests\Ruleset;

use Nexus\CsConfig\Ruleset\AbstractRuleset;
use Nexus\CsConfig\Ruleset\Nexus80;
use Nexus\CsConfig\Test\AbstractRulesetTestCase;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @internal
*
* @covers \Nexus\CsConfig\Ruleset\AbstractRuleset
* @covers \Nexus\CsConfig\Ruleset\Nexus80
* @covers \Nexus\CsConfig\Test\AbstractRulesetTestCase
*/
#[CoversClass(AbstractRuleset::class)]
#[CoversClass(Nexus80::class)]
#[CoversClass(AbstractRulesetTestCase::class)]
final class Nexus80Test extends AbstractRulesetTestCase {}
10 changes: 6 additions & 4 deletions tests/Ruleset/Nexus81Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

namespace Nexus\CsConfig\Tests\Ruleset;

use Nexus\CsConfig\Ruleset\AbstractRuleset;
use Nexus\CsConfig\Ruleset\Nexus81;
use Nexus\CsConfig\Test\AbstractRulesetTestCase;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @internal
*
* @covers \Nexus\CsConfig\Ruleset\AbstractRuleset
* @covers \Nexus\CsConfig\Ruleset\Nexus81
* @covers \Nexus\CsConfig\Test\AbstractRulesetTestCase
*/
#[CoversClass(AbstractRuleset::class)]
#[CoversClass(Nexus81::class)]
#[CoversClass(AbstractRulesetTestCase::class)]
final class Nexus81Test extends AbstractRulesetTestCase {}
10 changes: 6 additions & 4 deletions tests/Ruleset/Nexus82Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@

namespace Nexus\CsConfig\Tests\Ruleset;

use Nexus\CsConfig\Ruleset\AbstractRuleset;
use Nexus\CsConfig\Ruleset\Nexus82;
use Nexus\CsConfig\Test\AbstractRulesetTestCase;
use PHPUnit\Framework\Attributes\CoversClass;

/**
* @internal
*
* @covers \Nexus\CsConfig\Ruleset\AbstractRuleset
* @covers \Nexus\CsConfig\Ruleset\Nexus82
* @covers \Nexus\CsConfig\Test\AbstractRulesetTestCase
*/
#[CoversClass(AbstractRuleset::class)]
#[CoversClass(Nexus82::class)]
#[CoversClass(AbstractRulesetTestCase::class)]
final class Nexus82Test extends AbstractRulesetTestCase {}
9 changes: 4 additions & 5 deletions tests/Test/FixerProviderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,15 @@
use Nexus\CsConfig\Test\FixerProvider;
use PhpCsFixer\Fixer\DeprecatedFixerInterface;
use PhpCsFixer\Fixer\FixerInterface;
use PHPUnit\Framework\Attributes\CoversClass;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;

/**
* @internal
*
* @covers \Nexus\CsConfig\Test\FixerProvider
*/
#[CoversClass(FixerProvider::class)]
final class FixerProviderTest extends TestCase
{
protected function setUp(): void
Expand All @@ -41,9 +42,7 @@ public function testCreateMethodCreatesSameBuiltInFixers(): void
self::assertSame($fixerProvider1->builtin(), $fixerProvider2->builtin());
}

/**
* @dataProvider provideCreateMethodGivesNoDeprecatedBuiltInFixersCases
*/
#[DataProvider('provideCreateMethodGivesNoDeprecatedBuiltInFixersCases')]
public function testCreateMethodGivesNoDeprecatedBuiltInFixers(FixerInterface $fixer): void
{
self::assertNotInstanceOf(DeprecatedFixerInterface::class, $fixer);
Expand Down

0 comments on commit b44fc33

Please sign in to comment.