Skip to content
This repository was archived by the owner on Mar 12, 2025. It is now read-only.

Commit 0277e6c

Browse files
committed
Add assertString(Not)ContainsStringIgnoringCase
1 parent 5765766 commit 0277e6c

File tree

1 file changed

+40
-2
lines changed

1 file changed

+40
-2
lines changed

src/TestCase.php

Lines changed: 40 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
namespace Codeception\PHPUnit;
44

55

6+
use PHPUnit\Framework\AssertionFailedError;
7+
68
abstract class TestCase extends \PHPUnit\Framework\TestCase
79
{
810

@@ -36,11 +38,47 @@ public static function tearDownAfterClass()
3638

3739
public static function assertStringContainsString($needle, $haystack, $message = '')
3840
{
39-
\Codeception\PHPUnit\TestCase::assertContains($needle, $haystack, $message = '');
41+
if (!is_string($needle)) {
42+
throw new AssertionFailedError('Needle is not string');
43+
}
44+
if (!is_string($haystack)) {
45+
throw new AssertionFailedError('Haystack is not string');
46+
}
47+
\Codeception\PHPUnit\TestCase::assertContains($needle, $haystack, $message);
4048
}
4149

4250
public static function assertStringNotContainsString($needle, $haystack, $message = '')
4351
{
44-
\Codeception\PHPUnit\TestCase::assertNotContains($needle, $haystack, $message = '');
52+
53+
if (!is_string($needle)) {
54+
throw new AssertionFailedError('Needle is not string');
55+
}
56+
if (!is_string($haystack)) {
57+
throw new AssertionFailedError('Haystack is not string');
58+
}
59+
\Codeception\PHPUnit\TestCase::assertNotContains($needle, $haystack, $message);
60+
}
61+
62+
public static function assertStringContainsStringIgnoringCase($needle, $haystack, $message = '')
63+
{
64+
if (!is_string($needle)) {
65+
throw new AssertionFailedError('Needle is not string');
66+
}
67+
if (!is_string($haystack)) {
68+
throw new AssertionFailedError('Haystack is not string');
69+
}
70+
\Codeception\PHPUnit\TestCase::assertContains($needle, $haystack, $message, true);
71+
}
72+
73+
public static function assertStringNotContainsStringIgnoringCase($needle, $haystack, $message = '')
74+
{
75+
76+
if (!is_string($needle)) {
77+
throw new AssertionFailedError('Needle is not string');
78+
}
79+
if (!is_string($haystack)) {
80+
throw new AssertionFailedError('Haystack is not string');
81+
}
82+
\Codeception\PHPUnit\TestCase::assertNotContains($needle, $haystack, $message, true);
4583
}
4684
}

0 commit comments

Comments
 (0)