File tree Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Expand file tree Collapse file tree 2 files changed +17
-7
lines changed Original file line number Diff line number Diff line change @@ -131,7 +131,7 @@ public static function isValidKey($key)
131131 */
132132 public static function search ($ value )
133133 {
134- return array_search ($ value , self ::toArray ());
134+ return array_search ($ value , self ::toArray (), true );
135135 }
136136
137137 /**
Original file line number Diff line number Diff line change @@ -175,13 +175,23 @@ public function testIsValidKey()
175175
176176 /**
177177 * search()
178+ * @see https://github.com/myclabs/php-enum/issues/13
179+ * @dataProvider searchProvider
178180 */
179- public function testSearch ()
181+ public function testSearch ($ value , $ expected )
180182 {
181- $ this ->assertEquals ('FOO ' , EnumFixture::search ('foo ' ));
182- /**
183- * @see https://github.com/myclabs/php-enum/issues/9
184- */
185- $ this ->assertEquals (EnumFixture::PROBLEMATIC_NUMBER , EnumFixture::search (1 ));
183+ $ this ->assertSame ($ expected , EnumFixture::search ($ value ));
184+ }
185+
186+ public function searchProvider () {
187+ return array (
188+ array ('foo ' , 'FOO ' ),
189+ array (0 , 'PROBLEMATIC_NUMBER ' ),
190+ array (null , 'PROBLEMATIC_NULL ' ),
191+ array ('' , 'PROBLEMATIC_EMPTY_STRING ' ),
192+ array (false , 'PROBLEMATIC_BOOLEAN_FALSE ' ),
193+ array ('bar I do not exist ' , false ),
194+ array (array (), false ),
195+ );
186196 }
187197}
You can’t perform that action at this time.
0 commit comments