1
|
|
|
<?php namespace GeneaLabs\LaravelModelCaching\Tests\Integration\CachedBuilder; |
2
|
|
|
|
3
|
|
|
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\Author; |
4
|
|
|
use GeneaLabs\LaravelModelCaching\Tests\Fixtures\UncachedAuthor; |
5
|
|
|
use GeneaLabs\LaravelModelCaching\Tests\IntegrationTestCase; |
6
|
|
|
|
7
|
|
View Code Duplication |
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
|
|
|
|