File tree Expand file tree Collapse file tree 5 files changed +92
-0
lines changed
src/TextUI/Configuration/Xml/Migration
tests/end-to-end/migration
_files/migration-from-110 Expand file tree Collapse file tree 5 files changed +92
-0
lines changed Original file line number Diff line number Diff line change 921
921
<code ><![CDATA[ removeChild]]> </code >
922
922
</PossiblyNullReference >
923
923
</file >
924
+ <file src =" src/TextUI/Configuration/Xml/Migration/Migrations/ReplaceRestrictDeprecationsWithIgnoreDeprecations.php" >
925
+ <RedundantConditionGivenDocblockType >
926
+ <code ><![CDATA[ assert($source instanceof DOMElement)]]> </code >
927
+ </RedundantConditionGivenDocblockType >
928
+ </file >
924
929
<file src =" src/TextUI/Configuration/Xml/SchemaFinder.php" >
925
930
<LessSpecificReturnStatement >
926
931
<code ><![CDATA[ $result]]> </code >
Original file line number Diff line number Diff line change 65
65
'10.5 ' => [
66
66
RemoveRegisterMockObjectsFromTestArgumentsRecursivelyAttribute::class,
67
67
],
68
+
69
+ '11.0 ' => [
70
+ ReplaceRestrictDeprecationsWithIgnoreDeprecations::class,
71
+ ],
68
72
];
69
73
70
74
/**
Original file line number Diff line number Diff line change
1
+ <?php declare (strict_types=1 );
2
+ /*
3
+ * This file is part of PHPUnit.
4
+ *
5
+ * (c) Sebastian Bergmann <[email protected] >
6
+ *
7
+ * For the full copyright and license information, please view the LICENSE
8
+ * file that was distributed with this source code.
9
+ */
10
+ namespace PHPUnit \TextUI \XmlConfiguration ;
11
+
12
+ use function assert ;
13
+ use DOMDocument ;
14
+ use DOMElement ;
15
+
16
+ /**
17
+ * @internal This class is not covered by the backward compatibility promise for PHPUnit
18
+ */
19
+ final readonly class ReplaceRestrictDeprecationsWithIgnoreDeprecations implements Migration
20
+ {
21
+ /**
22
+ * @throws MigrationException
23
+ */
24
+ public function migrate (DOMDocument $ document ): void
25
+ {
26
+ $ source = $ document ->getElementsByTagName ('source ' )->item (0 );
27
+
28
+ if ($ source === null ) {
29
+ return ;
30
+ }
31
+
32
+ assert ($ source instanceof DOMElement);
33
+
34
+ if (!$ source ->hasAttribute ('restrictDeprecations ' )) {
35
+ return ;
36
+ }
37
+
38
+ $ restrictDeprecations = $ source ->getAttribute ('restrictDeprecations ' ) === 'true ' ;
39
+
40
+ $ source ->removeAttribute ('restrictDeprecations ' );
41
+
42
+ if (!$ restrictDeprecations ||
43
+ $ source ->hasAttribute ('ignoreIndirectDeprecations ' )) {
44
+ return ;
45
+ }
46
+
47
+ $ source ->setAttribute ('ignoreIndirectDeprecations ' , 'true ' );
48
+ }
49
+ }
Original file line number Diff line number Diff line change
1
+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2
+ <phpunit xmlns : xsi =" http://www.w3.org/2001/XMLSchema-instance"
3
+ xsi : noNamespaceSchemaLocation =" https://schema.phpunit.de/11.0/phpunit.xsd"
4
+ bootstrap =" src/Greeter.php" >
5
+ <testsuites >
6
+ <testsuite name =" default" >
7
+ <directory >tests</directory >
8
+ </testsuite >
9
+ </testsuites >
10
+
11
+ <source restrictDeprecations =" true" />
12
+ </phpunit >
Original file line number Diff line number Diff line change
1
+ --TEST--
2
+ Configuration migration from PHPUnit 11.0 format works
3
+ --FILE--
4
+ <?php declare (strict_types=1 );
5
+ $ _SERVER ['argv ' ][] = '--do-not-cache-result ' ;
6
+ $ _SERVER ['argv ' ][] = '--migrate-configuration ' ;
7
+
8
+ chdir (sys_get_temp_dir ());
9
+ copy (__DIR__ . '/_files/migration-from-110/phpunit-11.0.xml ' , 'phpunit.xml ' );
10
+
11
+ require_once __DIR__ . '/../../bootstrap.php ' ;
12
+
13
+ (new PHPUnit \TextUI \Application )->run ($ _SERVER ['argv ' ]);
14
+ --EXPECTF --
15
+ PHPUnit %s by Sebastian Bergmann and contributors.
16
+
17
+ Created backup: %sphpunit.xml.bak
18
+ Migrated configuration: %sphpunit.xml
19
+ --CLEAN --
20
+ <?php declare (strict_types=1 );
21
+ unlink (sys_get_temp_dir () . '/phpunit.xml ' );
22
+ unlink (sys_get_temp_dir () . '/phpunit.xml.bak ' );
You can’t perform that action at this time.
0 commit comments