-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest.php
More file actions
45 lines (34 loc) · 947 Bytes
/
test.php
File metadata and controls
45 lines (34 loc) · 947 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<?php
require_once 'Enum.php';
final class Foo extends \Enum
{
const VALUES = [
'bar' => 1,
'boo' => 10,
'key' => 10
];
}
try {
Foo::empty();
\assert(false, 'Created disallow value');
} catch (\RuntimeException $ex) {
//
}
\assert(Foo::bar() === Foo::bar(), 'Enums are not same');
\assert(Foo::bar() !== Foo::boo(), 'Different enums are same');
$enum = Foo::bar();
\assert($enum() === 1, 'Enum values is not equals 1');
\assert(Foo::fromValue(1) === Foo::bar(), 'Enum from value is different');
\assert(Foo::boo() === Foo::key(), 'Enums with same value are not same');
\assert(
\json_encode(Foo::bar()) === '{"name":"bar","value":1}',
'Enum json is not valid'
);
\assert((string) Foo::bar() === '1', 'Can\'t cast enum to string');
final class Bar extends \Enum
{
const VALUES = [
'bar' => 1
];
}
\assert(Foo::bar() !== Bar::bar(), 'Two different enums are the same');