@@ 107-123 (lines=17) @@ | ||
104 | $this->assertNull($results); |
|
105 | } |
|
106 | ||
107 | public function testHasManyRelationshipIsCached() |
|
108 | { |
|
109 | $authors = (new Author)->with('books')->get(); |
|
110 | $authorIds = implode('_', $authors->pluck('id')->toArray()); |
|
111 | ||
112 | $results = collect(cache()->tags([ |
|
113 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
114 | 'genealabslaravelmodelcachingtestsfixturesbook' |
|
115 | ]) |
|
116 | ->get("genealabslaravelmodelcachingtestsfixturesauthor_{$authorIds}-genealabslaravelmodelcachingtestsfixturesbooks")); |
|
117 | ||
118 | $this->assertNotNull($results); |
|
119 | $this->assertEmpty($authors->diffAssoc($results)); |
|
120 | $this->assertNotEmpty($authors); |
|
121 | $this->assertNotEmpty($results); |
|
122 | $this->assertEquals($authors->count(), $results->count()); |
|
123 | } |
|
124 | ||
125 | public function testBelongsToRelationshipIsCached() |
|
126 | { |
|
@@ 125-141 (lines=17) @@ | ||
122 | $this->assertEquals($authors->count(), $results->count()); |
|
123 | } |
|
124 | ||
125 | public function testBelongsToRelationshipIsCached() |
|
126 | { |
|
127 | $books = (new Book)->with('author')->get(); |
|
128 | $bookIds = implode('_', $books->pluck('id')->toArray()); |
|
129 | ||
130 | $results = collect(cache()->tags([ |
|
131 | 'genealabslaravelmodelcachingtestsfixturesbook', |
|
132 | 'genealabslaravelmodelcachingtestsfixturesauthor' |
|
133 | ]) |
|
134 | ->get("genealabslaravelmodelcachingtestsfixturesbook_{$bookIds}-genealabslaravelmodelcachingtestsfixturesauthors")); |
|
135 | ||
136 | $this->assertNotNull($results); |
|
137 | $this->assertEmpty($books->diffAssoc($results)); |
|
138 | $this->assertNotEmpty($books); |
|
139 | $this->assertNotEmpty($results); |
|
140 | $this->assertEquals($books->count(), $results->count()); |
|
141 | } |
|
142 | ||
143 | public function testBelongsToManyRelationshipIsCached() |
|
144 | { |
|
@@ 143-159 (lines=17) @@ | ||
140 | $this->assertEquals($books->count(), $results->count()); |
|
141 | } |
|
142 | ||
143 | public function testBelongsToManyRelationshipIsCached() |
|
144 | { |
|
145 | $books = (new Book)->with('stores')->get(); |
|
146 | $bookIds = implode('_', $books->pluck('id')->toArray()); |
|
147 | ||
148 | $results = collect(cache()->tags([ |
|
149 | 'genealabslaravelmodelcachingtestsfixturesbook', |
|
150 | 'genealabslaravelmodelcachingtestsfixturesstore' |
|
151 | ]) |
|
152 | ->get("genealabslaravelmodelcachingtestsfixturesbook_{$bookIds}-genealabslaravelmodelcachingtestsfixturesstores")); |
|
153 | ||
154 | $this->assertNotNull($results); |
|
155 | $this->assertEmpty($books->diffAssoc($results)); |
|
156 | $this->assertNotEmpty($books); |
|
157 | $this->assertNotEmpty($results); |
|
158 | $this->assertEquals($books->count(), $results->count()); |
|
159 | } |
|
160 | ||
161 | public function testHasOneRelationshipIsCached() |
|
162 | { |
|
@@ 161-178 (lines=18) @@ | ||
158 | $this->assertEquals($books->count(), $results->count()); |
|
159 | } |
|
160 | ||
161 | public function testHasOneRelationshipIsCached() |
|
162 | { |
|
163 | $authors = (new Author)->with('profile')->get(); |
|
164 | $authorIds = implode('_', $authors->pluck('id')->toArray()); |
|
165 | ||
166 | $results = collect(cache() |
|
167 | ->tags([ |
|
168 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
169 | 'genealabslaravelmodelcachingtestsfixturesprofile' |
|
170 | ]) |
|
171 | ->get("genealabslaravelmodelcachingtestsfixturesauthor_{$authorIds}-genealabslaravelmodelcachingtestsfixturesprofiles")); |
|
172 | ||
173 | $this->assertNotNull($results); |
|
174 | $this->assertEmpty($authors->diffAssoc($results)); |
|
175 | $this->assertNotEmpty($authors); |
|
176 | $this->assertNotEmpty($results); |
|
177 | $this->assertEquals($authors->count(), $results->count()); |
|
178 | } |
|
179 | } |
|
180 |