-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
InfoTest.php
57 lines (48 loc) · 1.5 KB
/
InfoTest.php
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
46
47
48
49
50
51
52
53
54
55
56
57
<?php
declare(strict_types=1);
namespace Bakame\Aide\Enum;
use PHPUnit\Framework\Attributes\Test;
use PHPUnit\Framework\TestCase;
final class InfoTest extends TestCase
{
#[Test]
public function it_can_get_information_from_a_pure_enumeration(): void
{
self::assertFalse(Direction::isBacked());
self::assertTrue(Direction::isPure());
self::assertSame(4, Direction::size());
self::assertSame(['Top', 'Down', 'Left', 'Right'], Direction::names());
self::assertSame([], Direction::values());
self::assertNull(Direction::nameOf('Up'));
self::assertSame([Direction::Down], Direction::only(Direction::Down));
self::assertSame([Direction::Left, Direction::Right], Direction::except(Direction::Top, Direction::Down));
}
#[Test]
public function it_can_get_information_from_a_backed_enumeration(): void
{
self::assertTrue(Cardinal::isBacked());
self::assertFalse(Cardinal::isPure());
self::assertSame(4, Direction::size());
self::assertSame(['North', 'South', 'East', 'West'], Cardinal::names());
self::assertSame(['north', 'south', 'east', 'west'], Cardinal::values());
self::assertSame('West', Cardinal::nameOf('west'));
}
}
enum Direction
{
use Info;
use Convert;
case Top;
case Down;
case Left;
case Right;
}
enum Cardinal: string
{
use Info;
use Convert;
case North = 'north';
case South = 'south';
case East = 'east';
case West = 'west';
}