|
@@ 183-199 (lines=17) @@
|
| 180 |
|
$this->assertEquals($authors->count(), $results->count()); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
public function testAvgModelResultsCreatesCache() |
| 184 |
|
{ |
| 185 |
|
$authorId = (new Author)->with('books', 'profile') |
| 186 |
|
->avg('id'); |
| 187 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-avg_id'; |
| 188 |
|
$tags = [ |
| 189 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 190 |
|
]; |
| 191 |
|
|
| 192 |
|
$cachedResult = cache()->tags($tags) |
| 193 |
|
->get($key); |
| 194 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 195 |
|
->avg('id'); |
| 196 |
|
|
| 197 |
|
$this->assertEquals($authorId, $cachedResult); |
| 198 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 199 |
|
} |
| 200 |
|
|
| 201 |
|
public function testChunkModelResultsCreatesCache() |
| 202 |
|
{ |
|
@@ 243-259 (lines=17) @@
|
| 240 |
|
} |
| 241 |
|
} |
| 242 |
|
|
| 243 |
|
public function testCountModelResultsCreatesCache() |
| 244 |
|
{ |
| 245 |
|
$authors = (new Author)->with('books', 'profile') |
| 246 |
|
->count(); |
| 247 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-count'; |
| 248 |
|
$tags = [ |
| 249 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 250 |
|
]; |
| 251 |
|
|
| 252 |
|
$cachedResults = cache()->tags($tags) |
| 253 |
|
->get($key); |
| 254 |
|
$liveResults = (new UncachedAuthor)->with('books', 'profile') |
| 255 |
|
->count(); |
| 256 |
|
|
| 257 |
|
$this->assertEquals($authors, $cachedResults); |
| 258 |
|
$this->assertEquals($liveResults, $cachedResults); |
| 259 |
|
} |
| 260 |
|
|
| 261 |
|
public function testCursorModelResultsCreatesCache() |
| 262 |
|
{ |
|
@@ 261-277 (lines=17) @@
|
| 258 |
|
$this->assertEquals($liveResults, $cachedResults); |
| 259 |
|
} |
| 260 |
|
|
| 261 |
|
public function testCursorModelResultsCreatesCache() |
| 262 |
|
{ |
| 263 |
|
$authors = (new Author)->with('books', 'profile') |
| 264 |
|
->cursor(); |
| 265 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-cursor'; |
| 266 |
|
$tags = [ |
| 267 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 268 |
|
]; |
| 269 |
|
|
| 270 |
|
$cachedResults = cache()->tags($tags) |
| 271 |
|
->get($key); |
| 272 |
|
$liveResults = collect((new UncachedAuthor)->with('books', 'profile') |
| 273 |
|
->cursor()); |
| 274 |
|
|
| 275 |
|
$this->assertEmpty($authors->diffAssoc($cachedResults)); |
| 276 |
|
$this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
public function testFindModelResultsCreatesCache() |
| 280 |
|
{ |
|
@@ 295-313 (lines=19) @@
|
| 292 |
|
$this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
| 293 |
|
} |
| 294 |
|
|
| 295 |
|
public function testGetModelResultsCreatesCache() |
| 296 |
|
{ |
| 297 |
|
$authors = (new Author)->with('books', 'profile') |
| 298 |
|
->get(); |
| 299 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-books-profile'; |
| 300 |
|
$tags = [ |
| 301 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 302 |
|
'genealabslaravelmodelcachingtestsfixturesbook', |
| 303 |
|
'genealabslaravelmodelcachingtestsfixturesprofile', |
| 304 |
|
]; |
| 305 |
|
|
| 306 |
|
$cachedResults = cache()->tags($tags) |
| 307 |
|
->get($key); |
| 308 |
|
$liveResults = (new UncachedAuthor)->with('books', 'profile') |
| 309 |
|
->get(); |
| 310 |
|
|
| 311 |
|
$this->assertEquals($authors, $cachedResults); |
| 312 |
|
$this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
public function testMaxModelResultsCreatesCache() |
| 316 |
|
{ |
|
@@ 315-331 (lines=17) @@
|
| 312 |
|
$this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
| 313 |
|
} |
| 314 |
|
|
| 315 |
|
public function testMaxModelResultsCreatesCache() |
| 316 |
|
{ |
| 317 |
|
$authorId = (new Author)->with('books', 'profile') |
| 318 |
|
->max('id'); |
| 319 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-max_id'; |
| 320 |
|
$tags = [ |
| 321 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 322 |
|
]; |
| 323 |
|
|
| 324 |
|
$cachedResult = cache()->tags($tags) |
| 325 |
|
->get($key); |
| 326 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 327 |
|
->max('id'); |
| 328 |
|
|
| 329 |
|
$this->assertEquals($authorId, $cachedResult); |
| 330 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 331 |
|
} |
| 332 |
|
|
| 333 |
|
public function testMinModelResultsCreatesCache() |
| 334 |
|
{ |
|
@@ 333-349 (lines=17) @@
|
| 330 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 331 |
|
} |
| 332 |
|
|
| 333 |
|
public function testMinModelResultsCreatesCache() |
| 334 |
|
{ |
| 335 |
|
$authorId = (new Author)->with('books', 'profile') |
| 336 |
|
->min('id'); |
| 337 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-min_id'; |
| 338 |
|
$tags = [ |
| 339 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 340 |
|
]; |
| 341 |
|
|
| 342 |
|
$cachedResult = cache()->tags($tags) |
| 343 |
|
->get($key); |
| 344 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 345 |
|
->min('id'); |
| 346 |
|
|
| 347 |
|
$this->assertEquals($authorId, $cachedResult); |
| 348 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 349 |
|
} |
| 350 |
|
|
| 351 |
|
public function testPluckModelResultsCreatesCache() |
| 352 |
|
{ |
|
@@ 351-369 (lines=19) @@
|
| 348 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 349 |
|
} |
| 350 |
|
|
| 351 |
|
public function testPluckModelResultsCreatesCache() |
| 352 |
|
{ |
| 353 |
|
$authors = (new Author)->with('books', 'profile') |
| 354 |
|
->pluck('id'); |
| 355 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor_id-books-profile-pluck_id'; |
| 356 |
|
$tags = [ |
| 357 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 358 |
|
'genealabslaravelmodelcachingtestsfixturesbook', |
| 359 |
|
'genealabslaravelmodelcachingtestsfixturesprofile', |
| 360 |
|
]; |
| 361 |
|
|
| 362 |
|
$cachedResults = cache()->tags($tags) |
| 363 |
|
->get($key); |
| 364 |
|
$liveResults = (new UncachedAuthor)->with('books', 'profile') |
| 365 |
|
->pluck('id'); |
| 366 |
|
|
| 367 |
|
$this->assertEmpty($authors->diffAssoc($cachedResults)); |
| 368 |
|
$this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
| 369 |
|
} |
| 370 |
|
|
| 371 |
|
public function testSumModelResultsCreatesCache() |
| 372 |
|
{ |
|
@@ 371-387 (lines=17) @@
|
| 368 |
|
$this->assertEmpty($liveResults->diffAssoc($cachedResults)); |
| 369 |
|
} |
| 370 |
|
|
| 371 |
|
public function testSumModelResultsCreatesCache() |
| 372 |
|
{ |
| 373 |
|
$authorId = (new Author)->with('books', 'profile') |
| 374 |
|
->sum('id'); |
| 375 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-sum_id'; |
| 376 |
|
$tags = [ |
| 377 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 378 |
|
]; |
| 379 |
|
|
| 380 |
|
$cachedResult = cache()->tags($tags) |
| 381 |
|
->get($key); |
| 382 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 383 |
|
->sum('id'); |
| 384 |
|
|
| 385 |
|
$this->assertEquals($authorId, $cachedResult); |
| 386 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 387 |
|
} |
| 388 |
|
|
| 389 |
|
public function testValueModelResultsCreatesCache() |
| 390 |
|
{ |
|
@@ 389-409 (lines=21) @@
|
| 386 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 387 |
|
} |
| 388 |
|
|
| 389 |
|
public function testValueModelResultsCreatesCache() |
| 390 |
|
{ |
| 391 |
|
$authors = (new Author)->with('books', 'profile') |
| 392 |
|
->value('name'); |
| 393 |
|
$key = 'genealabslaravelmodelcachingtestsfixturesauthor_name-books-profile-first'; |
| 394 |
|
$tags = [ |
| 395 |
|
'genealabslaravelmodelcachingtestsfixturesauthor', |
| 396 |
|
'genealabslaravelmodelcachingtestsfixturesbook', |
| 397 |
|
'genealabslaravelmodelcachingtestsfixturesprofile', |
| 398 |
|
]; |
| 399 |
|
|
| 400 |
|
$cachedResults = cache()->tags($tags) |
| 401 |
|
->get($key) |
| 402 |
|
->name; |
| 403 |
|
|
| 404 |
|
$liveResults = (new UncachedAuthor)->with('books', 'profile') |
| 405 |
|
->value('name'); |
| 406 |
|
|
| 407 |
|
$this->assertEquals($authors, $cachedResults); |
| 408 |
|
$this->assertEquals($liveResults, $cachedResults); |
| 409 |
|
} |
| 410 |
|
} |
| 411 |
|
|