| @@ 456-478 (lines=23) @@ | ||
| 453 | $this->assertEmpty($liveResults->diffKeys($cachedResults)); |
|
| 454 | } |
|
| 455 | ||
| 456 | public function testNestedRelationshipWhereClauseParsing() |
|
| 457 | { |
|
| 458 | $authors = (new Author) |
|
| 459 | ->with('books.publisher') |
|
| 460 | ->get(); |
|
| 461 | ||
| 462 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-books.publisher"); |
|
| 463 | $tags = [ |
|
| 464 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
|
| 465 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
|
| 466 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturespublisher", |
|
| 467 | ]; |
|
| 468 | ||
| 469 | $cachedResults = $this->cache() |
|
| 470 | ->tags($tags) |
|
| 471 | ->get($key)['value']; |
|
| 472 | ||
| 473 | $liveResults = (new UncachedAuthor)->with('books.publisher') |
|
| 474 | ->get(); |
|
| 475 | ||
| 476 | $this->assertEmpty($authors->diffKeys($cachedResults)); |
|
| 477 | $this->assertEmpty($liveResults->diffKeys($cachedResults)); |
|
| 478 | } |
|
| 479 | ||
| 480 | public function testExistsRelationshipWhereClauseParsing() |
|
| 481 | { |
|
| @@ 154-176 (lines=23) @@ | ||
| 151 | $this->assertNull($cachedResult); |
|
| 152 | } |
|
| 153 | ||
| 154 | public function testGetModelResultsIsNotCached() |
|
| 155 | { |
|
| 156 | $authors = (new Author) |
|
| 157 | ->with('books', 'profile') |
|
| 158 | ->disableCache() |
|
| 159 | ->get(); |
|
| 160 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile"); |
|
| 161 | $tags = [ |
|
| 162 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
| 163 | 'genealabslaravelmodelcachingtestsfixturesbook', |
|
| 164 | 'genealabslaravelmodelcachingtestsfixturesprofile', |
|
| 165 | ]; |
|
| 166 | ||
| 167 | $cachedResults = $this->cache() |
|
| 168 | ->tags($tags) |
|
| 169 | ->get($key); |
|
| 170 | $liveResults = (new UncachedAuthor) |
|
| 171 | ->with('books', 'profile') |
|
| 172 | ->get(); |
|
| 173 | ||
| 174 | $this->assertEmpty($liveResults->diffKeys($authors)); |
|
| 175 | $this->assertNull($cachedResults); |
|
| 176 | } |
|
| 177 | ||
| 178 | public function testMaxModelResultsIsNotCached() |
|
| 179 | { |
|
| @@ 27-50 (lines=24) @@ | ||
| 24 | $this->assertNull($cachedResults); |
|
| 25 | } |
|
| 26 | ||
| 27 | public function testCacheCanBeDisabledOnQuery() |
|
| 28 | { |
|
| 29 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-testing:{$this->testingSqlitePath}testing.sqlite:books"); |
|
| 30 | $tags = [ |
|
| 31 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
|
| 32 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
|
| 33 | ]; |
|
| 34 | $authors = (new Author) |
|
| 35 | ->with('books') |
|
| 36 | ->disableCache() |
|
| 37 | ->get() |
|
| 38 | ->keyBy("id"); |
|
| 39 | ||
| 40 | $cachedResults = $this->cache() |
|
| 41 | ->tags($tags) |
|
| 42 | ->get($key); |
|
| 43 | $liveResults = (new UncachedAuthor) |
|
| 44 | ->with('books') |
|
| 45 | ->get() |
|
| 46 | ->keyBy("id"); |
|
| 47 | ||
| 48 | $this->assertNull($cachedResults); |
|
| 49 | $this->assertEmpty($liveResults->diffKeys($authors)); |
|
| 50 | } |
|
| 51 | } |
|
| 52 | ||