Skip to content

Commit 06bbbdb

Browse files
feat(attribute): Add Autocomplete enum and update AutocompleteProvider for add test data. (#77)
1 parent 302c992 commit 06bbbdb

File tree

3 files changed

+34
-16
lines changed

3 files changed

+34
-16
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@
4747
- Bug #74: Remove directory `tests\Stub` and move `tests\Support\Provider` to `tests\Provider` in tests (@terabytesoftw)
4848
- Bug #75: Standardize PHPDoc headers for test classes (@terabytesoftw)
4949
- Bug #76: Move `HasDisabled` trait to `UIAwesome\Html\Attribute` namespace and update related imports accordingly (@terabytesoftw)
50+
- Enh #77: Add `Autocomplete` enum and update `AutocompleteProvider` to add test data (@terabytesoftw)
5051

5152
## 0.5.2 January 29, 2026
5253

src/Values/Autocomplete.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace UIAwesome\Html\Attribute\Values;
6+
7+
/**
8+
* Represents values for the HTML `autocomplete` attribute.
9+
*
10+
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Attributes/autocomplete
11+
*
12+
* @copyright Copyright (C) 2026 Terabytesoftw.
13+
* @license https://opensource.org/license/bsd-3-clause BSD 3-Clause License.
14+
*/
15+
enum Autocomplete: string
16+
{
17+
/**
18+
* `off` - Browser is not permitted to automatically enter or select a value for this field.
19+
*/
20+
case OFF = 'off';
21+
22+
/**
23+
* `on` - Browser is permitted to automatically complete values for this field.
24+
*/
25+
case ON = 'on';
26+
}

tests/Provider/Form/AutocompleteProvider.php

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

55
namespace UIAwesome\Html\Attribute\Tests\Provider\Form;
66

7-
use PHPForge\Support\Stub\{BackedString, Unit};
7+
use PHPForge\Support\EnumDataProvider;
88
use Stringable;
9+
use UIAwesome\Html\Attribute\Values\{Attribute, Autocomplete};
910
use UnitEnum;
1011

1112
/**
@@ -26,35 +27,23 @@ final class AutocompleteProvider
2627
*/
2728
public static function values(): array
2829
{
30+
$enumCases = EnumDataProvider::attributeCases(Autocomplete::class, Attribute::AUTOCOMPLETE);
31+
2932
$stringable = new class implements Stringable {
3033
public function __toString(): string
3134
{
3235
return 'email';
3336
}
3437
};
3538

36-
return [
39+
$staticCases = [
3740
'empty string' => [
3841
'',
3942
[],
4043
'',
4144
'',
4245
'Should return an empty string when setting an empty string.',
4346
],
44-
'enum backed string' => [
45-
BackedString::VALUE,
46-
[],
47-
BackedString::VALUE,
48-
' autocomplete="value"',
49-
'Should return the attribute value after setting it.',
50-
],
51-
'enum unit' => [
52-
Unit::value,
53-
[],
54-
Unit::value,
55-
' autocomplete="value"',
56-
'Should return the attribute value after setting it.',
57-
],
5847
'null' => [
5948
null,
6049
[],
@@ -91,5 +80,7 @@ public function __toString(): string
9180
"Should unset the 'autocomplete' attribute when 'null' is provided after a value.",
9281
],
9382
];
83+
84+
return [...$enumCases, ...$staticCases];
9485
}
9586
}

0 commit comments

Comments
 (0)