1+ <?php declare (strict_types=1 );
2+ /**
3+ * TypeEx
4+ *
5+ * Licensed under the Apache License, Version 2.0 (the "License");
6+ * you may not use this file except in compliance with the License.
7+ * You may obtain a copy of the License at
8+ *
9+ * http://www.apache.org/licenses/LICENSE-2.0
10+ *
11+ * Unless required by applicable law or agreed to in writing, software
12+ * distributed under the License is distributed on an "AS IS" BASIS,
13+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+ * See the License for the specific language governing permissions and
15+ * limitations under the License.
16+ */
17+ namespace modethirteen \TypeEx \Tests \StringEx ;
18+
19+ use modethirteen \TypeEx \StringEx ;
20+ use PHPUnit \Framework \TestCase ;
21+
22+ class contains_Test extends TestCase {
23+
24+ /**
25+ * @return array
26+ */
27+ public static function string_value_expected_Provider () : array {
28+ return [
29+ ['foo ' , 'foo ' , true ],
30+ ['foo ' , 'f ' , true ],
31+ ['foo ' , 'o ' , true ],
32+ ['foo ' , 'oo ' , true ],
33+ ['foo bar ' , 'bar ' , true ],
34+ ['foo bar ' , ' ' , true ],
35+ ['foo bar ' , 'foo ' , true ],
36+ ['foo ' , 'bar ' , false ],
37+ ['foo ' , 'boo ' , false ],
38+ ['foo ' , ['foo ' , 'f ' , 'o ' , 'oo ' ], true ],
39+ ['foo bar ' , ['foo ' , 'bar ' ], true ],
40+ ['foo bar ' , ['foo ' , ' ' ], true ],
41+ ['foo bar ' , ['foo ' ], true ],
42+ ['foo ' , ['foo ' , 'bar ' ], true ],
43+ ['foo ' , ['boo ' ], false ]
44+ ];
45+ }
46+
47+ /**
48+ * @dataProvider string_value_expected_Provider
49+ * @test
50+ * @param string $string
51+ * @param mixed $value
52+ * @param bool $expected
53+ */
54+ public function String_contains (string $ string , $ value , bool $ expected ) : void {
55+
56+ // act
57+ $ result = (new StringEx ($ string ))->contains ($ value );
58+
59+ // assert
60+ static ::assertEquals ($ expected , $ result );
61+ }
62+ }
0 commit comments