|
| 1 | +<?php namespace GeneaLabs\LaravelModelCaching\Tests\Integration\CachedBuilder; |
| 2 | + |
| 3 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author; |
| 4 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Book; |
| 5 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Publisher; |
| 6 | +use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor; |
| 7 | +use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase; |
| 8 | + |
| 9 | +class HasOneThroughTest extends IntegrationTestCase |
| 10 | +{ |
| 11 | + public function testEagerloadedHasOneThrough() |
| 12 | + { |
| 13 | + $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:printer-first"); |
| 14 | + $tags = [ |
| 15 | + "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 16 | + "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprinter", |
| 17 | + ]; |
| 18 | + |
| 19 | + $printer = (new Author) |
| 20 | + ->with("printer") |
| 21 | + ->find(1) |
| 22 | + ->printer; |
| 23 | + $cachedResults = $this->cache() |
| 24 | + ->tags($tags) |
| 25 | + ->get($key)['value'] |
| 26 | + ->printer; |
| 27 | + $liveResults = (new UncachedAuthor) |
| 28 | + ->with("printer") |
| 29 | + ->find(1) |
| 30 | + ->printer; |
| 31 | + |
| 32 | + $this->assertEquals($liveResults->id, $printer->id); |
| 33 | + $this->assertEquals($liveResults->id, $cachedResults->id); |
| 34 | + $this->assertNotEmpty($printer); |
| 35 | + $this->assertNotEmpty($cachedResults); |
| 36 | + $this->assertNotEmpty($liveResults); |
| 37 | + } |
| 38 | + |
| 39 | + public function testLazyloadedHasMany() |
| 40 | + { |
| 41 | + $key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-authors.id_=_1-limit_1"); |
| 42 | + $tags = [ |
| 43 | + "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 44 | + "genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprinter", |
| 45 | + ]; |
| 46 | + |
| 47 | + // $printer = (new Author) |
| 48 | + // ->find(1) |
| 49 | + // ->printer; |
| 50 | + // $cachedResults = $this->cache() |
| 51 | + // ->tags($tags) |
| 52 | + // ->get($key)['value'] |
| 53 | + // ->printer; |
| 54 | + // $liveResults = (new UncachedAuthor) |
| 55 | + // ->find(1) |
| 56 | + // ->printer; |
| 57 | + |
| 58 | + // $this->assertEquals($liveResults->id, $printer->id); |
| 59 | + // $this->assertEquals($liveResults->id, $cachedResults->id); |
| 60 | + // $this->assertNotEmpty($printer); |
| 61 | + // $this->assertNotEmpty($cachedResults); |
| 62 | + // $this->assertNotEmpty($liveResults); |
| 63 | + $this->markTestSkipped(); |
| 64 | + } |
| 65 | +} |
0 commit comments