|
| 1 | +<?php namespace GeneaLabs\LaravelModelCaching\Tests\Integration\CachedBuilder; |
| 2 | + |
| 3 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Post; |
| 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 | +} |
0 commit comments