@@ 200-216 (lines=17) @@ | ||
197 | $this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
|
198 | } |
|
199 | ||
200 | public function testAvgModelResultsCreatesCache() |
|
201 | { |
|
202 | $authorId = (new Author)->with('books', 'profile') |
|
203 | ->avg('id'); |
|
204 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor-avg_id'; |
|
205 | $tags = [ |
|
206 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
207 | ]; |
|
208 | ||
209 | $cachedResult = cache()->tags($tags) |
|
210 | ->get($key); |
|
211 | $liveResult = (new UncachedAuthor)->with('books', 'profile') |
|
212 | ->avg('id'); |
|
213 | ||
214 | $this->assertEquals($authorId, $cachedResult); |
|
215 | $this->assertEquals($liveResult, $cachedResult); |
|
216 | } |
|
217 | ||
218 | public function testChunkModelResultsCreatesCache() |
|
219 | { |
|
@@ 260-276 (lines=17) @@ | ||
257 | } |
|
258 | } |
|
259 | ||
260 | public function testCountModelResultsCreatesCache() |
|
261 | { |
|
262 | $authors = (new Author)->with('books', 'profile') |
|
263 | ->count(); |
|
264 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor-count'; |
|
265 | $tags = [ |
|
266 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
267 | ]; |
|
268 | ||
269 | $cachedResults = cache()->tags($tags) |
|
270 | ->get($key); |
|
271 | $liveResults = (new UncachedAuthor)->with('books', 'profile') |
|
272 | ->count(); |
|
273 | ||
274 | $this->assertEquals($authors, $cachedResults); |
|
275 | $this->assertEquals($liveResults, $cachedResults); |
|
276 | } |
|
277 | ||
278 | public function testCursorModelResultsCreatesCache() |
|
279 | { |
|
@@ 278-294 (lines=17) @@ | ||
275 | $this->assertEquals($liveResults, $cachedResults); |
|
276 | } |
|
277 | ||
278 | public function testCursorModelResultsCreatesCache() |
|
279 | { |
|
280 | $authors = (new Author)->with('books', 'profile') |
|
281 | ->cursor(); |
|
282 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor-cursor'; |
|
283 | $tags = [ |
|
284 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
285 | ]; |
|
286 | ||
287 | $cachedResults = cache()->tags($tags) |
|
288 | ->get($key); |
|
289 | $liveResults = collect((new UncachedAuthor)->with('books', 'profile') |
|
290 | ->cursor()); |
|
291 | ||
292 | $this->assertEmpty($authors->diffAssoc($cachedResults)); |
|
293 | $this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
|
294 | } |
|
295 | ||
296 | public function testFindModelResultsCreatesCache() |
|
297 | { |
|
@@ 312-330 (lines=19) @@ | ||
309 | $this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
|
310 | } |
|
311 | ||
312 | public function testGetModelResultsCreatesCache() |
|
313 | { |
|
314 | $authors = (new Author)->with('books', 'profile') |
|
315 | ->get(); |
|
316 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor-books-profile'; |
|
317 | $tags = [ |
|
318 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
319 | 'genealabslaravelmodelcachingtestsfixturesbook', |
|
320 | 'genealabslaravelmodelcachingtestsfixturesprofile', |
|
321 | ]; |
|
322 | ||
323 | $cachedResults = cache()->tags($tags) |
|
324 | ->get($key); |
|
325 | $liveResults = (new UncachedAuthor)->with('books', 'profile') |
|
326 | ->get(); |
|
327 | ||
328 | $this->assertEquals($authors, $cachedResults); |
|
329 | $this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
|
330 | } |
|
331 | ||
332 | public function testMaxModelResultsCreatesCache() |
|
333 | { |
|
@@ 332-348 (lines=17) @@ | ||
329 | $this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
|
330 | } |
|
331 | ||
332 | public function testMaxModelResultsCreatesCache() |
|
333 | { |
|
334 | $authorId = (new Author)->with('books', 'profile') |
|
335 | ->max('id'); |
|
336 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor-max_id'; |
|
337 | $tags = [ |
|
338 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
339 | ]; |
|
340 | ||
341 | $cachedResult = cache()->tags($tags) |
|
342 | ->get($key); |
|
343 | $liveResult = (new UncachedAuthor)->with('books', 'profile') |
|
344 | ->max('id'); |
|
345 | ||
346 | $this->assertEquals($authorId, $cachedResult); |
|
347 | $this->assertEquals($liveResult, $cachedResult); |
|
348 | } |
|
349 | ||
350 | public function testMinModelResultsCreatesCache() |
|
351 | { |
|
@@ 350-366 (lines=17) @@ | ||
347 | $this->assertEquals($liveResult, $cachedResult); |
|
348 | } |
|
349 | ||
350 | public function testMinModelResultsCreatesCache() |
|
351 | { |
|
352 | $authorId = (new Author)->with('books', 'profile') |
|
353 | ->min('id'); |
|
354 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor-min_id'; |
|
355 | $tags = [ |
|
356 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
357 | ]; |
|
358 | ||
359 | $cachedResult = cache()->tags($tags) |
|
360 | ->get($key); |
|
361 | $liveResult = (new UncachedAuthor)->with('books', 'profile') |
|
362 | ->min('id'); |
|
363 | ||
364 | $this->assertEquals($authorId, $cachedResult); |
|
365 | $this->assertEquals($liveResult, $cachedResult); |
|
366 | } |
|
367 | ||
368 | public function testPluckModelResultsCreatesCache() |
|
369 | { |
|
@@ 368-386 (lines=19) @@ | ||
365 | $this->assertEquals($liveResult, $cachedResult); |
|
366 | } |
|
367 | ||
368 | public function testPluckModelResultsCreatesCache() |
|
369 | { |
|
370 | $authors = (new Author)->with('books', 'profile') |
|
371 | ->pluck('id'); |
|
372 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor_id-books-profile-pluck_id'; |
|
373 | $tags = [ |
|
374 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
375 | 'genealabslaravelmodelcachingtestsfixturesbook', |
|
376 | 'genealabslaravelmodelcachingtestsfixturesprofile', |
|
377 | ]; |
|
378 | ||
379 | $cachedResults = cache()->tags($tags) |
|
380 | ->get($key); |
|
381 | $liveResults = (new UncachedAuthor)->with('books', 'profile') |
|
382 | ->pluck('id'); |
|
383 | ||
384 | $this->assertEmpty($authors->diffAssoc($cachedResults)); |
|
385 | $this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
|
386 | } |
|
387 | ||
388 | public function testSumModelResultsCreatesCache() |
|
389 | { |
|
@@ 388-404 (lines=17) @@ | ||
385 | $this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
|
386 | } |
|
387 | ||
388 | public function testSumModelResultsCreatesCache() |
|
389 | { |
|
390 | $authorId = (new Author)->with('books', 'profile') |
|
391 | ->sum('id'); |
|
392 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor-sum_id'; |
|
393 | $tags = [ |
|
394 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
395 | ]; |
|
396 | ||
397 | $cachedResult = cache()->tags($tags) |
|
398 | ->get($key); |
|
399 | $liveResult = (new UncachedAuthor)->with('books', 'profile') |
|
400 | ->sum('id'); |
|
401 | ||
402 | $this->assertEquals($authorId, $cachedResult); |
|
403 | $this->assertEquals($liveResult, $cachedResult); |
|
404 | } |
|
405 | ||
406 | public function testValueModelResultsCreatesCache() |
|
407 | { |
|
@@ 406-426 (lines=21) @@ | ||
403 | $this->assertEquals($liveResult, $cachedResult); |
|
404 | } |
|
405 | ||
406 | public function testValueModelResultsCreatesCache() |
|
407 | { |
|
408 | $authors = (new Author)->with('books', 'profile') |
|
409 | ->value('name'); |
|
410 | $key = 'genealabslaravelmodelcachingtestsfixturesauthor_name-books-profile-first'; |
|
411 | $tags = [ |
|
412 | 'genealabslaravelmodelcachingtestsfixturesauthor', |
|
413 | 'genealabslaravelmodelcachingtestsfixturesbook', |
|
414 | 'genealabslaravelmodelcachingtestsfixturesprofile', |
|
415 | ]; |
|
416 | ||
417 | $cachedResults = cache()->tags($tags) |
|
418 | ->get($key) |
|
419 | ->name; |
|
420 | ||
421 | $liveResults = (new UncachedAuthor)->with('books', 'profile') |
|
422 | ->value('name'); |
|
423 | ||
424 | $this->assertEquals($authors, $cachedResults); |
|
425 | $this->assertEquals($liveResults, $cachedResults); |
|
426 | } |
|
427 | } |
|
428 |