@@ -537,7 +537,7 @@ public function testExistsRelationshipWhereClauseParsing()
537
537
$ this ->assertEmpty ($ liveResults ->diffAssoc ($ cachedResults ));
538
538
}
539
539
540
- public function testDoesntHaveWhereClaseParsing ()
540
+ public function testDoesntHaveWhereClauseParsing ()
541
541
{
542
542
$ authors = (new Author )
543
543
->doesntHave ('books ' )
@@ -583,7 +583,8 @@ public function testColumnsRelationshipWhereClauseParsing()
583
583
public function testRawWhereClauseParsing ()
584
584
{
585
585
$ authors = collect ([(new Author )
586
- ->whereRaw ('name <> \'\'' )->first ()]);
586
+ ->whereRaw ('name <> \'\'' )
587
+ ->first ()]);
587
588
588
589
$ key = 'genealabslaravelmodelcachingtestsfixturesauthor_and_name-first ' ;
589
590
$ tags = ['genealabslaravelmodelcachingtestsfixturesauthor ' ];
@@ -596,4 +597,46 @@ public function testRawWhereClauseParsing()
596
597
$ this ->assertTrue ($ authors ->diffAssoc ($ cachedResults )->isEmpty ());
597
598
$ this ->assertTrue ($ liveResults ->diffAssoc ($ cachedResults )->isEmpty ());
598
599
}
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
+ }
599
642
}
0 commit comments