From 3c1e5ac76b8901322d4163b7d0ee690f504c9452 Mon Sep 17 00:00:00 2001 From: Sebastian Bergmann Date: Mon, 25 Nov 2019 16:33:13 +0100 Subject: [PATCH] Closes #3951 --- ChangeLog-9.0.md | 1 + src/Framework/Assert.php | 76 ++++-------------------------- src/Framework/Assert/Functions.php | 8 ++-- 3 files changed, 13 insertions(+), 72 deletions(-) diff --git a/ChangeLog-9.0.md b/ChangeLog-9.0.md index 994096c3531..cfc5ef57628 100644 --- a/ChangeLog-9.0.md +++ b/ChangeLog-9.0.md @@ -17,6 +17,7 @@ All notable changes of the PHPUnit 9.0 release series are documented in this fil * Implemented [#3370](https://github.com/sebastianbergmann/phpunit/issues/3370): Remove `assertInternalType()` and `assertNotInternalType()` * Implemented [#3426](https://github.com/sebastianbergmann/phpunit/issues/3426): Clean up `assertContains()` and `assertNotContains()` * Implemented [#3495](https://github.com/sebastianbergmann/phpunit/issues/3495): Remove `assertArraySubset()` +* Implemented [#3951](https://github.com/sebastianbergmann/phpunit/issues/3951): Remove optional parameters of `assertFileEquals()` etc. [9.0.0]: https://github.com/sebastianbergmann/phpunit/compare/8.5...master diff --git a/src/Framework/Assert.php b/src/Framework/Assert.php index 00c80d781f1..98b39d67764 100644 --- a/src/Framework/Assert.php +++ b/src/Framework/Assert.php @@ -495,27 +495,12 @@ public static function assertLessThanOrEqual($expected, $actual, string $message * @throws ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ - public static function assertFileEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void + public static function assertFileEquals(string $expected, string $actual, string $message = ''): void { - // @codeCoverageIgnoreStart - if ($canonicalize) { - self::createWarning('The optional $canonicalize parameter of assertFileEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertFileEqualsCanonicalizing() instead.'); - } - - if ($ignoreCase) { - self::createWarning('The optional $ignoreCase parameter of assertFileEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertFileEqualsIgnoringCase() instead.'); - } - // @codeCoverageIgnoreEnd - static::assertFileExists($expected, $message); static::assertFileExists($actual, $message); - $constraint = new IsEqual( - \file_get_contents($expected), - 0.0, - $canonicalize, - $ignoreCase - ); + $constraint = new IsEqual(\file_get_contents($expected)); static::assertThat(\file_get_contents($actual), $constraint, $message); } @@ -572,28 +557,13 @@ public static function assertFileEqualsIgnoringCase(string $expected, string $ac * @throws ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ - public static function assertFileNotEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void + public static function assertFileNotEquals(string $expected, string $actual, string $message = ''): void { - // @codeCoverageIgnoreStart - if ($canonicalize) { - self::createWarning('The optional $canonicalize parameter of assertFileNotEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertFileNotEqualsCanonicalizing() instead.'); - } - - if ($ignoreCase) { - self::createWarning('The optional $ignoreCase parameter of assertFileNotEquals() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertFileNotEqualsIgnoringCase() instead.'); - } - // @codeCoverageIgnoreEnd - static::assertFileExists($expected, $message); static::assertFileExists($actual, $message); $constraint = new LogicalNot( - new IsEqual( - \file_get_contents($expected), - 0.0, - $canonicalize, - $ignoreCase - ) + new IsEqual(\file_get_contents($expected),) ); static::assertThat(\file_get_contents($actual), $constraint, $message); @@ -655,26 +625,11 @@ public static function assertFileNotEqualsIgnoringCase(string $expected, string * @throws ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ - public static function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void + public static function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void { - // @codeCoverageIgnoreStart - if ($canonicalize) { - self::createWarning('The optional $canonicalize parameter of assertStringEqualsFile() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertStringEqualsFileCanonicalizing() instead.'); - } - - if ($ignoreCase) { - self::createWarning('The optional $ignoreCase parameter of assertStringEqualsFile() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertStringEqualsFileIgnoringCase() instead.'); - } - // @codeCoverageIgnoreEnd - static::assertFileExists($expectedFile, $message); - $constraint = new IsEqual( - \file_get_contents($expectedFile), - 0.0, - $canonicalize, - $ignoreCase - ); + $constraint = new IsEqual(\file_get_contents($expectedFile),); static::assertThat($actualString, $constraint, $message); } @@ -729,27 +684,12 @@ public static function assertStringEqualsFileIgnoringCase(string $expectedFile, * @throws ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ - public static function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void + public static function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void { - // @codeCoverageIgnoreStart - if ($canonicalize) { - self::createWarning('The optional $canonicalize parameter of assertStringNotEqualsFile() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertStringNotEqualsFileCanonicalizing() instead.'); - } - - if ($ignoreCase) { - self::createWarning('The optional $ignoreCase parameter of assertStringNotEqualsFile() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertStringNotEqualsFileIgnoringCase() instead.'); - } - // @codeCoverageIgnoreEnd - static::assertFileExists($expectedFile, $message); $constraint = new LogicalNot( - new IsEqual( - \file_get_contents($expectedFile), - 0.0, - $canonicalize, - $ignoreCase - ) + new IsEqual(\file_get_contents($expectedFile)) ); static::assertThat($actualString, $constraint, $message); diff --git a/src/Framework/Assert/Functions.php b/src/Framework/Assert/Functions.php index 1375267d191..e22cdcc96b3 100644 --- a/src/Framework/Assert/Functions.php +++ b/src/Framework/Assert/Functions.php @@ -402,7 +402,7 @@ function assertLessThanOrEqual($expected, $actual, string $message = ''): void * * @see Assert::assertFileEquals */ -function assertFileEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void +function assertFileEquals(string $expected, string $actual, string $message = ''): void { Assert::assertFileEquals(...\func_get_args()); } @@ -444,7 +444,7 @@ function assertFileEqualsIgnoringCase(string $expected, string $actual, string $ * * @see Assert::assertFileNotEquals */ -function assertFileNotEquals(string $expected, string $actual, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void +function assertFileNotEquals(string $expected, string $actual, string $message = ''): void { Assert::assertFileNotEquals(...\func_get_args()); } @@ -486,7 +486,7 @@ function assertFileNotEqualsIgnoringCase(string $expected, string $actual, strin * * @see Assert::assertStringEqualsFile */ -function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void +function assertStringEqualsFile(string $expectedFile, string $actualString, string $message = ''): void { Assert::assertStringEqualsFile(...\func_get_args()); } @@ -528,7 +528,7 @@ function assertStringEqualsFileIgnoringCase(string $expectedFile, string $actual * * @see Assert::assertStringNotEqualsFile */ -function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = '', bool $canonicalize = false, bool $ignoreCase = false): void +function assertStringNotEqualsFile(string $expectedFile, string $actualString, string $message = ''): void { Assert::assertStringNotEqualsFile(...\func_get_args()); }