Skip to content

Commit

Permalink
Add input attributes and tests. (#155)
Browse files Browse the repository at this point in the history
  • Loading branch information
terabytesoftw committed Dec 19, 2023
1 parent 61fe6e8 commit d02cf56
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Base/AbstractInput.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,10 @@ abstract class AbstractInput extends Element
use Attribute\HasStyle;
use Attribute\HasTabindex;
use Attribute\HasTitle;
use Attribute\Input\CanBeDisabled;
use Attribute\Input\CanBeReadonly;
use Attribute\Input\CanBeRequired;
use Attribute\Input\HasForm;
use Attribute\Input\HasName;
use Attribute\Input\HasType;
use Attribute\Input\HasValue;
Expand Down
40 changes: 40 additions & 0 deletions tests/Input/RenderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,30 @@ public function testClass(): void
);
}

public function testDataAttributes(): void
{
$this->assertSame(
'<input data-test="test-value">',
Input::widget()->dataAttributes(['test' => 'test-value'])->render(),
);
}

public function testDisabled(): void
{
$this->assertSame(
'<input disabled>',
Input::widget()->disabled()->render(),
);
}

public function testForm(): void
{
$this->assertSame(
'<input form="test-form">',
Input::widget()->form('test-form')->render(),
);
}

public function testHidden(): void
{
$this->assertSame(
Expand Down Expand Up @@ -176,6 +200,22 @@ public function testPrefixAndTypeRadio(): void
);
}

public function testReadonly(): void
{
$this->assertSame(
'<input readonly>',
Input::widget()->readonly()->render(),
);
}

public function testRequired(): void
{
$this->assertSame(
'<input required>',
Input::widget()->required()->render(),
);
}

public function testStyle(): void
{
$this->assertSame(
Expand Down

0 comments on commit d02cf56

Please sign in to comment.