From ae3bfa3755cfd5fdd0ca4ee681a8fe574cd3f39c Mon Sep 17 00:00:00 2001 From: Oliver Maksimovic Date: Mon, 4 Mar 2019 08:46:52 +0100 Subject: [PATCH] #3342 Remove optional parameters of assertEquals() and assertNotEquals() --- src/Framework/Assert.php | 76 +++--------------------------- src/Framework/Assert/Functions.php | 4 +- 2 files changed, 9 insertions(+), 71 deletions(-) diff --git a/src/Framework/Assert.php b/src/Framework/Assert.php index b40a2866a75..c11bb13d184 100644 --- a/src/Framework/Assert.php +++ b/src/Framework/Assert.php @@ -180,49 +180,19 @@ public static function assertArrayNotHasKey($key, $array, string $message = ''): * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException * @throws Exception */ - public static function assertContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void + public static function assertContains($needle, $haystack, string $message = ''): void { - // @codeCoverageIgnoreStart - if (\is_string($haystack)) { - self::createWarning('Using assertContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringContainsString() or assertStringContainsStringIgnoringCase() instead.'); - } - - if (!$checkForObjectIdentity) { - self::createWarning('The optional $checkForObjectIdentity parameter of assertContains() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertContainsEquals() instead.'); - } - - if ($checkForNonObjectIdentity) { - self::createWarning('The optional $checkForNonObjectIdentity parameter of assertContains() is deprecated and will be removed in PHPUnit 9.'); - } - - if ($ignoreCase) { - self::createWarning('The optional $ignoreCase parameter of assertContains() is deprecated and will be removed in PHPUnit 9.'); - } - // @codeCoverageIgnoreEnd - if (\is_array($haystack) || (\is_object($haystack) && $haystack instanceof Traversable)) { $constraint = new TraversableContains( $needle, - $checkForObjectIdentity, - $checkForNonObjectIdentity - ); - } elseif (\is_string($haystack)) { - if (!\is_string($needle)) { - throw InvalidArgumentHelper::factory( - 1, - 'string' - ); - } - - $constraint = new StringContains( - $needle, - $ignoreCase + true, + false ); } else { throw InvalidArgumentHelper::factory( 2, - 'array, traversable or string' + 'array or traversable' ); } @@ -271,47 +241,15 @@ public static function assertAttributeContains($needle, string $haystackAttribut * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException * @throws Exception */ - public static function assertNotContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void + public static function assertNotContains($needle, $haystack, string $message = ''): void { - // @codeCoverageIgnoreStart - if (\is_string($haystack)) { - self::createWarning('Using assertNotContains() with string haystacks is deprecated and will not be supported in PHPUnit 9. Refactor your test to use assertStringNotContainsString() or assertStringNotContainsStringIgnoringCase() instead.'); - } - - if (!$checkForObjectIdentity) { - self::createWarning('The optional $checkForObjectIdentity parameter of assertNotContains() is deprecated and will be removed in PHPUnit 9. Refactor your test to use assertNotContainsEquals() instead.'); - } - - if ($checkForNonObjectIdentity) { - self::createWarning('The optional $checkForNonObjectIdentity parameter of assertNotContains() is deprecated and will be removed in PHPUnit 9.'); - } - - if ($ignoreCase) { - self::createWarning('The optional $ignoreCase parameter of assertNotContains() is deprecated and will be removed in PHPUnit 9.'); - } - // @codeCoverageIgnoreEnd - if (\is_array($haystack) || (\is_object($haystack) && $haystack instanceof Traversable)) { $constraint = new LogicalNot( new TraversableContains( $needle, - $checkForObjectIdentity, - $checkForNonObjectIdentity - ) - ); - } elseif (\is_string($haystack)) { - if (!\is_string($needle)) { - throw InvalidArgumentHelper::factory( - 1, - 'string' - ); - } - - $constraint = new LogicalNot( - new StringContains( - $needle, - $ignoreCase + true, + false ) ); } else { diff --git a/src/Framework/Assert/Functions.php b/src/Framework/Assert/Functions.php index fffce4b24eb..630e99ffde3 100644 --- a/src/Framework/Assert/Functions.php +++ b/src/Framework/Assert/Functions.php @@ -113,7 +113,7 @@ function assertArrayNotHasKey($key, $array, string $message = ''): void * @throws ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ -function assertContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void +function assertContains($needle, $haystack, string $message = ''): void { Assert::assertContains(...\func_get_args()); } @@ -138,7 +138,7 @@ function assertAttributeContains($needle, string $haystackAttributeName, $haysta * @throws ExpectationFailedException * @throws \SebastianBergmann\RecursionContext\InvalidArgumentException */ -function assertNotContains($needle, $haystack, string $message = '', bool $ignoreCase = false, bool $checkForObjectIdentity = true, bool $checkForNonObjectIdentity = false): void +function assertNotContains($needle, $haystack, string $message = ''): void { Assert::assertNotContains(...\func_get_args()); }