File tree 2 files changed +57
-0
lines changed
2 files changed +57
-0
lines changed Original file line number Diff line number Diff line change
1
+ <?php
2
+ /**
3
+ * @link http://github.com/myclabs/php-enum
4
+ * @license http://www.opensource.org/licenses/mit-license.php MIT (see the LICENSE file)
5
+ */
6
+
7
+ namespace MyCLabs \Tests \Enum ;
8
+
9
+ use MyCLabs \Enum \Enum ;
10
+
11
+ /**
12
+ * Class ConstructorFixture
13
+ *
14
+ * @method static ConstructorFixture ONCE()
15
+ */
16
+ class ConstructorFixture extends Enum
17
+ {
18
+ public function __construct ()
19
+ {
20
+ /* noop */
21
+ }
22
+
23
+ const TEST = 'OK ' ;
24
+ }
Original file line number Diff line number Diff line change @@ -230,6 +230,39 @@ public function testEqualsComparesProblematicValuesProperly()
230
230
$ this ->assertFalse ($ null ->equals ($ false ));
231
231
}
232
232
233
+ /**
234
+ * fromKey()
235
+ */
236
+ public function testFromKey ()
237
+ {
238
+ $ number = EnumFixture::BAR ();
239
+ $ fromValue = EnumFixture::fromKey ('BAR ' );
240
+
241
+ $ this ->assertSame ($ number , $ fromValue );
242
+ }
243
+
244
+ /**
245
+ * fromValue()
246
+ */
247
+ public function testFromValue ()
248
+ {
249
+ $ enum = EnumFixture::NUMBER ();
250
+ $ number = EnumFixture::fromValue (42 );
251
+ $ inexistant = EnumFixture::fromValue ('inexistant ' );
252
+
253
+ $ this ->assertSame ($ enum , $ number );
254
+ $ this ->assertSame (null , $ inexistant );
255
+ }
256
+
257
+ /**
258
+ * @expectedException \BadMethodCallException
259
+ */
260
+ public function testConstructor ()
261
+ {
262
+ $ number = ConstructorFixture::TEST ();
263
+ $ number ->getValue ();
264
+ }
265
+
233
266
/**
234
267
* __wakeup()
235
268
*/
You can’t perform that action at this time.
0 commit comments