File tree 2 files changed +17
-7
lines changed
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)
131
131
*/
132
132
public static function search ($ value )
133
133
{
134
- return array_search ($ value , self ::toArray ());
134
+ return array_search ($ value , self ::toArray (), true );
135
135
}
136
136
137
137
/**
Original file line number Diff line number Diff line change @@ -175,13 +175,23 @@ public function testIsValidKey()
175
175
176
176
/**
177
177
* search()
178
+ * @see https://github.com/myclabs/php-enum/issues/13
179
+ * @dataProvider searchProvider
178
180
*/
179
- public function testSearch ()
181
+ public function testSearch ($ value , $ expected )
180
182
{
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
+ );
186
196
}
187
197
}
You can’t perform that action at this time.
0 commit comments