generated from yii-tools/template
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
024f53c
commit ee0dbec
Showing
5 changed files
with
688 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Input; | ||
|
||
/** | ||
* The input element with a type attribute whose value is "reset" represents a button for resetting a form. | ||
* | ||
* @link https://www.w3.org/TR/2012/WD-html-markup-20120329/input.reset.html#input.reset | ||
*/ | ||
final class Reset extends Base\AbstractButton | ||
{ | ||
/** | ||
* This method is used to configure the widget with the provided default definitions. | ||
*/ | ||
protected function loadDefaultDefinitions(): array | ||
{ | ||
return [ | ||
'container()' => [true], | ||
'id()' => [$this->generateId('reset-')], | ||
'template()' => ['{prefix}\n{label}\n{tag}\n{suffix}'], | ||
'type()' => ['reset'], | ||
]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,313 @@ | ||
<?php | ||
|
||
declare(strict_types=1); | ||
|
||
namespace PHPForge\Html\Tests\Input\Reset; | ||
|
||
use PHPForge\Html\Input\Reset; | ||
use PHPForge\Support\Assert; | ||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* @psalm-suppress PropertyNotSetInConstructor | ||
*/ | ||
final class AttributeTest extends TestCase | ||
{ | ||
public function testAriaDescribedBy(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" aria-describedby="value"> | ||
</div> | ||
HTML, | ||
Reset::widget()->ariaDescribedBy('value')->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testAriaLabel(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" aria-label="value"> | ||
</div> | ||
HTML, | ||
Reset::widget()->ariaLabel('value')->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testAttribute(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input class="value" id="reset-6582f2d099e8b" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->attributes(['class' => 'value'])->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testAutofocus(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" autofocus> | ||
</div> | ||
HTML, | ||
Reset::widget()->autofocus()->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testClass(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input class="value" id="reset-6582f2d099e8b" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->class('value')->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testDataAttributes(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" data-value="value"> | ||
</div> | ||
HTML, | ||
Reset::widget()->dataAttributes(['value' => 'value'])->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testDisabled(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" disabled> | ||
</div> | ||
HTML, | ||
Reset::widget()->disabled()->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testForm(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" form="form"> | ||
</div> | ||
HTML, | ||
Reset::widget()->form('form')->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testGenerateAriaDescribeBy(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" aria-describedby="reset-6582f2d099e8b-help"> | ||
</div> | ||
HTML, | ||
Reset::widget()->ariaDescribedBy()->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testGenerateAriaDescribeByWithFalse(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->ariaDescribedBy(false)->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testGenerateId(): void | ||
{ | ||
$this->assertStringContainsString('id="reset-', Reset::widget()->render()); | ||
} | ||
|
||
public function testGetValue(): void | ||
{ | ||
$this->assertSame('value', Reset::widget()->value('value')->getValue()); | ||
} | ||
|
||
public function testHidden(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" hidden> | ||
</div> | ||
HTML, | ||
Reset::widget()->hidden()->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function testId(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="id" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('id')->render() | ||
); | ||
} | ||
|
||
public function testLang(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" lang="value"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->lang('value')->render() | ||
); | ||
} | ||
|
||
public function testName(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" name="value" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->name('value')->render() | ||
); | ||
} | ||
|
||
public function testReadonly(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" readonly> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->readonly()->render() | ||
); | ||
} | ||
|
||
public function testRender(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->render() | ||
); | ||
} | ||
|
||
public function style(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" style="value" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->style('value')->render() | ||
); | ||
} | ||
|
||
public function testTabIndex(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" tabindex="1"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->tabIndex(1)->render() | ||
); | ||
} | ||
|
||
public function testTitle(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" title="value"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->title('value')->render() | ||
); | ||
} | ||
|
||
public function testType(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->type('reset')->render() | ||
); | ||
} | ||
|
||
public function testValue(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset" value="value"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->value('value')->render() | ||
); | ||
} | ||
|
||
public function testValueWithNull(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->value(null)->render() | ||
); | ||
} | ||
|
||
public function testWithoutId(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id(null)->render() | ||
); | ||
} | ||
|
||
public function testWithoutName(): void | ||
{ | ||
Assert::equalsWithoutLE( | ||
<<<HTML | ||
<div> | ||
<input id="reset-6582f2d099e8b" type="reset"> | ||
</div> | ||
HTML, | ||
Reset::widget()->id('reset-6582f2d099e8b')->name(null)->render() | ||
); | ||
} | ||
} |
Oops, something went wrong.