Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
- Enh #51: Add `InputDate` class for HTML `<input type="date">` element with attributes and rendering capabilities (@terabytesoftw)
- Enh #52: Add `InputColor` class for HTML `<input type="color">` element with attributes and rendering capabilities (@terabytesoftw)
- Enh #53: Add `TextArea` class for HTML `<textarea>` element with attributes and rendering capabilities (@terabytesoftw)
- Bug #54: Update exception test method names for consistency and clarity (@terabytesoftw)

## 0.3.0 March 31, 2024

Expand Down
2 changes: 1 addition & 1 deletion src/Form/Values/Capture.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace UIAwesome\Html\Form\Values;

/**
* Represents the values for the HTML `capture` attribute.
* Represents values for the HTML `capture` attribute.
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Attributes/capture
*
Expand Down
2 changes: 1 addition & 1 deletion src/Form/Values/Colorspace.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
namespace UIAwesome\Html\Form\Values;

/**
* Represents the values for the HTML `colorspace` attribute.
* Represents values for the HTML `colorspace` attribute.
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/input/color#colorspace
*
Expand Down
8 changes: 1 addition & 7 deletions src/Metadata/Values/ShadowRootMode.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,7 @@
namespace UIAwesome\Html\Metadata\Values;

/**
* Represents tokens for the HTML `shadowrootmode` attribute.
*
* Usage example:
* ```php
* $mode = \UIAwesome\Html\Metadata\Values\ShadowRootMode::OPEN;
* echo $mode->value;
* ```
* Represents values for the HTML `shadowrootmode` attribute.
*
* @link https://developer.mozilla.org/en-US/docs/Web/HTML/Reference/Elements/template#shadowrootmode
*
Expand Down
56 changes: 39 additions & 17 deletions tests/Embedded/ImgTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,12 @@
use PHPUnit\Framework\TestCase;
use UIAwesome\Html\Attribute\Values\{
Aria,
Attribute,
Crossorigin,
Data,
Decoding,
Direction,
ElementAttribute,
Fetchpriority,
GlobalAttribute,
Language,
Expand All @@ -24,6 +26,8 @@
};
use UIAwesome\Html\Core\Factory\SimpleFactory;
use UIAwesome\Html\Embedded\Img;
use UIAwesome\Html\Helper\Enum;
use UIAwesome\Html\Helper\Exception\Message;
use UIAwesome\Html\Tests\Support\Stub\{DefaultProvider, DefaultThemeProvider};

/**
Expand Down Expand Up @@ -907,55 +911,73 @@ public function testReturnNewInstanceWhenSettingAttribute(): void
);
}

public function testThrowInvalidArgumentExceptionWhenInvalidCrossorigin(): void
public function testThrowInvalidArgumentExceptionWhenSettingCrossorigin(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
"Value 'invalid' is not in the list of valid values for 'crossorigin': 'anonymous', 'use-credentials'.",
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
Attribute::CROSSORIGIN->value,
implode("', '", Enum::normalizeArray(Crossorigin::cases())),
),
);

Img::tag()->crossorigin('invalid');
Img::tag()->crossorigin('invalid-value');
}

public function testThrowInvalidArgumentExceptionWhenInvalidDecoding(): void
public function testThrowInvalidArgumentExceptionWhenSettingDecoding(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
"Value 'invalid' is not in the list of valid values for 'decoding': 'async', 'auto', 'sync'.",
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
ElementAttribute::DECODING->value,
implode("', '", Enum::normalizeArray(Decoding::cases())),
),
);

Img::tag()->decoding('invalid');
Img::tag()->decoding('invalid-value');
}

public function testThrowInvalidArgumentExceptionWhenInvalidFetchpriority(): void
public function testThrowInvalidArgumentExceptionWhenSettingFetchpriority(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
"Value 'invalid' is not in the list of valid values for 'fetchpriority': 'auto', 'high', 'low'.",
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
Attribute::FETCHPRIORITY->value,
implode("', '", Enum::normalizeArray(Fetchpriority::cases())),
),
);

Img::tag()->fetchpriority('invalid');
Img::tag()->fetchpriority('invalid-value');
}

public function testThrowInvalidArgumentExceptionWhenInvalidLoading(): void
public function testThrowInvalidArgumentExceptionWhenSettingLoading(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
"Value 'invalid' is not in the list of valid values for 'loading': 'eager', 'lazy'.",
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
ElementAttribute::LOADING->value,
implode("', '", Enum::normalizeArray(Loading::cases())),
),
);

Img::tag()->loading('invalid');
Img::tag()->loading('invalid-value');
}

public function testThrowInvalidArgumentExceptionWhenInvalidReferrerpolicy(): void
public function testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
"Value 'invalid' is not in the list of valid values for 'referrerpolicy': "
. "'no-referrer', 'no-referrer-when-downgrade', 'origin', 'origin-when-cross-origin', "
. "'same-origin', 'strict-origin', 'strict-origin-when-cross-origin', 'unsafe-url'.",
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
Attribute::REFERRERPOLICY->value,
implode("', '", Enum::normalizeArray(Referrerpolicy::cases())),
),
);

Img::tag()->referrerpolicy('invalid');
Img::tag()->referrerpolicy('invalid-value');
}
}
2 changes: 1 addition & 1 deletion tests/Form/InputColorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -983,7 +983,7 @@ public function testReturnNewInstanceWhenSettingAttribute(): void
);
}

public function testThrowInvalidArgumentExceptionForSettingColorspace(): void
public function testThrowInvalidArgumentExceptionWhenSettingColorspace(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Expand Down
6 changes: 3 additions & 3 deletions tests/Form/TextAreaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,7 @@ public function testReturnNewInstanceWhenSettingAttribute(): void
);
}

public function testThrowInvalidArgumentExceptionForSettingCols(): void
public function testThrowInvalidArgumentExceptionWhenSettingCols(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Expand All @@ -1020,7 +1020,7 @@ public function testThrowInvalidArgumentExceptionForSettingCols(): void
TextArea::tag()->cols(0);
}

public function testThrowInvalidArgumentExceptionForSettingRows(): void
public function testThrowInvalidArgumentExceptionWhenSettingRows(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Expand All @@ -1034,7 +1034,7 @@ public function testThrowInvalidArgumentExceptionForSettingRows(): void
TextArea::tag()->rows(0);
}

public function testThrowInvalidArgumentExceptionForSettingWrap(): void
public function testThrowInvalidArgumentExceptionWhenSettingWrap(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Expand Down
16 changes: 13 additions & 3 deletions tests/Metadata/BaseTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,17 @@
use InvalidArgumentException;
use PHPUnit\Framework\Attributes\Group;
use PHPUnit\Framework\TestCase;
use UIAwesome\Html\Attribute\Values\{Aria, Data, Direction, GlobalAttribute, Language, Role, Target, Translate};
use UIAwesome\Html\Attribute\Values\{
Aria,
Attribute,
Data,
Direction,
GlobalAttribute,
Language,
Role,
Target,
Translate,
};
use UIAwesome\Html\Core\Factory\SimpleFactory;
use UIAwesome\Html\Helper\Enum;
use UIAwesome\Html\Helper\Exception\Message;
Expand Down Expand Up @@ -581,13 +591,13 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
);
}

public function testThrowInvalidArgumentExceptionForSettingTarget(): void
public function testThrowInvalidArgumentExceptionWhenSettingTarget(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'target',
Attribute::TARGET->value,
implode("', '", Enum::normalizeArray(Target::cases())),
),
);
Expand Down
17 changes: 9 additions & 8 deletions tests/Metadata/LinkTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use UIAwesome\Html\Attribute\Values\{
Aria,
AsValue,
Attribute,
Blocking,
Crossorigin,
Data,
Expand Down Expand Up @@ -845,55 +846,55 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
);
}

public function testThrowInvalidArgumentExceptionForSettingBlocking(): void
public function testThrowInvalidArgumentExceptionWhenSettingBlocking(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'blocking',
Attribute::BLOCKING->value,
implode("', '", Enum::normalizeArray(Blocking::cases())),
),
);

Link::tag()->blocking('invalid-value');
}

public function testThrowInvalidArgumentExceptionForSettingCrossorigin(): void
public function testThrowInvalidArgumentExceptionWhenSettingCrossorigin(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'crossorigin',
Attribute::CROSSORIGIN->value,
implode("', '", Enum::normalizeArray(Crossorigin::cases())),
),
);

Link::tag()->crossorigin('invalid-value');
}

public function testThrowInvalidArgumentExceptionForSettingFetchpriority(): void
public function testThrowInvalidArgumentExceptionWhenSettingFetchpriority(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'fetchpriority',
Attribute::FETCHPRIORITY->value,
implode("', '", Enum::normalizeArray(Fetchpriority::cases())),
),
);

Link::tag()->fetchpriority('invalid-value');
}

public function testThrowInvalidArgumentExceptionForSettingReferrerpolicy(): void
public function testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'referrerpolicy',
Attribute::REFERRERPOLICY->value,
implode("', '", Enum::normalizeArray(Referrerpolicy::cases())),
),
);
Expand Down
5 changes: 3 additions & 2 deletions tests/Metadata/MetaTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPUnit\Framework\TestCase;
use UIAwesome\Html\Attribute\Values\{
Aria,
Attribute,
Charset,
Data,
Direction,
Expand Down Expand Up @@ -641,13 +642,13 @@ public function testRenderWithUserOverridesGlobalDefaults(): void
);
}

public function testThrowInvalidArgumentExceptionForSettingHttpEquiv(): void
public function testThrowInvalidArgumentExceptionWhenSettingHttpEquiv(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'http-equiv',
Attribute::HTTP_EQUIV->value,
implode("', '", Enum::normalizeArray(HttpEquiv::cases())),
),
);
Expand Down
17 changes: 9 additions & 8 deletions tests/Metadata/ScriptTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use PHPUnit\Framework\TestCase;
use UIAwesome\Html\Attribute\Values\{
Aria,
Attribute,
Blocking,
ContentEditable,
Crossorigin,
Expand Down Expand Up @@ -1034,55 +1035,55 @@ public function testReturnNewInstanceWhenSettingAttribute(): void
);
}

public function testThrowInvalidArgumentExceptionForSettingBlocking(): void
public function testThrowInvalidArgumentExceptionWhenSettingBlocking(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'blocking',
Attribute::BLOCKING->value,
implode("', '", Enum::normalizeArray(Blocking::cases())),
),
);

Script::tag()->blocking('invalid-value');
}

public function testThrowInvalidArgumentExceptionForSettingCrossorigin(): void
public function testThrowInvalidArgumentExceptionWhenSettingCrossorigin(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'crossorigin',
Attribute::CROSSORIGIN->value,
implode("', '", Enum::normalizeArray(Crossorigin::cases())),
),
);

Script::tag()->crossorigin('invalid-value');
}

public function testThrowInvalidArgumentExceptionForSettingFetchpriority(): void
public function testThrowInvalidArgumentExceptionWhenSettingFetchpriority(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'fetchpriority',
Attribute::FETCHPRIORITY->value,
implode("', '", Enum::normalizeArray(Fetchpriority::cases())),
),
);

Script::tag()->fetchpriority('invalid-value');
}

public function testThrowInvalidArgumentExceptionForSettingReferrerpolicy(): void
public function testThrowInvalidArgumentExceptionWhenSettingReferrerpolicy(): void
{
$this->expectException(InvalidArgumentException::class);
$this->expectExceptionMessage(
Message::VALUE_NOT_IN_LIST->getMessage(
'invalid-value',
'referrerpolicy',
Attribute::REFERRERPOLICY->value,
implode("', '", Enum::normalizeArray(Referrerpolicy::cases())),
),
);
Expand Down
Loading
Loading