Skip to content

Commit 5dc9030

Browse files
committed
wip
1 parent d84fcc6 commit 5dc9030

File tree

4 files changed

+88
-4
lines changed

4 files changed

+88
-4
lines changed

tests/ArrayableIntTest.php renamed to tests/IntBackedEnum/ArrayableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace CommitGlobal\Enums\Tests;
5+
namespace CommitGlobal\Enums\Tests\IntBackedEnum;
66

77
use CommitGlobal\Enums\Tests\Fixtures\IntBackedEnum;
88
use Orchestra\Testbench\TestCase;
99
use PHPUnit\Framework\Attributes\Test;
1010

11-
class ArrayableIntTest extends TestCase
11+
class ArrayableTest extends TestCase
1212
{
1313
#[Test]
1414
public function it_can_list_names_of_an_int_backed_enum(): void
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CommitGlobal\Enums\Tests\IntBackedEnum;
6+
7+
use CommitGlobal\Enums\Tests\Fixtures\IntBackedEnum;
8+
use Orchestra\Testbench\TestCase;
9+
use PHPUnit\Framework\Attributes\Test;
10+
11+
class ComparableTest extends TestCase
12+
{
13+
#[Test]
14+
public function it_can_compare_int_backed_enum_instances(): void
15+
{
16+
$this->assertTrue(IntBackedEnum::ONE->is(IntBackedEnum::ONE));
17+
$this->assertTrue(IntBackedEnum::TWO->is(IntBackedEnum::TWO));
18+
$this->assertTrue(IntBackedEnum::THREE->is(IntBackedEnum::THREE));
19+
$this->assertTrue(IntBackedEnum::FOUR->is(IntBackedEnum::FOUR));
20+
$this->assertTrue(IntBackedEnum::FIVE->is(IntBackedEnum::FIVE));
21+
}
22+
23+
#[Test]
24+
public function it_can_compare_int_backed_enum_values(): void
25+
{
26+
$this->assertTrue(IntBackedEnum::ONE->is(1));
27+
$this->assertTrue(IntBackedEnum::TWO->is(2));
28+
$this->assertTrue(IntBackedEnum::THREE->is(3));
29+
$this->assertTrue(IntBackedEnum::FOUR->is(4));
30+
$this->assertTrue(IntBackedEnum::FIVE->is(5));
31+
}
32+
33+
#[Test]
34+
public function it_can_compare_int_backed_enum_with_null(): void
35+
{
36+
$this->assertTrue(IntBackedEnum::ONE->isNot(null));
37+
$this->assertTrue(IntBackedEnum::TWO->isNot(null));
38+
$this->assertTrue(IntBackedEnum::THREE->isNot(null));
39+
$this->assertTrue(IntBackedEnum::FOUR->isNot(null));
40+
$this->assertTrue(IntBackedEnum::FIVE->isNot(null));
41+
}
42+
}

tests/ArrayableStringTest.php renamed to tests/StringBackedEnum/ArrayableTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22

33
declare(strict_types=1);
44

5-
namespace CommitGlobal\Enums\Tests;
5+
namespace CommitGlobal\Enums\Tests\StringBackedEnum;
66

77
use CommitGlobal\Enums\Tests\Fixtures\StringBackedEnum;
88
use Orchestra\Testbench\TestCase;
99
use PHPUnit\Framework\Attributes\Test;
1010

11-
class ArrayableStringTest extends TestCase
11+
class ArrayableTest extends TestCase
1212
{
1313
#[Test]
1414
public function it_can_list_names_of_a_string_backed_enum(): void
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace CommitGlobal\Enums\Tests\StringBackedEnum;
6+
7+
use CommitGlobal\Enums\Tests\Fixtures\StringBackedEnum;
8+
use Orchestra\Testbench\TestCase;
9+
use PHPUnit\Framework\Attributes\Test;
10+
11+
class ComparableTest extends TestCase
12+
{
13+
#[Test]
14+
public function it_can_compare_string_backed_enum_instances(): void
15+
{
16+
$this->assertTrue(StringBackedEnum::A->is(StringBackedEnum::A));
17+
$this->assertTrue(StringBackedEnum::B->is(StringBackedEnum::B));
18+
$this->assertTrue(StringBackedEnum::C->is(StringBackedEnum::C));
19+
$this->assertTrue(StringBackedEnum::D->is(StringBackedEnum::D));
20+
$this->assertTrue(StringBackedEnum::E->is(StringBackedEnum::E));
21+
}
22+
23+
#[Test]
24+
public function it_can_compare_string_backed_enum_values(): void
25+
{
26+
$this->assertTrue(StringBackedEnum::A->is('a'));
27+
$this->assertTrue(StringBackedEnum::B->is('b'));
28+
$this->assertTrue(StringBackedEnum::C->is('c'));
29+
$this->assertTrue(StringBackedEnum::D->is('d'));
30+
$this->assertTrue(StringBackedEnum::E->is('e'));
31+
}
32+
33+
#[Test]
34+
public function it_can_compare_string_backed_enum_with_null(): void
35+
{
36+
$this->assertTrue(StringBackedEnum::A->isNot(null));
37+
$this->assertTrue(StringBackedEnum::B->isNot(null));
38+
$this->assertTrue(StringBackedEnum::C->isNot(null));
39+
$this->assertTrue(StringBackedEnum::D->isNot(null));
40+
$this->assertTrue(StringBackedEnum::E->isNot(null));
41+
}
42+
}

0 commit comments

Comments
 (0)