@@ -184,23 +184,20 @@ public function testStrAfterLast()
184
184
$ this ->assertSame ('foo ' , Str::afterLast ('----foo ' , '--- ' ));
185
185
}
186
186
187
- public function testStrContains ()
187
+ /**
188
+ * @dataProvider strContainsProvider
189
+ */
190
+ public function testStrContains ($ haystack , $ needles , $ expected , $ ignoreCase = false )
188
191
{
189
- $ this ->assertTrue (Str::contains ('taylor ' , 'ylo ' ));
190
- $ this ->assertTrue (Str::contains ('taylor ' , 'taylor ' ));
191
- $ this ->assertTrue (Str::contains ('taylor ' , ['ylo ' ]));
192
- $ this ->assertTrue (Str::contains ('taylor ' , ['xxx ' , 'ylo ' ]));
193
- $ this ->assertFalse (Str::contains ('taylor ' , 'xxx ' ));
194
- $ this ->assertFalse (Str::contains ('taylor ' , ['xxx ' ]));
195
- $ this ->assertFalse (Str::contains ('taylor ' , '' ));
196
- $ this ->assertFalse (Str::contains ('' , '' ));
192
+ $ this ->assertEquals ($ expected , Str::contains ($ haystack , $ needles , $ ignoreCase ));
197
193
}
198
194
199
- public function testStrContainsAll ()
195
+ /**
196
+ * @dataProvider strContainsAllProvider
197
+ */
198
+ public function testStrContainsAll ($ haystack , $ needles , $ expected , $ ignoreCase = false )
200
199
{
201
- $ this ->assertTrue (Str::containsAll ('taylor otwell ' , ['taylor ' , 'otwell ' ]));
202
- $ this ->assertTrue (Str::containsAll ('taylor otwell ' , ['taylor ' ]));
203
- $ this ->assertFalse (Str::containsAll ('taylor otwell ' , ['taylor ' , 'xxx ' ]));
200
+ $ this ->assertEquals ($ expected , Str::containsAll ($ haystack , $ needles , $ ignoreCase ));
204
201
}
205
202
206
203
public function testParseCallback ()
@@ -553,6 +550,36 @@ public function invalidUuidList()
553
550
];
554
551
}
555
552
553
+ public function strContainsProvider ()
554
+ {
555
+ return [
556
+ ['Taylor ' , 'ylo ' , true , true ],
557
+ ['Taylor ' , 'ylo ' , true , false ],
558
+ ['Taylor ' , 'taylor ' , true , true ],
559
+ ['Taylor ' , 'taylor ' , false , false ],
560
+ ['Taylor ' , ['ylo ' ], true , true ],
561
+ ['Taylor ' , ['ylo ' ], true , false ],
562
+ ['Taylor ' , ['xxx ' , 'ylo ' ], true , true ],
563
+ ['Taylor ' , ['xxx ' , 'ylo ' ], true , false ],
564
+ ['Taylor ' , 'xxx ' , false ],
565
+ ['Taylor ' , ['xxx ' ], false ],
566
+ ['Taylor ' , '' , false ],
567
+ ['' , '' , false ],
568
+ ];
569
+ }
570
+
571
+ public function strContainsAllProvider ()
572
+ {
573
+ return [
574
+ ['Taylor Otwell ' , ['taylor ' , 'otwell ' ], false , false ],
575
+ ['Taylor Otwell ' , ['taylor ' , 'otwell ' ], true , true ],
576
+ ['Taylor Otwell ' , ['taylor ' ], false , false ],
577
+ ['Taylor Otwell ' , ['taylor ' ], true , true ],
578
+ ['Taylor Otwell ' , ['taylor ' , 'xxx ' ], false , false ],
579
+ ['Taylor Otwell ' , ['taylor ' , 'xxx ' ], false , true ],
580
+ ];
581
+ }
582
+
556
583
public function testMarkdown ()
557
584
{
558
585
$ this ->assertSame ("<p><em>hello world</em></p> \n" , Str::markdown ('*hello world* ' ));
0 commit comments