| @@ 7-65 (lines=59) @@ | ||
| 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor; |
|
| 5 | use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase; |
|
| 6 | ||
| 7 | class HasManyThroughTest extends IntegrationTestCase |
|
| 8 | { |
|
| 9 | public function testEagerloadedHasManyThrough() |
|
| 10 | { |
|
| 11 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:printers-first"); |
|
| 12 | $tags = [ |
|
| 13 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
|
| 14 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprinter", |
|
| 15 | ]; |
|
| 16 | ||
| 17 | $printers = (new Author) |
|
| 18 | ->with("printers") |
|
| 19 | ->first() |
|
| 20 | ->printers; |
|
| 21 | $cachedResults = $this->cache() |
|
| 22 | ->tags($tags) |
|
| 23 | ->get($key)['value'] |
|
| 24 | ->first() |
|
| 25 | ->printers; |
|
| 26 | $liveResults = (new UncachedAuthor) |
|
| 27 | ->with("printers") |
|
| 28 | ->first() |
|
| 29 | ->printers; |
|
| 30 | ||
| 31 | $this->assertEquals($liveResults->pluck("id")->toArray(), $printers->pluck("id")->toArray()); |
|
| 32 | $this->assertEquals($liveResults->pluck("id")->toArray(), $cachedResults->pluck("id")->toArray()); |
|
| 33 | $this->assertNotEmpty($printers); |
|
| 34 | $this->assertNotEmpty($cachedResults); |
|
| 35 | $this->assertNotEmpty($liveResults); |
|
| 36 | } |
|
| 37 | ||
| 38 | public function testLazyloadedHasManyThrough() |
|
| 39 | { |
|
| 40 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-authors.id_=_1-testing:{$this->testingSqlitePath}testing.sqlite:printers-limit_1"); |
|
| 41 | $tags = [ |
|
| 42 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
|
| 43 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprinter", |
|
| 44 | ]; |
|
| 45 | ||
| 46 | // $printers = (new Author) |
|
| 47 | // ->find(1) |
|
| 48 | // ->printers; |
|
| 49 | // $cachedResults = $this->cache() |
|
| 50 | // ->tags($tags) |
|
| 51 | // ->get($key)['value'] |
|
| 52 | // ->first() |
|
| 53 | // ->printers; |
|
| 54 | // $liveResults = (new UncachedAuthor) |
|
| 55 | // ->find(1) |
|
| 56 | // ->printers; |
|
| 57 | ||
| 58 | // $this->assertEquals($liveResults->pluck("id")->toArray(), $printers->pluck("id")->toArray()); |
|
| 59 | // $this->assertEquals($liveResults->pluck("id")->toArray(), $cachedResults->pluck("id")->toArray()); |
|
| 60 | // $this->assertNotEmpty($printers); |
|
| 61 | // $this->assertNotEmpty($cachedResults); |
|
| 62 | // $this->assertNotEmpty($liveResults); |
|
| 63 | $this->markTestSkipped(); |
|
| 64 | } |
|
| 65 | } |
|
| 66 | ||
| @@ 7-63 (lines=57) @@ | ||
| 4 | use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedPost; |
|
| 5 | use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase; |
|
| 6 | ||
| 7 | class PolymorphicManyToManyTest extends IntegrationTestCase |
|
| 8 | { |
|
| 9 | public function testEagerloadedRelationship() |
|
| 10 | { |
|
| 11 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:posts:genealabslaravelmodelcachingtestsfixturespost-testing:{$this->testingSqlitePath}testing.sqlite:tags-first"); |
|
| 12 | $tags = [ |
|
| 13 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturespost", |
|
| 14 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturestag", |
|
| 15 | ]; |
|
| 16 | ||
| 17 | $result = (new Post) |
|
| 18 | ->with("tags") |
|
| 19 | ->first() |
|
| 20 | ->tags; |
|
| 21 | $cachedResults = $this->cache() |
|
| 22 | ->tags($tags) |
|
| 23 | ->get($key)['value']; |
|
| 24 | $liveResults = (new UncachedPost) |
|
| 25 | ->with("tags") |
|
| 26 | ->first() |
|
| 27 | ->tags; |
|
| 28 | ||
| 29 | $this->assertEquals($liveResults->pluck("id")->toArray(), $result->pluck("id")->toArray()); |
|
| 30 | $this->assertEquals($liveResults->pluck("id")->toArray(), $cachedResults->pluck("id")->toArray()); |
|
| 31 | $this->assertNotEmpty($result); |
|
| 32 | $this->assertNotEmpty($cachedResults); |
|
| 33 | $this->assertNotEmpty($liveResults); |
|
| 34 | } |
|
| 35 | ||
| 36 | public function testLazyloadedRelationship() |
|
| 37 | { |
|
| 38 | $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:posts:genealabslaravelmodelcachingtestsfixturespost-testing:{$this->testingSqlitePath}testing.sqlite:tags-first"); |
|
| 39 | $tags = [ |
|
| 40 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturespost", |
|
| 41 | "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturestag", |
|
| 42 | ]; |
|
| 43 | ||
| 44 | // $result = (new Post) |
|
| 45 | // ->with("tags") |
|
| 46 | // ->first() |
|
| 47 | // ->tags; |
|
| 48 | // $cachedResults = $this->cache() |
|
| 49 | // ->tags($tags) |
|
| 50 | // ->get($key)['value']; |
|
| 51 | // $liveResults = (new UncachedPost) |
|
| 52 | // ->with("tags") |
|
| 53 | // ->first() |
|
| 54 | // ->tags; |
|
| 55 | ||
| 56 | // $this->assertEquals($liveResults->pluck("id")->toArray(), $result->pluck("id")->toArray()); |
|
| 57 | // $this->assertEquals($liveResults->pluck("id")->toArray(), $cachedResults->pluck("id")->toArray()); |
|
| 58 | // $this->assertNotEmpty($result); |
|
| 59 | // $this->assertNotEmpty($cachedResults); |
|
| 60 | // $this->assertNotEmpty($liveResults); |
|
| 61 | $this->markTestSkipped(); |
|
| 62 | } |
|
| 63 | } |
|
| 64 | ||