Skip to content

Commit 7049491

Browse files
guidocellaDavertMik
authored andcommitted
Add assertStringStartsWith (#4374)
1 parent f9f75d5 commit 7049491

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

src/Codeception/Module/Asserts.php

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,30 @@ public function assertNotRegExp($pattern, $string, $message = '')
183183
parent::assertNotRegExp($pattern, $string, $message);
184184
}
185185

186+
/**
187+
* Checks that a string starts with the given prefix.
188+
*
189+
* @param string $prefix
190+
* @param string $string
191+
* @param string $message
192+
*/
193+
public function assertStringStartsWith($prefix, $string, $message = '')
194+
{
195+
parent::assertStringStartsWith($prefix, $string, $message);
196+
}
197+
198+
/**
199+
* Checks that a string doesn't start with the given prefix.
200+
*
201+
* @param string $prefix
202+
* @param string $string
203+
* @param string $message
204+
*/
205+
public function assertStringStartsNotWith($prefix, $string, $message = '')
206+
{
207+
parent::assertStringStartsNotWith($prefix, $string, $message);
208+
}
209+
186210

187211
/**
188212
* Checks that variable is empty.

tests/unit/Codeception/Module/AssertsTest.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ public function testAsserts()
1010
$module->assertNotSame(1, '1');
1111
$module->assertRegExp('/^[\d]$/', '1');
1212
$module->assertNotRegExp('/^[a-z]$/', '1');
13+
$module->assertStringStartsWith('fo', 'foo');
14+
$module->assertStringStartsNotWith('ba', 'foo');
1315
$module->assertEmpty([]);
1416
$module->assertNotEmpty([1]);
1517
$module->assertNull(null);

0 commit comments

Comments
 (0)