@@ -94,10 +94,16 @@ public function assertTableColumnExists(): Closure
9494 );
9595
9696 if ($ record ) {
97- if (! ($ record instanceof Model)) {
98- $ record = $ this ->instance ()->getTableRecord ($ record );
97+ if ($ record instanceof Model) {
98+ $ recordKey = (string ) $ record ->getKey ();
99+ } elseif (is_array ($ record )) {
100+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
101+ } else {
102+ $ recordKey = (string ) $ record ;
99103 }
100104
105+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
106+
101107 $ column ->record ($ record );
102108 }
103109
@@ -126,10 +132,16 @@ public function assertTableColumnDoesNotExist(): Closure
126132 }
127133
128134 if ($ record ) {
129- if (! ($ record instanceof Model)) {
130- $ record = $ this ->instance ()->getTableRecord ($ record );
135+ if ($ record instanceof Model) {
136+ $ recordKey = (string ) $ record ->getKey ();
137+ } elseif (is_array ($ record )) {
138+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
139+ } else {
140+ $ recordKey = (string ) $ record ;
131141 }
132142
143+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
144+
133145 $ column ->record ($ record );
134146 }
135147
@@ -196,15 +208,19 @@ public function assertTableColumnStateSet(): Closure
196208
197209 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
198210
199- if (! ($ record instanceof Model)) {
200- /** @phpstan-ignore-next-line */
201- $ this ->assertTableRecordKeyExists ((string ) $ record );
202- $ record = $ this ->instance ()->getTableRecord ($ record );
203- $ recordKey = $ record [ArrayRecord::getKeyName ()];
211+ if ($ record instanceof Model) {
212+ $ recordKey = (string ) $ record ->getKey ();
213+ } elseif (is_array ($ record )) {
214+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
204215 } else {
205- $ recordKey = $ record -> getKey () ;
216+ $ recordKey = ( string ) $ record ;
206217 }
207218
219+ /** @phpstan-ignore-next-line */
220+ $ this ->assertTableRecordKeyExists ($ recordKey );
221+
222+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
223+
208224 $ column ->record ($ record );
209225
210226 $ livewireClass = $ this ->instance ()::class;
@@ -241,15 +257,19 @@ public function assertTableColumnStateNotSet(): Closure
241257
242258 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
243259
244- if (! ($ record instanceof Model)) {
245- /** @phpstan-ignore-next-line */
246- $ this ->assertTableRecordKeyExists ((string ) $ record );
247- $ record = $ this ->instance ()->getTableRecord ($ record );
248- $ recordKey = $ record [ArrayRecord::getKeyName ()];
260+ if ($ record instanceof Model) {
261+ $ recordKey = (string ) $ record ->getKey ();
262+ } elseif (is_array ($ record )) {
263+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
249264 } else {
250- $ recordKey = $ record -> getKey () ;
265+ $ recordKey = ( string ) $ record ;
251266 }
252267
268+ /** @phpstan-ignore-next-line */
269+ $ this ->assertTableRecordKeyExists ($ recordKey );
270+
271+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
272+
253273 $ column ->record ($ record );
254274
255275 $ livewireClass = $ this ->instance ()::class;
@@ -287,15 +307,19 @@ public function assertTableColumnFormattedStateSet(): Closure
287307 /** @var TextColumn $column */
288308 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
289309
290- if (! ($ record instanceof Model)) {
291- /** @phpstan-ignore-next-line */
292- $ this ->assertTableRecordKeyExists ((string ) $ record );
293- $ record = $ this ->instance ()->getTableRecord ($ record );
294- $ recordKey = $ record [ArrayRecord::getKeyName ()];
310+ if ($ record instanceof Model) {
311+ $ recordKey = (string ) $ record ->getKey ();
312+ } elseif (is_array ($ record )) {
313+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
295314 } else {
296- $ recordKey = $ record -> getKey () ;
315+ $ recordKey = ( string ) $ record ;
297316 }
298317
318+ /** @phpstan-ignore-next-line */
319+ $ this ->assertTableRecordKeyExists ($ recordKey );
320+
321+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
322+
299323 $ column ->record ($ record );
300324
301325 $ livewireClass = $ this ->instance ()::class;
@@ -321,15 +345,19 @@ public function assertTableColumnFormattedStateNotSet(): Closure
321345 /** @var TextColumn $column */
322346 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
323347
324- if (! ($ record instanceof Model)) {
325- /** @phpstan-ignore-next-line */
326- $ this ->assertTableRecordKeyExists ((string ) $ record );
327- $ record = $ this ->instance ()->getTableRecord ($ record );
328- $ recordKey = $ record [ArrayRecord::getKeyName ()];
348+ if ($ record instanceof Model) {
349+ $ recordKey = (string ) $ record ->getKey ();
350+ } elseif (is_array ($ record )) {
351+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
329352 } else {
330- $ recordKey = $ record -> getKey () ;
353+ $ recordKey = ( string ) $ record ;
331354 }
332355
356+ /** @phpstan-ignore-next-line */
357+ $ this ->assertTableRecordKeyExists ($ recordKey );
358+
359+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
360+
333361 $ column ->record ($ record );
334362
335363 $ livewireClass = $ this ->instance ()::class;
@@ -354,15 +382,19 @@ public function assertTableColumnHasExtraAttributes(): Closure
354382
355383 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
356384
357- if (! ($ record instanceof Model)) {
358- /** @phpstan-ignore-next-line */
359- $ this ->assertTableRecordKeyExists ((string ) $ record );
360- $ record = $ this ->instance ()->getTableRecord ($ record );
361- $ recordKey = $ record [ArrayRecord::getKeyName ()];
385+ if ($ record instanceof Model) {
386+ $ recordKey = (string ) $ record ->getKey ();
387+ } elseif (is_array ($ record )) {
388+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
362389 } else {
363- $ recordKey = $ record -> getKey () ;
390+ $ recordKey = ( string ) $ record ;
364391 }
365392
393+ /** @phpstan-ignore-next-line */
394+ $ this ->assertTableRecordKeyExists ($ recordKey );
395+
396+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
397+
366398 $ column ->record ($ record );
367399
368400 $ attributesString = print_r ($ attributes , true );
@@ -387,15 +419,19 @@ public function assertTableColumnDoesNotHaveExtraAttributes(): Closure
387419
388420 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
389421
390- if (! ($ record instanceof Model)) {
391- /** @phpstan-ignore-next-line */
392- $ this ->assertTableRecordKeyExists ((string ) $ record );
393- $ record = $ this ->instance ()->getTableRecord ($ record );
394- $ recordKey = $ record [ArrayRecord::getKeyName ()];
422+ if ($ record instanceof Model) {
423+ $ recordKey = (string ) $ record ->getKey ();
424+ } elseif (is_array ($ record )) {
425+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
395426 } else {
396- $ recordKey = $ record -> getKey () ;
427+ $ recordKey = ( string ) $ record ;
397428 }
398429
430+ /** @phpstan-ignore-next-line */
431+ $ this ->assertTableRecordKeyExists ($ recordKey );
432+
433+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
434+
399435 $ column ->record ($ record );
400436
401437 $ attributesString = print_r ($ attributes , true );
@@ -421,15 +457,19 @@ public function assertTableColumnHasDescription(): Closure
421457 /** @var TextColumn $column */
422458 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
423459
424- if (! ($ record instanceof Model)) {
425- /** @phpstan-ignore-next-line */
426- $ this ->assertTableRecordKeyExists ((string ) $ record );
427- $ record = $ this ->instance ()->getTableRecord ($ record );
428- $ recordKey = $ record [ArrayRecord::getKeyName ()];
460+ if ($ record instanceof Model) {
461+ $ recordKey = (string ) $ record ->getKey ();
462+ } elseif (is_array ($ record )) {
463+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
429464 } else {
430- $ recordKey = $ record -> getKey () ;
465+ $ recordKey = ( string ) $ record ;
431466 }
432467
468+ /** @phpstan-ignore-next-line */
469+ $ this ->assertTableRecordKeyExists ($ recordKey );
470+
471+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
472+
433473 $ column ->record ($ record );
434474
435475 $ actualDescription = $ position === 'above ' ? $ column ->getDescriptionAbove () : $ column ->getDescriptionBelow ();
@@ -455,15 +495,19 @@ public function assertTableColumnDoesNotHaveDescription(): Closure
455495 /** @var TextColumn $column */
456496 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
457497
458- if (! ($ record instanceof Model)) {
459- /** @phpstan-ignore-next-line */
460- $ this ->assertTableRecordKeyExists ((string ) $ record );
461- $ record = $ this ->instance ()->getTableRecord ($ record );
462- $ recordKey = $ record [ArrayRecord::getKeyName ()];
498+ if ($ record instanceof Model) {
499+ $ recordKey = (string ) $ record ->getKey ();
500+ } elseif (is_array ($ record )) {
501+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
463502 } else {
464- $ recordKey = $ record -> getKey () ;
503+ $ recordKey = ( string ) $ record ;
465504 }
466505
506+ /** @phpstan-ignore-next-line */
507+ $ this ->assertTableRecordKeyExists ($ recordKey );
508+
509+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
510+
467511 $ column ->record ($ record );
468512
469513 $ actualDescription = $ position === 'above ' ? $ column ->getDescriptionAbove () : $ column ->getDescriptionBelow ();
@@ -489,15 +533,19 @@ public function assertTableSelectColumnHasOptions(): Closure
489533 /** @var SelectColumn $column */
490534 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
491535
492- if (! ($ record instanceof Model)) {
493- /** @phpstan-ignore-next-line */
494- $ this ->assertTableRecordKeyExists ((string ) $ record );
495- $ record = $ this ->instance ()->getTableRecord ($ record );
496- $ recordKey = $ record [ArrayRecord::getKeyName ()];
536+ if ($ record instanceof Model) {
537+ $ recordKey = (string ) $ record ->getKey ();
538+ } elseif (is_array ($ record )) {
539+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
497540 } else {
498- $ recordKey = $ record -> getKey () ;
541+ $ recordKey = ( string ) $ record ;
499542 }
500543
544+ /** @phpstan-ignore-next-line */
545+ $ this ->assertTableRecordKeyExists ($ recordKey );
546+
547+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
548+
501549 $ column ->record ($ record );
502550
503551 $ optionsString = print_r ($ options , true );
@@ -523,15 +571,19 @@ public function assertTableSelectColumnDoesNotHaveOptions(): Closure
523571 /** @var SelectColumn $column */
524572 $ column = $ this ->instance ()->getTable ()->getColumn ($ name );
525573
526- if (! ($ record instanceof Model)) {
527- /** @phpstan-ignore-next-line */
528- $ this ->assertTableRecordKeyExists ((string ) $ record );
529- $ record = $ this ->instance ()->getTableRecord ($ record );
530- $ recordKey = $ record [ArrayRecord::getKeyName ()];
574+ if ($ record instanceof Model) {
575+ $ recordKey = (string ) $ record ->getKey ();
576+ } elseif (is_array ($ record )) {
577+ $ recordKey = (string ) $ record [ArrayRecord::getKeyName ()];
531578 } else {
532- $ recordKey = $ record -> getKey () ;
579+ $ recordKey = ( string ) $ record ;
533580 }
534581
582+ /** @phpstan-ignore-next-line */
583+ $ this ->assertTableRecordKeyExists ($ recordKey );
584+
585+ $ record = $ this ->instance ()->getTableRecord ($ recordKey );
586+
535587 $ column ->record ($ record );
536588
537589 $ optionsString = print_r ($ options , true );
0 commit comments