@@ -504,34 +504,58 @@ public function testNestedRelationshipWhereClauseParsing()
504
504
505
505
public function testExistsRelationshipWhereClauseParsing ()
506
506
{
507
+ $ authors = (new Author )->whereHas ('books ' )
508
+ ->get ();
507
509
508
- $ authors = collect ([(new Author )->whereHas ('books ' )->first ()]);
509
-
510
- $ key = 'genealabslaravelmodelcachingtestsfixturesauthor_and_authors.id_=_books.author_id-first ' ;
510
+ $ key = 'genealabslaravelmodelcachingtestsfixturesauthor_exists_and_authors.id_=_books.author_id ' ;
511
511
$ tags = ['genealabslaravelmodelcachingtestsfixturesauthor ' ];
512
512
513
- $ cachedResults = collect ([cache ()->tags ($ tags )->get ($ key )]);
513
+ $ cachedResults = cache ()->tags ($ tags )->get ($ key );
514
+ $ liveResults = (new UncachedAuthor )->whereHas ('books ' )
515
+ ->get ();
514
516
515
- $ liveResults = collect ([(new UncachedAuthor )
516
- ->whereHas ('books ' )->first ()]);
517
+ $ this ->assertEmpty ($ authors ->diffAssoc ($ cachedResults ));
518
+ $ this ->assertEmpty ($ liveResults ->diffAssoc ($ cachedResults ));
519
+ }
517
520
518
- $ this ->assertTrue ($ authors ->diffAssoc ($ cachedResults )->isEmpty ());
519
- $ this ->assertTrue ($ liveResults ->diffAssoc ($ cachedResults )->isEmpty ());
521
+ public function testDoesntHaveWhereClaseParsing ()
522
+ {
523
+ $ authors = (new Author )
524
+ ->doesntHave ('books ' )
525
+ ->get ();
526
+
527
+ $ key = 'genealabslaravelmodelcachingtestsfixturesauthor_notexists_and_authors.id_=_books.author_id ' ;
528
+ $ tags = ['genealabslaravelmodelcachingtestsfixturesauthor ' ];
529
+
530
+ $ cachedResults = cache ()
531
+ ->tags ($ tags )
532
+ ->get ($ key );
533
+ $ liveResults = (new UncachedAuthor )
534
+ ->doesntHave ('books ' )
535
+ ->get ();
520
536
537
+ $ this ->assertEmpty ($ authors ->diffAssoc ($ cachedResults ));
538
+ $ this ->assertEmpty ($ liveResults ->diffAssoc ($ cachedResults ));
521
539
}
522
540
523
541
public function testColumnsRelationshipWhereClauseParsing ()
524
542
{
525
- $ author = (new Author )->orderBy ('name ' )->first ();
526
-
527
- $ authors = collect ([(new Author )->where ('name ' , '= ' , $ author ->name )->first ()]);
528
-
529
- $ key = 'genealabslaravelmodelcachingtestsfixturesauthor-name_ ' . $ author ->name . '-first ' ;
543
+ $ author = (new Author )
544
+ ->orderBy ('name ' )
545
+ ->first ();
546
+ $ authors = (new Author )
547
+ ->where ('name ' , '= ' , $ author ->name )
548
+ ->get ();
549
+ $ key = 'genealabslaravelmodelcachingtestsfixturesauthor-name_ ' .
550
+ $ author ->name ;
530
551
$ tags = ['genealabslaravelmodelcachingtestsfixturesauthor ' ];
531
552
532
- $ cachedResults = collect ([cache ()->tags ($ tags )->get ($ key )]);
533
-
534
- $ liveResults = collect ([(new UncachedAuthor )->where ('name ' , '= ' , $ author ->name )->first ()]);
553
+ $ cachedResults = cache ()
554
+ ->tags ($ tags )
555
+ ->get ($ key );
556
+ $ liveResults = (new UncachedAuthor )
557
+ ->where ('name ' , '= ' , $ author ->name )
558
+ ->get ();
535
559
536
560
$ this ->assertEmpty ($ authors ->diffAssoc ($ cachedResults ));
537
561
$ this ->assertEmpty ($ liveResults ->diffAssoc ($ cachedResults ));
0 commit comments