Skip to content

Commit 3075093

Browse files
Added wire:model.boolean as an option to assertPropertyWired and assertPropertyNotWired (#38)
* added an extra assertions test to check for boolean, added boolean into the CustomLivewireAssertionsMixin.php after the blur entry, and additional line to test-componet-a * Fix styling --------- Co-authored-by: Christoph Rumpel <[email protected]>
1 parent 20493cf commit 3075093

4 files changed

+8
-4
lines changed

.php-cs-fixer.cache

+2-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1-
{"php":"8.3.4","version":"3.53.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces_position":true,"class_definition":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"const":"one","method":"one","property":"one"}},"single_trait_insert_per_statement":true},"hashes":{"src\/CustomLivewireAssertionsMixin.php":"0af451faed1cc2a92aad855976006161","src\/ComponentName.php":"af0dc94880495710238f36e09974f56b","src\/MissingLivewireAssertionsServiceProvider.php":"001e0571136e8126eb93c4ddb1bbb53a","tests\/resources\/views\/livewire-test-component-b.php":"ab1e1d7326d9e0a269a84c239503d679","tests\/resources\/views\/blade-test-component.php":"4b61e7dba267eb48b3fa25a14e0d086b","tests\/resources\/views\/livewire-test-component-a.php":"2ba62faed184d61a5eae8d52def8eb10","tests\/resources\/views\/livewire-test-component-d.php":"5316f158439e7e01c467a5ac16508dd1","tests\/resources\/views\/livewire-test-component-c.php":"b91a9c12dd35893f20ffc42f92bfb68e","tests\/AssertionsTest.php":"5ed1b02e461e7860486c1b7bf247bf0a","tests\/Components\/LivewireTestComponentD.php":"a0a14bddb133c4a7e971b6d3c31d3d0e","tests\/Components\/LivewireTestComponentC.php":"d516104cd3b4eb72826b8a3eef9246fd","tests\/Components\/LivewireTestComponentA.php":"2306729210f9134b92a46d05c71dc566","tests\/Components\/FileDownloadComponent.php":"92f6b79d4253193dc1503a0d84d6ac7e","tests\/Components\/LivewireTestComponentB.php":"7ef74a34799d9cc730a738f40eeb2b40","tests\/TestCase.php":"3e2e658dc76516b56f2c8f83c770cf97","tests\/View\/Components\/Button.php":"ed586764f2469ec4b6a76d0f0d96f6ba"}}
1+
{"php":"8.3.4","version":"3.53.0","indent":" ","lineEnding":"\n","rules":{"blank_line_after_namespace":true,"braces_position":true,"class_definition":true,"constant_case":true,"control_structure_braces":true,"control_structure_continuation_position":true,"elseif":true,"function_declaration":true,"indentation_type":true,"line_ending":true,"lowercase_keywords":true,"method_argument_space":{"on_multiline":"ensure_fully_multiline","keep_multiple_spaces_after_comma":true},"no_break_comment":true,"no_closing_tag":true,"no_multiple_statements_per_line":true,"no_space_around_double_colon":true,"no_spaces_after_function_name":true,"no_trailing_whitespace":true,"no_trailing_whitespace_in_comment":true,"single_blank_line_at_eof":true,"single_class_element_per_statement":{"elements":["property"]},"single_import_per_statement":true,"single_line_after_imports":true,"spaces_inside_parentheses":true,"statement_indentation":true,"switch_case_semicolon_to_colon":true,"switch_case_space":true,"visibility_required":{"elements":["method","property"]},"encoding":true,"full_opening_tag":true,"array_syntax":{"syntax":"short"},"ordered_imports":{"sort_algorithm":"alpha"},"no_unused_imports":true,"not_operator_with_successor_space":true,"trailing_comma_in_multiline":true,"phpdoc_scalar":true,"unary_operator_spaces":true,"binary_operator_spaces":true,"blank_line_before_statement":{"statements":["break","continue","declare","return","throw","try"]},"phpdoc_single_line_var_spacing":true,"phpdoc_var_without_name":true,"class_attributes_separation":{"elements":{"const":"one","method":"one","property":"one"}},"single_trait_insert_per_statement":true},"hashes":{"src\/CustomLivewireAssertionsMixin.php":"ab5d5d4a61b0355151090ce647092102","src\/ComponentName.php":"af0dc94880495710238f36e09974f56b","src\/MissingLivewireAssertionsServiceProvider.php":"001e0571136e8126eb93c4ddb1bbb53a","tests\/resources\/views\/livewire-test-component-b.php":"ab1e1d7326d9e0a269a84c239503d679","tests\/resources\/views\/blade-test-component.php":"4b61e7dba267eb48b3fa25a14e0d086b","tests\/resources\/views\/livewire-test-component-a.php":"3b67f76d466d9c252eb3116c5d754d52","tests\/resources\/views\/livewire-test-component-d.php":"5316f158439e7e01c467a5ac16508dd1","tests\/resources\/views\/livewire-test-component-c.php":"b91a9c12dd35893f20ffc42f92bfb68e","tests\/AssertionsTest.php":"1292aaa3fcfb235d81ee35d01e9bf830","tests\/Components\/LivewireTestComponentD.php":"a0a14bddb133c4a7e971b6d3c31d3d0e","tests\/Components\/LivewireTestComponentC.php":"d516104cd3b4eb72826b8a3eef9246fd","tests\/Components\/LivewireTestComponentA.php":"2306729210f9134b92a46d05c71dc566","tests\/Components\/FileDownloadComponent.php":"92f6b79d4253193dc1503a0d84d6ac7e","tests\/Components\/LivewireTestComponentB.php":"7ef74a34799d9cc730a738f40eeb2b40","tests\/TestCase.php":"3e2e658dc76516b56f2c8f83c770cf97","tests\/View\/Components\/Button.php":"ed586764f2469ec4b6a76d0f0d96f6ba"}}
2+

