|
@@ 9-36 (lines=28) @@
|
| 6 |
|
|
| 7 |
|
class PolymorphicOneToOneTest extends IntegrationTestCase |
| 8 |
|
{ |
| 9 |
|
public function testEagerloadedRelationship() |
| 10 |
|
{ |
| 11 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:images:genealabslaravelmodelcachingtestsfixturesimage-images.imagable_id_inraw_2-images.imagable_type_=_GeneaLabs\LaravelModelCaching\Tests\Fixtures\User"); |
| 12 |
|
$tags = [ |
| 13 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesimage", |
| 14 |
|
]; |
| 15 |
|
|
| 16 |
|
$result = (new User) |
| 17 |
|
->with("image") |
| 18 |
|
->whereHas("image") |
| 19 |
|
->first() |
| 20 |
|
->image; |
| 21 |
|
$cachedResults = $this->cache() |
| 22 |
|
->tags($tags) |
| 23 |
|
->get($key)['value'] |
| 24 |
|
->first(); |
| 25 |
|
$liveResults = (new UncachedUser) |
| 26 |
|
->with("image") |
| 27 |
|
->whereHas("image") |
| 28 |
|
->first() |
| 29 |
|
->image; |
| 30 |
|
|
| 31 |
|
$this->assertEquals($liveResults->path, $result->path); |
| 32 |
|
$this->assertEquals($liveResults->path, $cachedResults->path); |
| 33 |
|
$this->assertNotEmpty($result); |
| 34 |
|
$this->assertNotEmpty($cachedResults); |
| 35 |
|
$this->assertNotEmpty($liveResults); |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
public function testLazyloadedHasOneThrough() |
| 39 |
|
{ |
|
@@ 38-63 (lines=26) @@
|
| 35 |
|
$this->assertNotEmpty($liveResults); |
| 36 |
|
} |
| 37 |
|
|
| 38 |
|
public function testLazyloadedHasOneThrough() |
| 39 |
|
{ |
| 40 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:images:genealabslaravelmodelcachingtestsfixturesimage-images.imagable_id_=_2-images.imagable_id_notnull-images.imagable_type_=_GeneaLabs\LaravelModelCaching\Tests\Fixtures\User-limit_1"); |
| 41 |
|
$tags = [ |
| 42 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesimage", |
| 43 |
|
]; |
| 44 |
|
|
| 45 |
|
$result = (new User) |
| 46 |
|
->whereHas("image") |
| 47 |
|
->first() |
| 48 |
|
->image; |
| 49 |
|
$cachedResults = $this->cache() |
| 50 |
|
->tags($tags) |
| 51 |
|
->get($key)['value'] |
| 52 |
|
->first(); |
| 53 |
|
$liveResults = (new UncachedUser) |
| 54 |
|
->whereHas("image") |
| 55 |
|
->first() |
| 56 |
|
->image; |
| 57 |
|
|
| 58 |
|
$this->assertEquals($liveResults->path, $result->path); |
| 59 |
|
$this->assertEquals($liveResults->path, $cachedResults->path); |
| 60 |
|
$this->assertNotEmpty($result); |
| 61 |
|
$this->assertNotEmpty($cachedResults); |
| 62 |
|
$this->assertNotEmpty($liveResults); |
| 63 |
|
} |
| 64 |
|
} |
| 65 |
|
|