'); + $this->assertSelectorAttribute($form, 'form', 'role', 'main'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'marquee'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'math'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'menu'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'menubar'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'menuitem'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'menuitemcheckbox'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'menuitemradio'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'navigation'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'note'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'option'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'presentation'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'progressbar'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'radio'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'radiogroup'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'region'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'row'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'rowgroup'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'rowheader'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'scrollbar'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'search'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'separator'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'slider'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'spinbutton'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'status'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'tab'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'tablist'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'tabpanel'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'textbox'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'timer'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'toolbar'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'tooltip'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'tree'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'treegrid'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'role', 'treeitem'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'role'); + } + + public function test_spell_check_boolean_can_be_set_to_true_and_false_and_be_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'spellcheck', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'spellcheck', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'spellcheck'); + } + + public function test_style_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'style', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'style'); + } + + public function test_tab_index_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'tabindex', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'tabindex'); + } + + public function test_title_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'title', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'title'); + } + + public function test_aria_active_descendant_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'aria-activedescendant', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-activedescendant'); + } + + public function test_aria_atomic_boolean_can_be_set_to_true_and_false_and_be_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-atomic', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-atomic', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-atomic'); + } + + public function test_aria_busy_boolean_can_be_set_to_true_and_false_and_be_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-busy', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-busy', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-busy'); + } + + public function test_aria_controls_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'aria-controls', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-controls'); + } + + public function test_aria_described_by_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'aria-describedby', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-describedby'); + } + + public function test_aria_disabled_attribute_can_be_set_and_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-disabled', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-disabled', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-disabled'); + } + + public function test_aria_drop_effect_attribute_can_be_set_and_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-dropeffect', 'copy'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-dropeffect', 'move'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-dropeffect', 'link'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-dropeffect', 'execute'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-dropeffect', 'popup'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-dropeffect', 'none'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-dropeffect'); + } + + public function test_aria_flow_to_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'aria-flowto', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-flowto'); + } + + public function test_aria_grabbed_attribute_can_be_set_and_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-grabbed', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-grabbed', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-grabbed', 'undefined'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-grabbed'); + } + + public function test_aria_has_popup_boolean_can_be_set_to_true_and_false_and_be_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-haspopup', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-haspopup', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-haspopup'); + } + + public function test_aria_hidden_boolean_can_be_set_to_true_and_false_and_be_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-hidden', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-hidden', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-hidden'); + } + + public function test_aria_invalid_attribute_can_be_set_and_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-invalid', 'grammar'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-invalid', 'false'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-invalid', 'spelling'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-invalid', 'true'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-invalid'); + } + + public function test_aria_label_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'aria-label', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-label'); + } + + public function test_aria_labelled_by_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'aria-labelledby', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-labelledby'); + } + + public function test_aria_live_attribute_can_be_set_and_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-live', 'off'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-live', 'polite'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-live', 'assertive'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-live'); + } + + public function test_aria_owns_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $form = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($form, 'form', 'aria-owns', $value); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-owns'); + } + + public function test_aria_relevant_attribute_can_be_set_and_unset() : void + { + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-relevant', 'additions'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-relevant', 'removals'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-relevant', 'text'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-relevant', 'all'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttribute($form, 'form', 'aria-relevant', 'additions text'); + + $form = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($form, 'form', 'aria-relevant'); + } + +} diff --git a/tests/Components/HiddenTest.php b/tests/Components/HiddenTest.php new file mode 100644 index 0000000..7990ab6 --- /dev/null +++ b/tests/Components/HiddenTest.php @@ -0,0 +1,8 @@ +renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'text/html'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'text/plain'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'application/msword'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'application/msexcel'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'application/postscript'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'application/x-zip-compressed'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'application/pdf'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'application/rtf'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'video/x-msvideo'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'video/quicktime'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'video/x-mpeg2'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'audio/x-pn/realaudio'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'audio/x-mpeg'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'audio/x-waw'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'audio/x-aiff'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'audio/basic'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/tiff'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/jpeg'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/gif'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/x-png'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/x-photo-cd'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/x-MS-bmp'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/x-rgb'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/x-portable-pixmap'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/x-portable-greymap'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'accept', 'image/x-portablebitmap'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'accept'); + } + + public function test_alt_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'alt', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'alt'); + } + + public function test_auto_complete_attribute_can_be_set_and_unset() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'additional-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'address-level1'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'address-level2'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'address-level3'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'address-level4'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'address-line1'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'address-line2'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'address-line3'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'bday'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'bday-year'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'bday-day'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'bday-month'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'billing'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-additional-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-csc'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-exp'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-exp-month'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-exp-year'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-family-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-given-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-number'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'cc-type'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'country'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'country-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'current-password'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'email'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'family-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'fax'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'given-name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'home'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'honorific-prefix'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'honorific-suffix'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'impp'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'language'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'mobile'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'name'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'new-password'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'nickname'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'off'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'on'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'organization'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'organization-title'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'pager'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'photo'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'postal-code'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'sex'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'shipping'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'street-address'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel-area-code'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel-country-code'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel-extension'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel-local'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel-local-prefix'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel-local-suffix'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'tel-national'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'transaction-amount'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'transaction-currency'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'url'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'username'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autocomplete', 'work'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'autocomplete'); + } + + public function test_auto_focus_flag_can_be_set_on_and_off() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'autofocus'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'autofocus'); + } + + public function test_checked_flag_can_be_set_on_and_off() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'checked'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'checked'); + } + + public function test_dir_name_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'dirname', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'dirname'); + } + + public function test_disabled_flag_can_be_set_on_and_off() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'disabled'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'disabled'); + } + + public function test_form_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'form', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'form'); + } + + public function test_form_action_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'formaction', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'formaction'); + } + + public function test_form_enc_type_attribute_can_be_set_and_unset() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formenctype', 'application/x-www-form-urlencoded'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formenctype', 'multipart/form-data'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formenctype', 'text/plain'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'formenctype'); + } + + public function test_form_method_attribute_can_be_set_and_unset() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formmethod', 'get'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formmethod', 'post'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'formmethod'); + } + + public function test_form_no_validate_flag_can_be_set_on_and_off() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formnovalidate'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'formnovalidate'); + } + + public function test_form_target_attribute_can_be_set_and_unset() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formtarget', '_blank'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formtarget', '_parent'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formtarget', '_self'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'formtarget', '_top'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'formtarget'); + } + + public function test_height_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'height', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'height'); + } + + public function test_list_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'list', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'list'); + } + + public function test_max_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'max', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'max'); + } + + public function test_max_length_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'maxlength', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'maxlength'); + } + + public function test_min_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'min', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'min'); + } + + public function test_multiple_flag_can_be_set_on_and_off() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'multiple'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'multiple'); + } + + public function test_name_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'name', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'name'); + } + + public function test_pattern_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'pattern', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'pattern'); + } + + public function test_placeholder_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'placeholder', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'placeholder'); + } + + public function test_read_only_flag_can_be_set_on_and_off() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'readonly'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'readonly'); + } + + public function test_required_flag_can_be_set_on_and_off() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'required'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'required'); + } + + public function test_size_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'size', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'size'); + } + + public function test_src_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'src', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'src'); + } + + public function test_step_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'step', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'step'); + } + + public function test_type_attribute_can_be_set_and_unset() : void + { + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'button'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'checkbox'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'color'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'date'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'datetime'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'datetime-local'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'email'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'file'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'hidden'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'image'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'month'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'number'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'password'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'radio'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'range'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'reset'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'search'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'submit'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'tel'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'text'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'time'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'url'); + + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', 'week'); + } + + public function test_value_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'value', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'value'); + } + + public function test_width_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $input = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($input, 'input', 'width', $value); + + $input = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($input, 'input', 'width'); + } + +} diff --git a/tests/Components/InputTypeTestCase.php b/tests/Components/InputTypeTestCase.php new file mode 100644 index 0000000..e241700 --- /dev/null +++ b/tests/Components/InputTypeTestCase.php @@ -0,0 +1,23 @@ +inputType(); + $input = $this->renderBlade(''); + $this->assertSelectorAttribute($input, 'input', 'type', $type); + } + + protected function inputType() + { + return Str::of(static::class) + ->afterLast('\\') + ->before('Test') + ->lower(); + } +} diff --git a/tests/Components/MonthTest.php b/tests/Components/MonthTest.php new file mode 100644 index 0000000..54253a3 --- /dev/null +++ b/tests/Components/MonthTest.php @@ -0,0 +1,8 @@ + + '; + + $form = $this->renderBlade($blade, ['keyup' => 'doKeyUp()', 'click' => 'doClick()']); + + $this->assertSelectorAttribute($form, 'form', 'x-data', '{ open: true }'); + $this->assertSelectorAttribute($form, 'form', 'x-init', 'baz'); + $this->assertSelectorAttribute($form, 'form', 'x-show.transition.in.duration.200ms.out.duration.50ms', '!open'); + $this->assertSelectorAttribute($form, 'form', 'x-bind:type', 'input_type'); + $this->assertSelectorAttribute($form, 'form', 'x-bind:view-box.camel', 'viewBox'); + $this->assertSelectorAttribute($form, 'form', 'x-on:click', 'open = true'); + $this->assertSelectorAttribute($form, 'form', 'x-on:keydown.escape', 'open = false'); + $this->assertSelectorAttribute($form, 'form', 'x-on:keyup', 'doKeyUp()'); + $this->assertSelectorAttribute($form, 'form', 'x-transition:enter', 'transition ease-out duration-300'); + $this->assertSelectorAttribute($form, 'form', 'x-cloak'); + + // DOM Crawler doesn't like @-prefixed attributes, so we'll just check those strings + $this->assertStringContainsString('@click="doClick()"', $form); + $this->assertStringContainsString('@click.away="open = false"', $form); + } + + public function test_livewire_style_attributes() : void + { + $blade = ' + + '; + + $form = $this->renderBlade($blade, ['poll' => 'poll_500ms']); + + $this->assertSelectorAttribute($form, 'form', 'wire:key', 'form_key'); + $this->assertSelectorAttribute($form, 'form', 'wire:click.prefetch', 'prefetch_click'); + $this->assertSelectorAttribute($form, 'form', 'wire:model.debounce.100ms', 'debounced_model'); + $this->assertSelectorAttribute($form, 'form', 'wire:poll.500ms', 'poll_500ms'); + } +} diff --git a/tests/Components/NumberTest.php b/tests/Components/NumberTest.php new file mode 100644 index 0000000..7ff83cd --- /dev/null +++ b/tests/Components/NumberTest.php @@ -0,0 +1,8 @@ +renderBlade(''); + $this->assertSelectorAttribute($select, 'select', 'autofocus'); + + $select = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($select, 'select', 'autofocus'); + } + + public function test_disabled_flag_can_be_set_on_and_off() : void + { + $select = $this->renderBlade(''); + $this->assertSelectorAttribute($select, 'select', 'disabled'); + + $select = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($select, 'select', 'disabled'); + } + + public function test_form_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $select = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($select, 'select', 'form', $value); + + $select = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($select, 'select', 'form'); + } + + public function test_multiple_flag_can_be_set_on_and_off() : void + { + $select = $this->renderBlade(''); + $this->assertSelectorAttribute($select, 'select', 'multiple'); + + $select = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($select, 'select', 'multiple'); + } + + public function test_name_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $select = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($select, 'select', 'name', $value); + + $select = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($select, 'select', 'name'); + } + + public function test_required_flag_can_be_set_on_and_off() : void + { + $select = $this->renderBlade(''); + $this->assertSelectorAttribute($select, 'select', 'required'); + + $select = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($select, 'select', 'required'); + } + + public function test_size_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $select = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($select, 'select', 'size', $value); + + $select = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($select, 'select', 'size'); + } + +} diff --git a/tests/Components/TelTest.php b/tests/Components/TelTest.php new file mode 100644 index 0000000..23215a3 --- /dev/null +++ b/tests/Components/TelTest.php @@ -0,0 +1,8 @@ +renderBlade(''); + $this->assertSelectorAttribute($textarea, 'textarea', 'autofocus'); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'autofocus'); + } + + public function test_cols_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $textarea = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($textarea, 'textarea', 'cols', $value); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'cols'); + } + + public function test_dir_name_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $textarea = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($textarea, 'textarea', 'dirname', $value); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'dirname'); + } + + public function test_disabled_flag_can_be_set_on_and_off() : void + { + $textarea = $this->renderBlade(''); + $this->assertSelectorAttribute($textarea, 'textarea', 'disabled'); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'disabled'); + } + + public function test_form_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $textarea = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($textarea, 'textarea', 'form', $value); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'form'); + } + + public function test_max_length_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $textarea = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($textarea, 'textarea', 'maxlength', $value); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'maxlength'); + } + + public function test_name_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $textarea = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($textarea, 'textarea', 'name', $value); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'name'); + } + + public function test_placeholder_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $textarea = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($textarea, 'textarea', 'placeholder', $value); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'placeholder'); + } + + public function test_read_only_flag_can_be_set_on_and_off() : void + { + $textarea = $this->renderBlade(''); + $this->assertSelectorAttribute($textarea, 'textarea', 'readonly'); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'readonly'); + } + + public function test_required_flag_can_be_set_on_and_off() : void + { + $textarea = $this->renderBlade(''); + $this->assertSelectorAttribute($textarea, 'textarea', 'required'); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'required'); + } + + public function test_rows_attribute_can_be_set_and_unset() : void + { + $value = Str::random(); + + $textarea = $this->renderBlade('', compact('value')); + $this->assertSelectorAttribute($textarea, 'textarea', 'rows', $value); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'rows'); + } + + public function test_wrap_attribute_can_be_set_and_unset() : void + { + $textarea = $this->renderBlade(''); + $this->assertSelectorAttribute($textarea, 'textarea', 'wrap', 'hard'); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttribute($textarea, 'textarea', 'wrap', 'soft'); + + $textarea = $this->renderBlade(''); + $this->assertSelectorAttributeMissing($textarea, 'textarea', 'wrap'); + } + +} diff --git a/tests/Components/TimeTest.php b/tests/Components/TimeTest.php new file mode 100644 index 0000000..89060b3 --- /dev/null +++ b/tests/Components/TimeTest.php @@ -0,0 +1,8 @@ +render(); + $this->performBasicFormAssertions($html); + } + + public function test_a_basic_form_using_blade_components_renders_as_expected() + { + if (version_compare($this->app->version(), '8.0.0', '<')) { + $this->markTestSkipped('Only applies to Laravel 8 and higher.'); + } + + // Needed occasionally to clear the view cache for tests: + // $this->artisan('view:clear'); + + $html = View::make('basic-component-form')->render(); + $this->performBasicFormAssertions($html); + } + + public function test_a_button_with_html_content_renders() + { + $html = View::make('button-open-close')->render(); + $this->assertSelectorExists($html, 'form > button'); + $this->assertSelectorAttribute($html, 'form > button', 'type', 'submit'); + $this->assertSelectorExists($html, 'form > button > strong'); + $this->assertSelectorTextEquals($html, 'form > button > strong', 'Hello world'); + } + + protected function performBasicFormAssertions($html) + { // Form $this->assertSelectorExists($html, 'form#test_form'); @@ -65,24 +92,18 @@ public function test_a_basic_form_renders_as_expected() $this->assertSelectorAttribute($html, '#checkbox', 'type', 'checkbox'); $this->assertSelectorExists($html, 'label[for="checkbox"]'); - // Radio Button - // $this->assertSelectorExists($html, 'input#radio'); - // $this->assertSelectorAttribute($html, '#radio', 'name', 'radio'); - // $this->assertSelectorAttribute($html, '#radio', 'type', 'radio'); - // $this->assertSelectorExists($html, 'label[for="radio"]'); + // Radio Group + $this->assertSelectorExists($html, 'input[name=radio_group]'); + $this->assertSelectorAttribute($html, 'input[name=radio_group]', 'type', 'radio'); + $this->assertSelectorExists($html, 'label input[name=radio_group]'); + + // Checkbox Group + $this->assertSelectorExists($html, 'input[name^=checkbox_group]'); + $this->assertSelectorAttribute($html, 'input[name^=checkbox_group]', 'type', 'checkbox'); + $this->assertSelectorExists($html, 'label input[name^=checkbox_group]'); // Submit Button $this->assertSelectorExists($html, 'button#submit'); $this->assertSelectorAttribute($html, '#submit', 'type', 'submit'); } - - public function test_a_button_with_html_content_renders() - { - $html = View::make('button-open-close')->render(); - - $this->assertSelectorExists($html, 'form > button'); - $this->assertSelectorAttribute($html, 'form > button', 'type', 'submit'); - $this->assertSelectorExists($html, 'form > button > strong'); - $this->assertSelectorTextEquals($html, 'form > button > strong', 'Hello world'); - } } diff --git a/tests/Feature/stubs/basic-component-form.blade.php b/tests/Feature/stubs/basic-component-form.blade.php new file mode 100644 index 0000000..4f52483 --- /dev/null +++ b/tests/Feature/stubs/basic-component-form.blade.php @@ -0,0 +1,76 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/Feature/stubs/basic-form.blade.php b/tests/Feature/stubs/basic-form.blade.php index 00f3ffc..143b90f 100644 --- a/tests/Feature/stubs/basic-form.blade.php +++ b/tests/Feature/stubs/basic-form.blade.php @@ -28,10 +28,11 @@ {{ Aire::checkbox('checkbox', 'Checkbox') ->id('checkbox') }} -{{-- TODO: Radio buttons don't make any sense singularly, so implement as a group -{{ Aire::radio('radio', 'Radio') - ->id('radio') }} ---}} +{{ Aire::radioGroup(['a' => 'eh', 'b' => 'bee'], 'radio_group', 'Radio Group') + ->id('radio_group') }} + +{{ Aire::checkboxGroup(['a' => 'eh', 'b' => 'bee'], 'checkbox_group', 'Checkbox Group') + ->id('checkbox_group') }} {{ Aire::submit('Submit Button')->id('submit') }} diff --git a/tests/TestCase.php b/tests/TestCase.php index 3b1e57d..8023b13 100644 --- a/tests/TestCase.php +++ b/tests/TestCase.php @@ -14,6 +14,7 @@ use Galahad\Aire\Tests\Constraints\SelectorHasClassNames; use Galahad\Aire\Tests\Constraints\SelectorMissingClassNames; use Galahad\Aire\Tests\Constraints\SelectorTextEquals; +use Illuminate\Container\Container; use Orchestra\Testbench\TestCase as Orchestra; use PHPUnit\Framework\Constraint\LogicalNot; use Symfony\Component\DomCrawler\Crawler; @@ -73,6 +74,31 @@ protected function crawl($html) : Crawler : new Crawler((string) $html); } + protected function renderBlade($contents, array $data = []) + { + $factory = $this->app['view']; + + $factory->addNamespace( + '__aire_test_components', + $directory = $this->app['config']->get('view.compiled') + ); + + $basename = sha1($contents); + $filename = "{$directory}/{$basename}.blade.php"; + + if (!is_file($filename)) { + if (!is_dir($directory)) { + mkdir($directory, 0755, true); + } + + file_put_contents($filename, $contents); + } + + $component_name = "__aire_test_components::{$basename}"; + + return $factory->make($component_name, $data)->render(); + } + protected function assertSelectorExists($html, $selector) { static::assertThat($html, new SelectorExists($selector));