minor #37778 The PHPUnit\Util\XML class has been removed in PHPUnit 9.3 (derrabus)

This PR was merged into the 3.4 branch.

Discussion
----------

The PHPUnit\Util\XML class has been removed in PHPUnit 9.3

| Q             | A
| ------------- | ---
| Branch?       | 3.4
| Bug fix?      | yes
| New feature?  | no
| Deprecations? | no
| Tickets       | Part of #37564
| License       | MIT
| Doc PR        | N/A

`PHPUnit\Util\XML`, an internal PHPUnit class, is used in a couple of tests. Those tests fail on PHPUnit 9.3 because that class has been removed. This PR fixes those tests by using the new class if it's available.

If this is too much C&P, we could consider having PhpUnitBridge polyfill this call.

Commits
-------

8b801c1269 The PHPUnit\Util\XML class has been removed in PHPUnit 9.3.
This commit is contained in:
Fabien Potencier 2020-08-09 10:07:49 +02:00
commit d628fcb914
3 changed files with 18 additions and 3 deletions

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Form\Tests\Resources;
use PHPUnit\Framework\TestCase;
use PHPUnit\Util\Xml\Loader;
class TranslationFilesTest extends TestCase
{
@ -20,7 +21,11 @@ class TranslationFilesTest extends TestCase
*/
public function testTranslationFileIsValid($filePath)
{
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
$loader = class_exists(Loader::class)
? [new Loader(), 'loadFile']
: 'PHPUnit\Util\XML::loadfile';
$loader($filePath, false, false, true);
$this->addToAssertionCount(1);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Security\Core\Tests\Resources;
use PHPUnit\Framework\TestCase;
use PHPUnit\Util\Xml\Loader;
class TranslationFilesTest extends TestCase
{
@ -20,7 +21,11 @@ class TranslationFilesTest extends TestCase
*/
public function testTranslationFileIsValid($filePath)
{
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
$loader = class_exists(Loader::class)
? [new Loader(), 'loadFile']
: 'PHPUnit\Util\XML::loadfile';
$loader($filePath, false, false, true);
$this->addToAssertionCount(1);
}

View File

@ -12,6 +12,7 @@
namespace Symfony\Component\Validator\Tests\Resources;
use PHPUnit\Framework\TestCase;
use PHPUnit\Util\Xml\Loader;
class TranslationFilesTest extends TestCase
{
@ -20,7 +21,11 @@ class TranslationFilesTest extends TestCase
*/
public function testTranslationFileIsValid($filePath)
{
\PHPUnit\Util\XML::loadfile($filePath, false, false, true);
$loader = class_exists(Loader::class)
? [new Loader(), 'loadFile']
: 'PHPUnit\Util\XML::loadfile';
$loader($filePath, false, false, true);
$this->addToAssertionCount(1);
}