-
-
Notifications
You must be signed in to change notification settings - Fork 9.6k
[String] Add AbstractString::containsAny() #35936
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -55,6 +55,26 @@ public static function provideBytesAt(): array | |
]; | ||
} | ||
|
||
/** | ||
* @dataProvider provideIndexOf | ||
*/ | ||
public function testContainsAny(?int $result, string $string, $needle) | ||
{ | ||
$instance = static::createFromString($string); | ||
|
||
$this->assertSame(null !== $instance->indexOf($needle), $instance->containsAny($needle)); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does copy pasting the method content here actually test something? Shouldn't we create dedicated providers for this new methods? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's better this way to me, easier to maintain. |
||
} | ||
|
||
/** | ||
* @dataProvider provideIndexOfIgnoreCase | ||
*/ | ||
public function testContainsAnyIgnoreCase(?int $result, string $string, $needle) | ||
{ | ||
$instance = static::createFromString($string); | ||
|
||
$this->assertSame(null !== $instance->ignoreCase()->indexOf($needle), $instance->ignoreCase()->containsAny($needle)); | ||
} | ||
|
||
public function testUnwrap() | ||
{ | ||
$expected = ['hello', 'world']; | ||
|
@@ -161,7 +181,7 @@ public static function provideLength(): array | |
/** | ||
* @dataProvider provideIndexOf | ||
*/ | ||
public function testIndexOf(?int $result, string $string, string $needle, int $offset) | ||
public function testIndexOf(?int $result, string $string, $needle, int $offset) | ||
{ | ||
$instance = static::createFromString($string); | ||
|
||
|
@@ -180,6 +200,7 @@ public static function provideIndexOf(): array | |
[null, 'abc', 'a', -1], | ||
[null, '123abc', 'B', -3], | ||
[null, '123abc', 'b', 6], | ||
[0, 'abc', ['a', 'e'], 0], | ||
[0, 'abc', 'a', 0], | ||
[1, 'abc', 'b', 1], | ||
[2, 'abc', 'c', 1], | ||
|
@@ -191,7 +212,7 @@ public static function provideIndexOf(): array | |
/** | ||
* @dataProvider provideIndexOfIgnoreCase | ||
*/ | ||
public function testIndexOfIgnoreCase(?int $result, string $string, string $needle, int $offset) | ||
public function testIndexOfIgnoreCase(?int $result, string $string, $needle, int $offset) | ||
{ | ||
$instance = static::createFromString($string); | ||
|
||
|
@@ -208,6 +229,7 @@ public static function provideIndexOfIgnoreCase(): array | |
[null, 'abc', 'a', -1], | ||
[null, 'abc', 'A', -1], | ||
[null, '123abc', 'B', 6], | ||
[0, 'ABC', ['a', 'e'], 0], | ||
[0, 'ABC', 'a', 0], | ||
[0, 'ABC', 'A', 0], | ||
[1, 'ABC', 'b', 0], | ||
|
Uh oh!
There was an error while loading. Please reload this page.