55use Closure ;
66use Illuminate \Support \Str ;
77use Livewire \Component ;
8- use Livewire \Mechanisms \ ComponentRegistry ;
8+ use Livewire \Finder \ Finder ;
99use PHPUnit \Framework \Assert as PHPUnit ;
1010
1111/**
@@ -17,7 +17,7 @@ public function assertPropertyWired(): Closure
1717 {
1818 return function (string $ property ) {
1919 PHPUnit::assertMatchesRegularExpression (
20- '/wire:model(\.(defer| live|blur|change|boolean|self|(lazy| debounce)( \.\d+?( ms|s)|))) *=(?<q>"| \') ' .$ property. ' ( \k \'q \') / ' ,
20+ '/wire:model(?:\. live(?:\. debounce(?: \.\d+(?: ms|s))?)?|\.(?:blur|lazy|change|boolean|self|deep|number|fill)) *=(?<q>"| \') ' .preg_quote ( $ 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|change|boolean|self|(lazy| debounce)( \.\d+?( ms|s)|))) *=(?<q>"| \') ' .$ property. ' ( \k \'q \') / ' ,
35+ '/wire:model(?:\. live(?:\. debounce(?: \.\d+(?: ms|s))?)?|\.(?:blur|lazy|change|boolean|self|deep|number|fill)) *=(?<q>"| \') ' .preg_quote ( $ property, ' / ' ). ' \k \'q \'/ ' ,
3636 $ this ->html ()
3737 );
3838
@@ -56,7 +56,7 @@ public function assertPropertyEntangled(): Closure
5656 . preg_quote ("' " . $ property . "' " )
5757 . ') ' ;
5858 PHPUnit::assertMatchesRegularExpression (
59- '/(.|\$wire\.)entangle\( ' . $ propertyRe. '\)/ ' ,
59+ '/(.|\$wire\.)entangle\( ' . $ propertyRe . '\)/ ' ,
6060 $ this ->html ()
6161 );
6262
@@ -80,7 +80,7 @@ public function assertPropertyNotEntangled(): Closure
8080 . preg_quote ("' " . $ property . "' " )
8181 . ') ' ;
8282 PHPUnit::assertDoesNotMatchRegularExpression (
83- '/(.|\$wire\.)entangle\( ' . $ propertyRe. '\)/ ' ,
83+ '/(.|\$wire\.)entangle\( ' . $ propertyRe . '\)/ ' ,
8484 $ this ->html ()
8585 );
8686
@@ -95,7 +95,7 @@ public function assertMethodWired(): Closure
9595 {
9696 return function (string $ method ) {
9797 PHPUnit::assertMatchesRegularExpression (
98- '/wire:click(\.(prevent))?=(?<q>"| \') ' . preg_quote ($ method ). '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
98+ '/wire:click(\.(prevent))?=(?<q>"| \') ' . preg_quote ($ method ) . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
9999 $ this ->html ()
100100 );
101101
@@ -110,7 +110,7 @@ public function assertMethodNotWired(): Closure
110110 {
111111 return function (string $ method ) {
112112 PHPUnit::assertDoesNotMatchRegularExpression (
113- '/wire:click(\.(prevent))?=(?<q>"| \') ' . preg_quote ($ method ). '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
113+ '/wire:click(\.(prevent))?=(?<q>"| \') ' . preg_quote ($ method ) . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
114114 $ this ->html ()
115115 );
116116
@@ -125,7 +125,7 @@ public function assertMethodWiredToAction(): Closure
125125 {
126126 return function (string $ action , string $ methodName ) {
127127 PHPUnit::assertMatchesRegularExpression (
128- '/wire: ' . $ action . '?=(?<q>"| \') ' . preg_quote ($ methodName ). '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
128+ '/wire: ' . $ action . '?=(?<q>"| \') ' . preg_quote ($ methodName ) . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
129129 $ this ->html ()
130130 );
131131
@@ -140,7 +140,7 @@ public function assertMethodNotWiredToAction(): Closure
140140 {
141141 return function (string $ action , string $ methodName ) {
142142 PHPUnit::assertDoesNotMatchRegularExpression (
143- '/wire: ' . $ action . '?=(?<q>"| \') ' . preg_quote ($ methodName ). '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
143+ '/wire: ' . $ action . '?=(?<q>"| \') ' . preg_quote ($ methodName ) . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
144144 $ this ->html ()
145145 );
146146
@@ -155,7 +155,7 @@ public function assertMethodWiredToForm(): Closure
155155 {
156156 return function (string $ method ) {
157157 PHPUnit::assertMatchesRegularExpression (
158- '/wire:submit(\.(prevent))*=(?<q>"| \') ' . $ method. '(\k \'q \')/ ' ,
158+ '/wire:submit(\.(prevent))*=(?<q>"| \') ' . $ method . '(\k \'q \')/ ' ,
159159 $ this ->html ()
160160 );
161161
@@ -170,7 +170,7 @@ public function assertMethodNotWiredToForm(): Closure
170170 {
171171 return function (string $ method ) {
172172 PHPUnit::assertDoesNotMatchRegularExpression (
173- '/wire:submit(\.(prevent))*=(?<q>"| \') ' . $ method. '(\k \'q \')/ ' ,
173+ '/wire:submit(\.(prevent))*=(?<q>"| \') ' . $ method . '(\k \'q \')/ ' ,
174174 $ this ->html ()
175175 );
176176
@@ -185,7 +185,7 @@ public function assertMethodWiredToEvent(): Closure
185185 {
186186 return function (string $ method , string $ event ) {
187187 PHPUnit::assertMatchesRegularExpression (
188- '/wire: ' . preg_quote ($ event , '/ ' ). '(\.[a-zA-Z0-9\-]+)*=(?<q>"| \') ' . $ method. '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
188+ '/wire: ' . preg_quote ($ event , '/ ' ) . '(\.[a-zA-Z0-9\-]+)*=(?<q>"| \') ' . $ method . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
189189 $ this ->html ()
190190 );
191191
@@ -200,7 +200,7 @@ public function assertMethodNotWiredToEvent(): Closure
200200 {
201201 return function (string $ method , string $ event ) {
202202 PHPUnit::assertDoesNotMatchRegularExpression (
203- '/wire: ' . preg_quote ($ event , '/ ' ). '(\.[a-zA-Z0-9\-]+)*=(?<q>"| \') ' . $ method. '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
203+ '/wire: ' . preg_quote ($ event , '/ ' ) . '(\.[a-zA-Z0-9\-]+)*=(?<q>"| \') ' . $ method . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
204204 $ this ->html ()
205205 );
206206
@@ -215,7 +215,7 @@ public function assertMethodWiredToEventWithoutModifiers(): Closure
215215 {
216216 return function (string $ method , string $ event ) {
217217 PHPUnit::assertMatchesRegularExpression (
218- '/wire: ' . preg_quote ($ event , '/ ' ). '=(?<q>"| \') ' . $ method. '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
218+ '/wire: ' . preg_quote ($ event , '/ ' ) . '=(?<q>"| \') ' . $ method . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
219219 $ this ->html ()
220220 );
221221
@@ -230,7 +230,7 @@ public function assertMethodNotWiredToEventWithoutModifiers(): Closure
230230 {
231231 return function (string $ method , string $ event ) {
232232 PHPUnit::assertDoesNotMatchRegularExpression (
233- '/wire: ' . preg_quote ($ event , '/ ' ). '=(?<q>"| \') ' . $ method. '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
233+ '/wire: ' . preg_quote ($ event , '/ ' ) . '=(?<q>"| \') ' . $ method . '(\s*\(.+\)\s*)?\s*(\k \'q \')/ ' ,
234234 $ this ->html ()
235235 );
236236
@@ -245,13 +245,13 @@ public function assertContainsLivewireComponent(): Closure
245245 {
246246 return function (string $ component ) {
247247 if (is_subclass_of ($ component , Component::class)) {
248- $ component = app (ComponentRegistry ::class)->getName ($ component );
248+ $ component = app (Finder ::class)->normalizeName ($ component );
249249 }
250250
251251 $ componentHaystackView = file_get_contents ($ this ->lastState ->getView ()->getPath ());
252252
253253 PHPUnit::assertMatchesRegularExpression (
254- '/@livewire\(\s* \'' . $ component. '\'|<livewire\: ' . $ component. '/ ' ,
254+ '/@livewire\(\s* \'' . $ component . '\'|<livewire\: ' . $ component . '/ ' ,
255255 $ componentHaystackView
256256 );
257257
@@ -266,13 +266,13 @@ public function assertDoesNotContainLivewireComponent(): Closure
266266 {
267267 return function (string $ component ) {
268268 if (is_subclass_of ($ component , Component::class)) {
269- $ component = app (ComponentRegistry ::class)->getName ($ component );
269+ $ component = app (Finder ::class)->normalizeName ($ component );
270270 }
271271
272272 $ componentHaystackView = file_get_contents ($ this ->lastState ->getView ()->getPath ());
273273
274274 PHPUnit::assertDoesNotMatchRegularExpression (
275- '/@livewire\( \'' . $ component. '\'|<livewire\: ' . $ component. '/ ' ,
275+ '/@livewire\( \'' . $ component . '\'|<livewire\: ' . $ component . '/ ' ,
276276 $ componentHaystackView
277277 );
278278
0 commit comments