@@ -184,23 +184,20 @@ public function testStrAfterLast()
184184 $ this ->assertSame ('foo ' , Str::afterLast ('----foo ' , '--- ' ));
185185 }
186186
187- public function testStrContains ()
187+ /**
188+ * @dataProvider strContainsProvider
189+ */
190+ public function testStrContains ($ haystack , $ needles , $ expected , $ ignoreCase = false )
188191 {
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 ));
197193 }
198194
199- public function testStrContainsAll ()
195+ /**
196+ * @dataProvider strContainsAllProvider
197+ */
198+ public function testStrContainsAll ($ haystack , $ needles , $ expected , $ ignoreCase = false )
200199 {
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 ));
204201 }
205202
206203 public function testParseCallback ()
@@ -553,6 +550,36 @@ public function invalidUuidList()
553550 ];
554551 }
555552
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+
556583 public function testMarkdown ()
557584 {
558585 $ this ->assertSame ("<p><em>hello world</em></p> \n" , Str::markdown ('*hello world* ' ));
0 commit comments