| @@ 35-57 (lines=23) @@ | ||
| 32 | $this->assertNotEmpty($liveResults); |
|
| 33 | } |
|
| 34 | ||
| 35 | public function testLazyloadedHasMany() |
|
| 36 | { |
|
| 37 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:books:genealabslaravelmodelcachingtestsfixturesbook-books.author_id_=_1-books.author_id_notnull"); |
|
| 38 | $tags = [ |
|
| 39 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
|
| 40 | ]; |
|
| 41 | ||
| 42 | $books = (new Author) |
|
| 43 | ->find(1) |
|
| 44 | ->books; |
|
| 45 | $cachedResults = $this->cache() |
|
| 46 | ->tags($tags) |
|
| 47 | ->get($key)['value']; |
|
| 48 | $liveResults = (new UncachedAuthor) |
|
| 49 | ->find(1) |
|
| 50 | ->books; |
|
| 51 | ||
| 52 | $this->assertEquals($liveResults->pluck("id"), $books->pluck("id")); |
|
| 53 | $this->assertEquals($liveResults->pluck("id"), $cachedResults->pluck("id")); |
|
| 54 | $this->assertNotEmpty($books); |
|
| 55 | $this->assertNotEmpty($cachedResults); |
|
| 56 | $this->assertNotEmpty($liveResults); |
|
| 57 | } |
|
| 58 | } |
|
| 59 | ||
| @@ 9-29 (lines=21) @@ | ||
| 6 | ||
| 7 | class CachePrefixingTest extends IntegrationTestCase |
|
| 8 | { |
|
| 9 | public function testDatabaseKeyingEnabled() |
|
| 10 | { |
|
| 11 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-first"); |
|
| 12 | $tags = [ |
|
| 13 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
|
| 14 | ]; |
|
| 15 | ||
| 16 | $author = (new Author) |
|
| 17 | ->first(); |
|
| 18 | $cachedResults = $this->cache() |
|
| 19 | ->tags($tags) |
|
| 20 | ->get($key)['value']; |
|
| 21 | $liveResults = (new UncachedAuthor) |
|
| 22 | ->first(); |
|
| 23 | ||
| 24 | $this->assertEquals($liveResults->pluck("id"), $author->pluck("id")); |
|
| 25 | $this->assertEquals($liveResults->pluck("id"), $cachedResults->pluck("id")); |
|
| 26 | $this->assertNotEmpty($author); |
|
| 27 | $this->assertNotEmpty($cachedResults); |
|
| 28 | $this->assertNotEmpty($liveResults); |
|
| 29 | } |
|
| 30 | ||
| 31 | public function testDatabaseKeyingDisabled() |
|
| 32 | { |
|