@@ -537,7 +537,7 @@ public function testExistsRelationshipWhereClauseParsing()
537537 $ this ->assertEmpty ($ liveResults ->diffAssoc ($ cachedResults ));
538538 }
539539
540- public function testDoesntHaveWhereClaseParsing ()
540+ public function testDoesntHaveWhereClauseParsing ()
541541 {
542542 $ authors = (new Author )
543543 ->doesntHave ('books ' )
@@ -583,7 +583,8 @@ public function testColumnsRelationshipWhereClauseParsing()
583583 public function testRawWhereClauseParsing ()
584584 {
585585 $ authors = collect ([(new Author )
586- ->whereRaw ('name <> \'\'' )->first ()]);
586+ ->whereRaw ('name <> \'\'' )
587+ ->first ()]);
587588
588589 $ key = 'genealabslaravelmodelcachingtestsfixturesauthor_and_name-first ' ;
589590 $ tags = ['genealabslaravelmodelcachingtestsfixturesauthor ' ];
@@ -596,4 +597,46 @@ public function testRawWhereClauseParsing()
596597 $ this ->assertTrue ($ authors ->diffAssoc ($ cachedResults )->isEmpty ());
597598 $ this ->assertTrue ($ liveResults ->diffAssoc ($ cachedResults )->isEmpty ());
598599 }
600+
601+ public function testScopeClauseParsing ()
602+ {
603+ $ author = factory (Author::class, 1 )
604+ ->create (['name ' => 'Anton ' ])
605+ ->first ();
606+ $ authors = (new Author )
607+ ->startsWithA ()
608+ ->get ();
609+ $ key = 'genealabslaravelmodelcachingtestsfixturesauthor-name_A% ' ;
610+ $ tags = ['genealabslaravelmodelcachingtestsfixturesauthor ' ];
611+
612+ $ cachedResults = cache ()->tags ($ tags )->get ($ key );
613+ $ liveResults = (new UncachedAuthor )
614+ ->startsWithA ()
615+ ->get ();
616+
617+ $ this ->assertTrue ($ authors ->contains ($ author ));
618+ $ this ->assertTrue ($ cachedResults ->contains ($ author ));
619+ $ this ->assertTrue ($ liveResults ->contains ($ author ));
620+ }
621+
622+ public function testRelationshipQueriesAreCached ()
623+ {
624+ $ books = (new Author )
625+ ->first ()
626+ ->books ()
627+ ->get ();
628+ $ key = 'genealabslaravelmodelcachingtestsfixturesbook-books.author_id_1-books.author_id_notnull ' ;
629+ $ tags = [
630+ 'genealabslaravelmodelcachingtestsfixturesbook '
631+ ];
632+
633+ $ cachedResults = cache ()->tags ($ tags )->get ($ key );
634+ $ liveResults = (new UncachedAuthor )
635+ ->first ()
636+ ->books ()
637+ ->get ();
638+
639+ $ this ->assertTrue ($ cachedResults ->diffAssoc ($ books )->isEmpty ());
640+ $ this ->assertTrue ($ liveResults ->diffAssoc ($ books )->isEmpty ());
641+ }
599642}
0 commit comments