Skip to content

Commit edf6235

Browse files
feat(stub): Add enums for backed integer, backed string, and unit values in the Stub namespace. (#24)
1 parent be49ce8 commit edf6235

File tree

10 files changed

+91
-88
lines changed

10 files changed

+91
-88
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
- Enh #22: Add `php-forge/coding-standard` to development dependencies for code quality checks (@terabytesoftw)
66
- Bug #23: Update Rector command in `composer.json` to remove unnecessary 'src' argument (@terabytesoftw)
7+
- Enh #24: Add enums for backed integer, backed string, and unit values in the `Stub` namespace (@terabytesoftw)
78

89
## 0.3.1 January 20, 2026
910

src/ReflectionHelper.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
*/
3030
final class ReflectionHelper
3131
{
32-
private function __construct() {}
33-
3432
/**
3533
* Retrieves a property value from a specified class context.
3634
*

src/Stub/BackedInteger.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PHPForge\Support\Stub;
6+
7+
/**
8+
* Stub enum for backed integer values.
9+
*
10+
* Provides deterministic values required by the test suite.
11+
*
12+
* @copyright Copyright (C) 2026 Terabytesoftw.
13+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
14+
*/
15+
enum BackedInteger: int
16+
{
17+
/**
18+
* Type representing a value.
19+
*/
20+
case VALUE = 1;
21+
}

src/Stub/BackedString.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PHPForge\Support\Stub;
6+
7+
/**
8+
* Stub enum for backed string values.
9+
*
10+
* Provides deterministic values required by the test suite.
11+
*
12+
* @copyright Copyright (C) 2026 Terabytesoftw.
13+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
14+
*/
15+
enum BackedString: string
16+
{
17+
/**
18+
* Type representing a value.
19+
*/
20+
case VALUE = 'value';
21+
}

src/Stub/Unit.php

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace PHPForge\Support\Stub;
6+
7+
/**
8+
* Stub enum for unit values.
9+
*
10+
* Provides deterministic values required by the test suite.
11+
*
12+
* @copyright Copyright (C) 2026 Terabytesoftw.
13+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
14+
*/
15+
enum Unit
16+
{
17+
/**
18+
* Type representing a value.
19+
*/
20+
case value;
21+
}

tests/EnumDataProviderTest.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
namespace PHPForge\Support\Tests;
66

77
use PHPForge\Support\EnumDataProvider;
8-
use PHPForge\Support\Tests\Stub\TestEnum;
8+
use PHPForge\Support\Stub\BackedInteger;
99
use PHPForge\Support\Tests\Support\Provider\EnumDataProviderProvider;
1010
use PHPUnit\Framework\Attributes\{DataProviderExternal, Group};
1111
use PHPUnit\Framework\TestCase;
@@ -76,21 +76,17 @@ public function testCasesGenerateExpectedStructure(
7676

7777
public function testTagCasesGenerateExpectedStructure(): void
7878
{
79-
$data = EnumDataProvider::tagCases(TestEnum::class, 'element');
79+
$data = EnumDataProvider::tagCases(BackedInteger::class, 'element');
8080

8181
self::assertNotEmpty(
8282
$data,
8383
'Should return at least one data set.',
8484
);
8585
self::assertSame(
8686
[
87-
'BAR element tag' => [
88-
TestEnum::BAR,
89-
'BAR',
90-
],
91-
'FOO element tag' => [
92-
TestEnum::FOO,
93-
'FOO',
87+
'1 element tag' => [
88+
BackedInteger::VALUE,
89+
1 => '1',
9490
],
9591
],
9692
$data,

tests/Stub/TestBackedEnum.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/Stub/TestEnum.php

Lines changed: 0 additions & 18 deletions
This file was deleted.

tests/Stub/TestIntBackedEnum.php

Lines changed: 0 additions & 19 deletions
This file was deleted.

tests/Support/Provider/EnumDataProviderProvider.php

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44

55
namespace PHPForge\Support\Tests\Support\Provider;
66

7-
use PHPForge\Support\Tests\Stub\TestEnum;
7+
use PHPForge\Support\Stub\{BackedInteger, BackedString, Unit};
8+
use UnitEnum;
89

910
/**
1011
* Data provider for {@see \PHPForge\Support\Tests\EnumDataProviderTest} test cases.
@@ -17,34 +18,34 @@
1718
final class EnumDataProviderProvider
1819
{
1920
/**
20-
* @return array<string, array{string, string|\UnitEnum, bool, string, string, string}>
21+
* @return array<string, array{string, string|UnitEnum, bool, string, string, string}>
2122
*/
2223
public static function casesParameters(): array
2324
{
2425
return [
25-
'as enum instance' => [
26-
TestEnum::class,
27-
'data-test',
28-
false,
29-
'enum: FOO',
30-
' data-test="FOO"',
31-
"Should return the 'data-test' attribute value for enum case: FOO.",
26+
'enum backed integer instance' => [
27+
BackedInteger::class,
28+
BackedInteger::VALUE,
29+
true,
30+
'enum: 1',
31+
' 1="1"',
32+
"Should return the '1' attribute value for enum case: 1.",
3233
],
33-
'as html' => [
34-
TestEnum::class,
34+
'enum backed string instance' => [
35+
BackedString::class,
3536
'data-test',
3637
true,
37-
'enum: BAR',
38-
' data-test="BAR"',
39-
"Should return the 'data-test' attribute value for enum case: BAR.",
38+
'enum: value',
39+
' data-test="value"',
40+
"Should return the 'data-test' attribute value for enum case: value.",
4041
],
41-
'attribute as enum instance' => [
42-
TestEnum::class,
43-
TestEnum::FOO,
44-
true,
45-
'enum: FOO',
46-
' FOO="FOO"',
47-
"Should return the 'FOO' attribute value for enum case: FOO.",
42+
'enum unit instance' => [
43+
Unit::class,
44+
'data-test',
45+
false,
46+
'enum: value',
47+
' data-test="value"',
48+
"Should return the 'data-test' attribute value for enum case: value.",
4849
],
4950
];
5051
}

0 commit comments

Comments
 (0)