Skip to content

Commit

Permalink
test: add test for value-of for enum with one case
Browse files Browse the repository at this point in the history
  • Loading branch information
romm committed Jun 6, 2024
1 parent 3fb1bcd commit cb60378
Showing 1 changed file with 20 additions and 3 deletions.
23 changes: 20 additions & 3 deletions tests/Integration/Mapping/EnumValueOfMappingTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

final class EnumValueOfMappingTest extends IntegrationTestCase
{
public function test_can_map_string_enum_value_of(): void
public function test_can_map_value_of_string_enum(): void
{
try {
$result = $this->mapperBuilder()
Expand All @@ -22,7 +22,20 @@ public function test_can_map_string_enum_value_of(): void
self::assertSame(SomeStringEnumForValueOf::FOO->value, $result);
}

public function test_can_map_integer_enum_value_of(): void
public function test_can_map_value_of_enum_with_one_case(): void
{
try {
$result = $this->mapperBuilder()
->mapper()
->map('value-of<' . SomeStringEnumForValueOfWithOneCase::class . '>', SomeStringEnumForValueOf::FOO->value);
} catch (MappingError $error) {
$this->mappingFail($error);
}

self::assertSame(SomeStringEnumForValueOf::FOO->value, $result);
}

public function test_can_map_value_of_integer_enum(): void
{
try {
$result = $this->mapperBuilder()
Expand Down Expand Up @@ -66,12 +79,16 @@ enum SomeStringEnumForValueOf: string
case FOO = 'FOO';
case FOZ = 'FOZ';
case BAZ = 'BAZ';
}

enum SomeStringEnumForValueOfWithOneCase: string
{
case FOO = 'FOO';
}

enum SomeIntegerEnumForValueOf: int
{
case FOO = 42;
case FOZ = 404;
case BAZ = 1337;

}

0 comments on commit cb60378

Please sign in to comment.