@@ -13,6 +13,8 @@ public function setUp()
13
13
{
14
14
parent ::setUp ();
15
15
16
+ cache ()->flush ();
17
+
16
18
factory (Author::class, 10 )->create ()
17
19
->each (function ($ author ) {
18
20
factory (Book::class, random_int (2 , 10 ))->make ()
@@ -25,22 +27,54 @@ public function setUp()
25
27
26
28
public function testCacheIsEmptyBeforeLoadingModels ()
27
29
{
28
- $ this ->assertNull (cache ()->get ('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks ' ));
30
+ $ results = cache ()->tags ([
31
+ 'genealabslaravelmodelcachingtestsfixturesauthor ' ,
32
+ 'genealabslaravelmodelcachingtestsfixturesbook '
33
+ ])
34
+ ->get ('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks ' );
35
+
36
+ $ this ->assertNull ($ results );
29
37
}
30
38
31
39
public function testCacheIsNotEmptyAfterLoadingModels ()
32
40
{
33
- (new Author )->with ('books ' )->get ();
41
+ (new Author )->with ('books ' )->get ()->first ();
42
+
43
+ $ results = cache ()->tags ([
44
+ 'genealabslaravelmodelcachingtestsfixturesauthor ' ,
45
+ 'genealabslaravelmodelcachingtestsfixturesbook '
46
+ ])
47
+ ->get ('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks ' );
34
48
35
- $ this ->assertNotNull (cache ()-> get ( ' genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks ' ) );
49
+ $ this ->assertNotNull ($ results );
36
50
}
37
51
38
- public function testChangingModelClearsCache ()
52
+ public function testCreatingModelClearsCache ()
39
53
{
40
- $ author = (new Author )->with ('books ' )->first ();
54
+ $ author = (new Author )->with ('books ' )->get ()-> first ();
41
55
$ author ->name = "John Jinglheimer " ;
42
56
$ author ->save ();
43
57
44
- $ this ->assertNull (cache ()->get ('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks ' ));
58
+ $ results = cache ()->tags ([
59
+ 'genealabslaravelmodelcachingtestsfixturesauthor ' ,
60
+ 'genealabslaravelmodelcachingtestsfixturesbook '
61
+ ])
62
+ ->get ('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks ' );
63
+
64
+ $ this ->assertNull ($ results );
65
+ }
66
+
67
+ public function testDeletingModelClearsCache ()
68
+ {
69
+ $ author = (new Author )->with ('books ' )->get ()->first ();
70
+ $ author ->delete ();
71
+
72
+ $ results = cache ()->tags ([
73
+ 'genealabslaravelmodelcachingtestsfixturesauthor ' ,
74
+ 'genealabslaravelmodelcachingtestsfixturesbook '
75
+ ])
76
+ ->get ('genealabslaravelmodelcachingtestsfixturesauthor_1_2_3_4_5_6_7_8_9_10-genealabslaravelmodelcachingtestsfixturesbooks ' );
77
+
78
+ $ this ->assertNull ($ results );
45
79
}
46
80
}
0 commit comments