= 6.4.2 behaviour. * * @link https://github.com/sebastianbergmann/phpunit/issues/3422 * @link https://github.com/sebastianbergmann/phpunit/issues/2520 * @link https://github.com/sebastianbergmann/phpunit/pull/2778 */ trait AssertStringContains { /** * Asserts that a string haystack contains a needle. * * @param string $needle The string to search for. * @param string $haystack The string to treat as the haystack. * @param string $message Optional failure message to display. * * @return void */ final public static function assertStringContainsString( $needle, $haystack, $message = '' ) { if ( $needle === '' ) { static::assertSame( $needle, $needle, $message ); return; } static::assertContains( $needle, $haystack, $message ); } /** * Asserts that a string haystack contains a needle (case-insensitive). * * @param string $needle The string to search for. * @param string $haystack The string to treat as the haystack. * @param string $message Optional failure message to display. * * @return void */ final public static function assertStringContainsStringIgnoringCase( $needle, $haystack, $message = '' ) { if ( $needle === '' ) { static::assertSame( $needle, $needle, $message ); return; } static::assertContains( $needle, $haystack, $message, true ); } /** * Asserts that a string haystack does NOT contain a needle. * * @param string $needle The string to search for. * @param string $haystack The string to treat as the haystack. * @param string $message Optional failure message to display. * * @return void */ final public static function assertStringNotContainsString( $needle, $haystack, $message = '' ) { if ( $needle === '' ) { $msg = "Failed asserting that '{$haystack}' does not contain \"\"."; if ( $message !== '' ) { $msg = $message . \PHP_EOL . $msg; } static::fail( $msg ); } static::assertNotContains( $needle, $haystack, $message ); } /** * Asserts that a string haystack does NOT contain a needle (case-insensitive). * * @param string $needle The string to search for. * @param string $haystack The string to treat as the haystack. * @param string $message Optional failure message to display. * * @return void */ final public static function assertStringNotContainsStringIgnoringCase( $needle, $haystack, $message = '' ) { if ( $needle === '' ) { $msg = "Failed asserting that '{$haystack}' does not contain \"\"."; if ( $message !== '' ) { $msg = $message . \PHP_EOL . $msg; } static::fail( $msg ); } static::assertNotContains( $needle, $haystack, $message, true ); } }