Skip to content

Commit

Permalink
Merge branch '11.5'
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 20, 2024
2 parents 510e81f + be53591 commit 9c95792
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 49 deletions.
2 changes: 0 additions & 2 deletions schema/11.2.xsd
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,6 @@
<xs:attribute name="bootstrap" type="xs:anyURI"/>
<xs:attribute name="cacheDirectory" type="xs:anyURI"/>
<xs:attribute name="cacheResult" type="xs:boolean" default="true"/>
<xs:attribute name="cacheResultFile" type="xs:anyURI"/>
<xs:attribute name="colors" type="xs:boolean" default="false"/>
<xs:attribute name="columns" type="columnsType" default="80"/>
<xs:attribute name="controlGarbageCollector" type="xs:boolean" default="false"/>
Expand All @@ -198,7 +197,6 @@
<xs:attribute name="beStrictAboutChangesToGlobalState" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutOutputDuringTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutTestsThatDoNotTestAnything" type="xs:boolean" default="true"/>
<xs:attribute name="beStrictAboutTodoAnnotatedTests" type="xs:boolean" default="false"/>
<xs:attribute name="beStrictAboutCoverageMetadata" type="xs:boolean" default="false"/>
<xs:attribute name="defaultTimeLimit" type="xs:integer" default="0"/>
<xs:attribute name="enforceTimeLimit" type="xs:boolean" default="false"/>
Expand Down
8 changes: 8 additions & 0 deletions src/TextUI/Configuration/Xml/Migration/MigrationBuilder.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@
MoveCoverageDirectoriesToSource::class,
],

'10.4' => [
RemoveBeStrictAboutTodoAnnotatedTestsAttribute::class,
],

'10.5' => [
RemoveRegisterMockObjectsFromTestArgumentsRecursivelyAttribute::class,
],
Expand All @@ -80,6 +84,10 @@
RemoveCoverageElementCacheDirectoryAttribute::class,
],

'11.2' => [
RemoveBeStrictAboutTodoAnnotatedTestsAttribute::class,
],

'11.4' => [
RemoveCoverageElementIncludeUncoveredFilesAttribute::class,
],
Expand Down
11 changes: 11 additions & 0 deletions tests/_files/XmlConfigurationMigration/input-issue-6087.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/11.1/phpunit.xsd"
beStrictAboutTodoAnnotatedTests="true"
>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
10 changes: 10 additions & 0 deletions tests/_files/XmlConfigurationMigration/output-issue-6087.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:noNamespaceSchemaLocation="https://schema.phpunit.de/12.0/phpunit.xsd"
>
<testsuites>
<testsuite name="default">
<directory>tests</directory>
</testsuite>
</testsuites>
</phpunit>
75 changes: 28 additions & 47 deletions tests/unit/TextUI/Configuration/Xml/MigratorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,63 +9,44 @@
*/
namespace PHPUnit\TextUI\XmlConfiguration;

use PHPUnit\Framework\Attributes\TestDox;
use PHPUnit\Framework\Attributes\Ticket;
use PHPUnit\Framework\Attributes\DataProvider;
use PHPUnit\Framework\TestCase;
use PHPUnit\Util\Xml\Loader as XmlLoader;

final class MigratorTest extends TestCase
{
#[TestDox('Can migrate PHPUnit 9.2 configuration')]
public function testCanMigratePhpUnit92Configuration(): void
public static function provider(): array
{
$this->assertEquals(
(new XmlLoader)->loadFile(__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.2.xml'),
(new XmlLoader)->load(
(new Migrator)->migrate(
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.2.xml',
),
),
);
}

#[TestDox('Can migrate PHPUnit 9.5 configuration')]
public function testCanMigratePhpUnit95Configuration(): void
{
$this->assertEquals(
(new XmlLoader)->loadFile(__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.5.xml'),
(new XmlLoader)->load(
(new Migrator)->migrate(
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.5.xml',
),
),
);
}

#[TestDox('Remove cacheDirectory attribute from <coverage> element when migrating from PHPUnit 11.1 to PHPUnit 11.2')]
#[Ticket('https://github.com/sebastianbergmann/phpunit/issues/5859')]
public function testIssue5859(): void
{
$this->assertEquals(
(new XmlLoader)->loadFile(__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-5859.xml'),
(new XmlLoader)->load(
(new Migrator)->migrate(
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-5859.xml',
),
),
);
return [
'PHPUnit 9.2' => [
__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.2.xml',
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.2.xml',
],
'PHPUnit 9.5' => [
__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-9.5.xml',
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-9.5.xml',
],
'Relative Path' => [
__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-relative-schema-path.xml',
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-relative-schema-path.xml',
],
'Issue 5859' => [
__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-issue-5859.xml',
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-issue-5859.xml',
],
'Issue 6087' => [
__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-issue-6087.xml',
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-issue-6087.xml',
],
];
}

#[TestDox('Keep relative schema path when present')]
public function testKeepRelativeSchema(): void
#[DataProvider('provider')]
public function testCanMigrateConfigurationFileThatValidatesAgainstPreviousSchema(string $output, string $input): void
{
$this->assertEquals(
(new XmlLoader)->loadFile(__DIR__ . '/../../../../_files/XmlConfigurationMigration/output-relative-schema-path.xml'),
(new XmlLoader)->load(
(new Migrator)->migrate(
__DIR__ . '/../../../../_files/XmlConfigurationMigration/input-relative-schema-path.xml',
),
),
(new XmlLoader)->loadFile($output),
(new XmlLoader)->load((new Migrator)->migrate($input)),
);
}
}

0 comments on commit 9c95792

Please sign in to comment.