From 47a2d9218f294ef5b096016a5d26f3bf55ad025e Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Fri, 4 Dec 2020 07:13:31 +0100 Subject: [PATCH] Closes #4092 --- ChangeLog-10.0.md | 1 + src/Framework/Assert.php | 83 ------------------------------ src/Framework/Assert/Functions.php | 23 --------- 3 files changed, 1 insertion(+), 106 deletions(-) diff --git a/ChangeLog-10.0.md b/ChangeLog-10.0.md index 07d4a307048..7c1ac0e45bb 100644 --- a/ChangeLog-10.0.md +++ b/ChangeLog-10.0.md @@ -15,6 +15,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi * [#4081](https://github.com/sebastianbergmann/phpunit/issues/4081): Remove `assertFileNotIsReadable()` * [#4087](https://github.com/sebastianbergmann/phpunit/issues/4087): Remove `assertRegExp()` * [#4090](https://github.com/sebastianbergmann/phpunit/issues/4090): Remove `assertNotRegExp()` +* [#4092](https://github.com/sebastianbergmann/phpunit/issues/4092): Remove `assertEqualXMLStructure()` * [#4142](https://github.com/sebastianbergmann/phpunit/issues/4142): Remove Prophecy integration [10.0.0]: https://github.com/sebastianbergmann/phpunit/compare/9.5...master diff --git a/src/Framework/Assert.php b/src/Framework/Assert.php index 918631bf19d..ba2310eeefc 100644 --- a/src/Framework/Assert.php +++ b/src/Framework/Assert.php @@ -30,13 +30,10 @@ use function is_string; use function preg_match; use function preg_split; -use function sprintf; use function strpos; use ArrayAccess; use Countable; -use DOMAttr; use DOMDocument; -use DOMElement; use PHPUnit\Framework\Constraint\ArrayHasKey; use PHPUnit\Framework\Constraint\Callback; use PHPUnit\Framework\Constraint\ClassHasAttribute; @@ -2089,86 +2086,6 @@ public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXm static::assertNotEquals($expected, $actual, $message); } - /** - * Asserts that a hierarchy of DOMElements matches. - * - * @throws AssertionFailedError - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4091 - */ - public static function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void - { - self::createWarning('assertEqualXMLStructure() is deprecated and will be removed in PHPUnit 10.'); - - $expectedElement = Xml::import($expectedElement); - $actualElement = Xml::import($actualElement); - - static::assertSame( - $expectedElement->tagName, - $actualElement->tagName, - $message - ); - - if ($checkAttributes) { - static::assertSame( - $expectedElement->attributes->length, - $actualElement->attributes->length, - sprintf( - '%s%sNumber of attributes on node "%s" does not match', - $message, - !empty($message) ? "\n" : '', - $expectedElement->tagName - ) - ); - - for ($i = 0; $i < $expectedElement->attributes->length; $i++) { - $expectedAttribute = $expectedElement->attributes->item($i); - $actualAttribute = $actualElement->attributes->getNamedItem($expectedAttribute->name); - - assert($expectedAttribute instanceof DOMAttr); - - if (!$actualAttribute) { - static::fail( - sprintf( - '%s%sCould not find attribute "%s" on node "%s"', - $message, - !empty($message) ? "\n" : '', - $expectedAttribute->name, - $expectedElement->tagName - ) - ); - } - } - } - - Xml::removeCharacterDataNodes($expectedElement); - Xml::removeCharacterDataNodes($actualElement); - - static::assertSame( - $expectedElement->childNodes->length, - $actualElement->childNodes->length, - sprintf( - '%s%sNumber of child nodes of "%s" differs', - $message, - !empty($message) ? "\n" : '', - $expectedElement->tagName - ) - ); - - for ($i = 0; $i < $expectedElement->childNodes->length; $i++) { - static::assertEqualXMLStructure( - $expectedElement->childNodes->item($i), - $actualElement->childNodes->item($i), - $checkAttributes, - $message - ); - } - } - /** * Evaluates a PHPUnit\Framework\Constraint matcher object. * diff --git a/src/Framework/Assert/Functions.php b/src/Framework/Assert/Functions.php index 0f9cbe19295..3442e10d96c 100644 --- a/src/Framework/Assert/Functions.php +++ b/src/Framework/Assert/Functions.php @@ -13,7 +13,6 @@ use ArrayAccess; use Countable; use DOMDocument; -use DOMElement; use PHPUnit\Framework\Constraint\ArrayHasKey; use PHPUnit\Framework\Constraint\Callback; use PHPUnit\Framework\Constraint\ClassHasAttribute; @@ -2233,28 +2232,6 @@ function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, string $mes } } -if (!function_exists('PHPUnit\Framework\assertEqualXMLStructure')) { - /** - * Asserts that a hierarchy of DOMElements matches. - * - * @throws AssertionFailedError - * @throws ExpectationFailedException - * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException - * - * @codeCoverageIgnore - * - * @deprecated https://github.com/sebastianbergmann/phpunit/issues/4091 - * - * @no-named-arguments Parameter names are not covered by the backward compatibility promise for PHPUnit - * - * @see Assert::assertEqualXMLStructure - */ - function assertEqualXMLStructure(DOMElement $expectedElement, DOMElement $actualElement, bool $checkAttributes = false, string $message = ''): void - { - Assert::assertEqualXMLStructure(...func_get_args()); - } -} - if (!function_exists('PHPUnit\Framework\assertThat')) { /** * Evaluates a PHPUnit\Framework\Constraint matcher object.