Skip to content

Commit

Permalink
Closes #4397
Browse files Browse the repository at this point in the history
  • Loading branch information
sebastianbergmann committed Dec 4, 2020
1 parent 077e9bf commit 26a12c8
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 134 deletions.
1 change: 1 addition & 0 deletions ChangeLog-10.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ All notable changes of the PHPUnit 10.0 release series are documented in this fi
* [#4286](https://github.com/sebastianbergmann/phpunit/issues/4286): Remove support for old logging configuration
* [#4298](https://github.com/sebastianbergmann/phpunit/issues/4298): Remove `at()` matcher
* [#4395](https://github.com/sebastianbergmann/phpunit/issues/4395): Remove `Remove Command::createRunner()`
* [#4397](https://github.com/sebastianbergmann/phpunit/issues/4397): Remove confusing parameter options for XML assertions
* [#4536](https://github.com/sebastianbergmann/phpunit/issues/4536): Remove `assertFileNotIsWritable()`

[10.0.0]: https://github.com/sebastianbergmann/phpunit/compare/9.5...master
71 changes: 10 additions & 61 deletions src/Framework/Assert.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
use function strpos;
use ArrayAccess;
use Countable;
use DOMDocument;
use PHPUnit\Framework\Constraint\ArrayHasKey;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\Constraint\ClassHasAttribute;
Expand Down Expand Up @@ -1961,109 +1960,59 @@ public static function assertXmlFileNotEqualsXmlFile(string $expectedFile, strin
/**
* Asserts that two XML documents are equal.
*
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
*/
public static function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void
public static function assertXmlStringEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
{
if (!is_string($actualXml)) {
self::createWarning('Passing an argument of type DOMDocument for the $actualXml parameter is deprecated. Support for this will be removed in PHPUnit 10.');

$actual = $actualXml;
} else {
$actual = (new XmlLoader)->load($actualXml);
}

$expected = (new XmlLoader)->loadFile($expectedFile);
$actual = (new XmlLoader)->load($actualXml);

static::assertEquals($expected, $actual, $message);
}

/**
* Asserts that two XML documents are not equal.
*
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
*/
public static function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void
public static function assertXmlStringNotEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
{
if (!is_string($actualXml)) {
self::createWarning('Passing an argument of type DOMDocument for the $actualXml parameter is deprecated. Support for this will be removed in PHPUnit 10.');

$actual = $actualXml;
} else {
$actual = (new XmlLoader)->load($actualXml);
}

$expected = (new XmlLoader)->loadFile($expectedFile);
$actual = (new XmlLoader)->load($actualXml);

static::assertNotEquals($expected, $actual, $message);
}

/**
* Asserts that two XML documents are equal.
*
* @param DOMDocument|string $expectedXml
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
*/
public static function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $message = ''): void
public static function assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
{
if (!is_string($expectedXml)) {
self::createWarning('Passing an argument of type DOMDocument for the $expectedXml parameter is deprecated. Support for this will be removed in PHPUnit 10.');

$expected = $expectedXml;
} else {
$expected = (new XmlLoader)->load($expectedXml);
}

if (!is_string($actualXml)) {
self::createWarning('Passing an argument of type DOMDocument for the $actualXml parameter is deprecated. Support for this will be removed in PHPUnit 10.');

$actual = $actualXml;
} else {
$actual = (new XmlLoader)->load($actualXml);
}
$expected = (new XmlLoader)->load($expectedXml);
$actual = (new XmlLoader)->load($actualXml);

static::assertEquals($expected, $actual, $message);
}

/**
* Asserts that two XML documents are not equal.
*
* @param DOMDocument|string $expectedXml
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
*/
public static function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, string $message = ''): void
public static function assertXmlStringNotEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
{
if (!is_string($expectedXml)) {
self::createWarning('Passing an argument of type DOMDocument for the $expectedXml parameter is deprecated. Support for this will be removed in PHPUnit 10.');

$expected = $expectedXml;
} else {
$expected = (new XmlLoader)->load($expectedXml);
}

if (!is_string($actualXml)) {
self::createWarning('Passing an argument of type DOMDocument for the $actualXml parameter is deprecated. Support for this will be removed in PHPUnit 10.');

$actual = $actualXml;
} else {
$actual = (new XmlLoader)->load($actualXml);
}
$expected = (new XmlLoader)->load($expectedXml);
$actual = (new XmlLoader)->load($actualXml);

static::assertNotEquals($expected, $actual, $message);
}
Expand Down
19 changes: 4 additions & 15 deletions src/Framework/Assert/Functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
use function func_get_args;
use ArrayAccess;
use Countable;
use DOMDocument;
use PHPUnit\Framework\Constraint\ArrayHasKey;
use PHPUnit\Framework\Constraint\Callback;
use PHPUnit\Framework\Constraint\ClassHasAttribute;
Expand Down Expand Up @@ -2132,8 +2131,6 @@ function assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile,
/**
* Asserts that two XML documents are equal.
*
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
Expand All @@ -2142,7 +2139,7 @@ function assertXmlFileNotEqualsXmlFile(string $expectedFile, string $actualFile,
*
* @see Assert::assertXmlStringEqualsXmlFile
*/
function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void
function assertXmlStringEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
{
Assert::assertXmlStringEqualsXmlFile(...func_get_args());
}
Expand All @@ -2152,8 +2149,6 @@ function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $
/**
* Asserts that two XML documents are not equal.
*
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
Expand All @@ -2162,7 +2157,7 @@ function assertXmlStringEqualsXmlFile(string $expectedFile, $actualXml, string $
*
* @see Assert::assertXmlStringNotEqualsXmlFile
*/
function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, string $message = ''): void
function assertXmlStringNotEqualsXmlFile(string $expectedFile, string $actualXml, string $message = ''): void
{
Assert::assertXmlStringNotEqualsXmlFile(...func_get_args());
}
Expand All @@ -2172,9 +2167,6 @@ function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, strin
/**
* Asserts that two XML documents are equal.
*
* @param DOMDocument|string $expectedXml
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
Expand All @@ -2183,7 +2175,7 @@ function assertXmlStringNotEqualsXmlFile(string $expectedFile, $actualXml, strin
*
* @see Assert::assertXmlStringEqualsXmlString
*/
function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $message = ''): void
function assertXmlStringEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
{
Assert::assertXmlStringEqualsXmlString(...func_get_args());
}
Expand All @@ -2193,9 +2185,6 @@ function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $messag
/**
* Asserts that two XML documents are not equal.
*
* @param DOMDocument|string $expectedXml
* @param DOMDocument|string $actualXml
*
* @throws ExpectationFailedException
* @throws \SebastianBergmann\RecursionContext\InvalidArgumentException
* @throws \PHPUnit\Util\Xml\Exception
Expand All @@ -2204,7 +2193,7 @@ function assertXmlStringEqualsXmlString($expectedXml, $actualXml, string $messag
*
* @see Assert::assertXmlStringNotEqualsXmlString
*/
function assertXmlStringNotEqualsXmlString($expectedXml, $actualXml, string $message = ''): void
function assertXmlStringNotEqualsXmlString(string $expectedXml, string $actualXml, string $message = ''): void
{
Assert::assertXmlStringNotEqualsXmlString(...func_get_args());
}
Expand Down
33 changes: 0 additions & 33 deletions tests/end-to-end/regression/GitHub/4407.phpt

This file was deleted.

21 changes: 0 additions & 21 deletions tests/end-to-end/regression/GitHub/4407/Issue4407Test.php

This file was deleted.

4 changes: 0 additions & 4 deletions tests/end-to-end/regression/GitHub/4407/test.xml

This file was deleted.

0 comments on commit 26a12c8

Please sign in to comment.