Skip to content

Commit

Permalink
Fix input attribute case sensitivity. (#221)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Jan 11, 2024
1 parent 92bbb6e commit 2fb9add
Show file tree
Hide file tree
Showing 8 changed files with 41 additions and 17 deletions.
8 changes: 3 additions & 5 deletions infection.json.dist
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,12 @@
"PHPForge\\Html\\Attribute\\HasId::id",
"PHPForge\\Html\\Attribute\\Input\\CanBeChecked::checked",
"PHPForge\\Html\\Attribute\\Input\\CanBeRequired::required",
"PHPForge\\Html\\Attribute\\Input\\HasMaxLength::maxLength",
"PHPForge\\Html\\Attribute\\Input\\HasMinLength::minLength",
"PHPForge\\Html\\Attribute\\Input\\HasMaxLength::maxlength",
"PHPForge\\Html\\Attribute\\Input\\HasMinLength::minlength",
"PHPForge\\Html\\Attribute\\Input\\HasName::name",
"PHPForge\\Html\\Attribute\\Input\\HasPattern::pattern",
"PHPForge\\Html\\Attribute\\Input\\HasPlaceholder::placeholder",
"PHPForge\\Html\\Attribute\\Input\\HasValue::value",
"PHPForge\\Html\\Input\\Text::maxLength()",
"PHPForge\\Html\\Input\\Text::minLength()"
"PHPForge\\Html\\Attribute\\Input\\HasValue::value"
]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Input/HasMaxLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ trait HasMaxLength
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-maxlength
*/
public function maxLength(int $value): static
public function maxlength(int $value): static
{
$new = clone $this;
$new->attributes['maxlength'] = $value;
Expand Down
2 changes: 1 addition & 1 deletion src/Attribute/Input/HasMinLength.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ trait HasMinLength
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-minlength
*/
public function minLength(int $value): static
public function minlength(int $value): static
{
$new = clone $this;
$new->attributes['minlength'] = $value;
Expand Down
10 changes: 5 additions & 5 deletions src/Base/AbstractSelect.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@
namespace PHPForge\Html\Base;

use InvalidArgumentException;
use PHPForge\Html\Attribute;
use PHPForge\Html\Input\Contract\InputInterface;
use PHPForge\Html\Label;
use PHPForge\Html\Tag;
use PHPForge\Html\Input\Contract\{InputInterface, RequiredInterface};
use PHPForge\Html\{Attribute, Label, Tag};
use PHPForge\Widget\Element;

use Stringable;
Expand All @@ -24,7 +22,7 @@
/**
* Provides a foundation for creating HTML `select` elements with various attributes and content.
*/
abstract class AbstractSelect extends Element implements InputInterface
abstract class AbstractSelect extends Element implements InputInterface, RequiredInterface
{
use Attribute\Aria\HasAriaLabel;
use Attribute\CanBeAutofocus;
Expand All @@ -34,7 +32,9 @@ abstract class AbstractSelect extends Element implements InputInterface
use Attribute\HasClass;
use Attribute\HasId;
use Attribute\HasTabindex;
use Attribute\Input\CanBeDisabled;
use Attribute\Input\CanBeMultiple;
use Attribute\Input\CanBeRequired;
use Attribute\Input\HasName;
use Attribute\Input\HasSize;
use Attribute\Input\HasValue;
Expand Down
4 changes: 2 additions & 2 deletions src/Input/Contract/LengthInterface.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ interface LengthInterface
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-maxlength
*/
public function maxLength(int $value): static;
public function maxlength(int $value): static;

/**
* Set the minimum number of characters (as UTF-16 code units) the user can enter into the text input.
Expand All @@ -36,5 +36,5 @@ public function maxLength(int $value): static;
*
* @link https://html.spec.whatwg.org/multipage/input.html#attr-input-minlength
*/
public function minLength(int $value): static;
public function minlength(int $value): static;
}
4 changes: 2 additions & 2 deletions tests/Input/Text/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@ public function testMaxLength(): void
<<<HTML
<input id="text-6582f2d099e8b" type="text" maxlength="1">
HTML,
Text::widget()->id('text-6582f2d099e8b')->maxLength(1)->render()
Text::widget()->id('text-6582f2d099e8b')->maxlength(1)->render()
);
}

Expand All @@ -169,7 +169,7 @@ public function testMinLength(): void
<<<HTML
<input id="text-6582f2d099e8b" type="text" minlength="1">
HTML,
Text::widget()->id('text-6582f2d099e8b')->minLength(1)->render()
Text::widget()->id('text-6582f2d099e8b')->minlength(1)->render()
);
}

Expand Down
26 changes: 26 additions & 0 deletions tests/Select/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,19 @@ public function testAutofocus(): void
);
}

public function testDisabled(): void
{
Assert::equalsWithoutLE(
<<<HTML
<select disabled>
<option>Select an option</option>
<option value="1">Moscu</option>
</select>
HTML,
Select::widget()->items([1 => 'Moscu'])->disabled()->render(),
);
}

public function testElement(): void
{
Assert::equalsWithoutLE(
Expand Down Expand Up @@ -259,6 +272,19 @@ public function testPrompt(): void
);
}

public function testRequired(): void
{
Assert::equalsWithoutLE(
<<<HTML
<select required>
<option>Select an option</option>
<option value="1">Moscu</option>
</select>
HTML,
Select::widget()->items([1 => 'Moscu'])->required()->render(),
);
}

public function testSuffix(): void
{
Assert::equalsWithoutLE(
Expand Down
2 changes: 1 addition & 1 deletion tests/TextArea/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public function testMaxLength(): void

public function testMinLength(): void
{
$this->assertSame('<textarea minlength="1"></textarea>', TextArea::widget()->minLength(1)->render());
$this->assertSame('<textarea minlength="1"></textarea>', TextArea::widget()->minlength(1)->render());
}

public function testName(): void
Expand Down

0 comments on commit 2fb9add

Please sign in to comment.