src/CustomLivewireAssertionsMixin.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public function assertPropertyWired(): Closure
1717
{
1818
return function (string $property) {
1919
PHPUnit::assertMatchesRegularExpression(
20-
'/wire:model(\.(defer|live|blur|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
20+
'/wire:model(\.(defer|live|blur|boolean|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
2121
$this->html()
2222
);
2323

@@ -32,7 +32,7 @@ public function assertPropertyNotWired(): Closure
3232
{
3333
return function (string $property) {
3434
PHPUnit::assertDoesNotMatchRegularExpression(
35-
'/wire:model(\.(live|blur|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
35+
'/wire:model(\.(live|blur|boolean|(lazy|debounce)(\.\d+?(ms|s)|)))*=(?<q>"|\')'.$property.'(\k\'q\')/',
3636
$this->html()
3737
);
3838

tests/AssertionsTest.php

+3-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
Livewire::test(LivewireTestComponentA::class)
1818
->assertPropertyWired('user')
1919
->assertPropertyWired('blur')
20+
->assertPropertyWired('boolean')
2021
->assertPropertyWired('defer')
2122
->assertPropertyWired('lazy')
2223
->assertPropertyWired('live')
@@ -26,10 +27,11 @@
2627
->assertPropertyWired('singlequote');
2728
});
2829

29-
it('checks if Livewire property is not wired toa field', function () {
30+
it('checks if Livewire property is not wired to a field', function () {
3031
Livewire::test(LivewireTestComponentA::class)
3132
->assertPropertyNotWired('user_not_wired')
3233
->assertPropertyNotWired('blur_not_wired')
34+
->assertPropertyNotWired('boolean_not_wired')
3335
->assertPropertyNotWired('lazy_not_wired')
3436
->assertPropertyNotWired('live_not_wired')
3537
->assertPropertyNotWired('defer_not_wired')

tests/resources/views/livewire-test-component-a.php

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
<div>
22
<input type="text" wire:model="user" />
33
<input type="text" wire:model.blur="blur" />
4+
<input type="text" wire:model.boolean="boolean" />
45
<input type="text" wire:model.lazy="lazy" />
56
<input type="text" wire:model.live="live" />
67
<input type="text" wire:model.defer="defer" />

0 commit comments

Comments
 (0)