@@ -36,10 +36,15 @@ public function test_cache_tags()
3636 $ post = factory (Post::class)->create ();
3737 $ storedPost = Post::cacheFor (now ()->addHours (1 ))->cacheTags (['test ' ])->first ();
3838
39- $ cache = Cache::get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
40- $ this ->assertNull ($ cache );
39+ $ cache = $ this ->getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
40+
41+ // The caches that do not support tagging should
42+ // cache the query either way.
43+ $ this ->driverSupportsTags ()
44+ ? $ this ->assertNull ($ cache )
45+ : $ this ->assertNotNull ($ cache );
4146
42- $ cache = Cache:: tags ([ ' test ' ])-> get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
47+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' , [ ' test ' ] );
4348 $ this ->assertNotNull ($ cache );
4449 }
4550
@@ -48,12 +53,12 @@ public function test_cache_flush_with_the_right_tag()
4853 $ post = factory (Post::class)->create ();
4954 $ storedPost = Post::cacheFor (now ()->addHours (1 ))->cacheTags (['test ' ])->first ();
5055
51- $ cache = Cache:: tags ([ ' test ' ])-> get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
56+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' , [ ' test ' ] );
5257 $ this ->assertNotNull ($ cache );
5358
5459 Post::flushQueryCache (['test ' ]);
5560
56- $ cache = Cache:: tags ([ ' test ' ])-> get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
61+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' , [ ' test ' ] );
5762 $ this ->assertNull ($ cache );
5863 }
5964
@@ -62,22 +67,27 @@ public function test_cache_flush_without_the_right_tag()
6267 $ post = factory (Post::class)->create ();
6368 $ storedPost = Post::cacheFor (now ()->addHours (1 ))->cacheTags (['test ' ])->first ();
6469
65- $ cache = Cache:: tags ([ ' test ' ])-> get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
70+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' , [ ' test ' ] );
6671 $ this ->assertNotNull ($ cache );
6772
6873 Post::flushQueryCache (['test2 ' ]);
6974 Post::flushQueryCacheWithTag ('test2 ' );
7075
71- $ cache = Cache::tags (['test ' ])->get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
72- $ this ->assertNotNull ($ cache );
76+ $ cache = $ this ->getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' , ['test ' ]);
77+
78+ // The caches that do not support tagging should
79+ // flush the cache either way since tags are not supported.
80+ $ this ->driverSupportsTags ()
81+ ? $ this ->assertNotNull ($ cache )
82+ : $ this ->assertNull ($ cache );
7383 }
7484
7585 public function test_cache_flush_with_more_tags ()
7686 {
7787 $ post = factory (Post::class)->create ();
7888 $ storedPost = Post::cacheFor (now ()->addHours (1 ))->cacheTags (['test ' ])->first ();
7989
80- $ cache = Cache:: tags ([ ' test ' ])-> get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
90+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' , [ ' test ' ] );
8191 $ this ->assertNotNull ($ cache );
8292
8393 Post::flushQueryCache ([
@@ -86,7 +96,7 @@ public function test_cache_flush_with_more_tags()
8696 'test3 ' ,
8797 ]);
8898
89- $ cache = Cache:: tags ([ ' test ' ])-> get ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' );
99+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "posts" limit 1a:0:{} ' , [ ' test ' ] );
90100 $ this ->assertNull ($ cache );
91101 }
92102
@@ -95,12 +105,12 @@ public function test_cache_flush_with_default_tags_attached()
95105 $ book = factory (Book::class)->create ();
96106 $ storedBook = Book::cacheFor (now ()->addHours (1 ))->cacheTags (['test ' ])->first ();
97107
98- $ cache = Cache:: tags ([ ' test ' , Book:: getCacheBaseTags ()[ 0 ]])-> get ('leqc:sqlitegetselect * from "books" limit 1a:0:{} ' );
108+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "books" limit 1a:0:{} ' , [ ' test ' , Book:: getCacheBaseTags ()[ 0 ]] );
99109 $ this ->assertNotNull ($ cache );
100110
101111 Book::flushQueryCache ();
102112
103- $ cache = Cache:: tags ([ ' test ' , Book:: getCacheBaseTags ()[ 0 ]])-> get ('leqc:sqlitegetselect * from "books" limit 1a:0:{} ' );
113+ $ cache = $ this -> getCacheWithTags ('leqc:sqlitegetselect * from "books" limit 1a:0:{} ' , [ ' test ' , Book:: getCacheBaseTags ()[ 0 ]] );
104114
105115 $ this ->assertNull ($ cache );
106116 }
0 commit comments