|
@@ 162-181 (lines=20) @@
|
| 159 |
|
$this->assertEquals($authors->count(), $results->count()); |
| 160 |
|
} |
| 161 |
|
|
| 162 |
|
public function testAvgModelResultsCreatesCache() |
| 163 |
|
{ |
| 164 |
|
$authorId = (new Author)->with('books', 'profile') |
| 165 |
|
->avg('id'); |
| 166 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile-avg_id"); |
| 167 |
|
$tags = [ |
| 168 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 169 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
| 170 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprofile", |
| 171 |
|
]; |
| 172 |
|
|
| 173 |
|
$cachedResult = $this->cache() |
| 174 |
|
->tags($tags) |
| 175 |
|
->get($key)['value']; |
| 176 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 177 |
|
->avg('id'); |
| 178 |
|
|
| 179 |
|
$this->assertEquals($authorId, $cachedResult); |
| 180 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 181 |
|
} |
| 182 |
|
|
| 183 |
|
public function testChunkModelResultsCreatesCache() |
| 184 |
|
{ |
|
@@ 237-257 (lines=21) @@
|
| 234 |
|
$this->assertEquals($liveResults, $cachedResults); |
| 235 |
|
} |
| 236 |
|
|
| 237 |
|
public function testCountWithStringCreatesCache() |
| 238 |
|
{ |
| 239 |
|
$authors = (new Author) |
| 240 |
|
->with('books', 'profile') |
| 241 |
|
->count("id"); |
| 242 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor_id-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile-count"); |
| 243 |
|
$tags = [ |
| 244 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 245 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
| 246 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprofile", |
| 247 |
|
]; |
| 248 |
|
|
| 249 |
|
$cachedResults = $this->cache()->tags($tags) |
| 250 |
|
->get($key)['value']; |
| 251 |
|
$liveResults = (new UncachedAuthor) |
| 252 |
|
->with('books', 'profile') |
| 253 |
|
->count("id"); |
| 254 |
|
|
| 255 |
|
$this->assertEquals($authors, $cachedResults); |
| 256 |
|
$this->assertEquals($liveResults, $cachedResults); |
| 257 |
|
} |
| 258 |
|
|
| 259 |
|
public function testFirstModelResultsCreatesCache() |
| 260 |
|
{ |
|
@@ 279-297 (lines=19) @@
|
| 276 |
|
$this->assertEquals($liveResult->id, $author->id); |
| 277 |
|
} |
| 278 |
|
|
| 279 |
|
public function testMaxModelResultsCreatesCache() |
| 280 |
|
{ |
| 281 |
|
$authorId = (new Author)->with('books', 'profile') |
| 282 |
|
->max('id'); |
| 283 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile-max_id"); |
| 284 |
|
$tags = [ |
| 285 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 286 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
| 287 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprofile", |
| 288 |
|
]; |
| 289 |
|
|
| 290 |
|
$cachedResult = $this->cache()->tags($tags) |
| 291 |
|
->get($key)['value']; |
| 292 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 293 |
|
->max('id'); |
| 294 |
|
|
| 295 |
|
$this->assertEquals($authorId, $cachedResult); |
| 296 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
public function testMinModelResultsCreatesCache() |
| 300 |
|
{ |
|
@@ 299-317 (lines=19) @@
|
| 296 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 297 |
|
} |
| 298 |
|
|
| 299 |
|
public function testMinModelResultsCreatesCache() |
| 300 |
|
{ |
| 301 |
|
$authorId = (new Author)->with('books', 'profile') |
| 302 |
|
->min('id'); |
| 303 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile-min_id"); |
| 304 |
|
$tags = [ |
| 305 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 306 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
| 307 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprofile", |
| 308 |
|
]; |
| 309 |
|
|
| 310 |
|
$cachedResult = $this->cache()->tags($tags) |
| 311 |
|
->get($key)['value']; |
| 312 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 313 |
|
->min('id'); |
| 314 |
|
|
| 315 |
|
$this->assertEquals($authorId, $cachedResult); |
| 316 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
public function testPluckModelResultsCreatesCache() |
| 320 |
|
{ |
|
@@ 319-337 (lines=19) @@
|
| 316 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 317 |
|
} |
| 318 |
|
|
| 319 |
|
public function testPluckModelResultsCreatesCache() |
| 320 |
|
{ |
| 321 |
|
$authors = (new Author)->with('books', 'profile') |
| 322 |
|
->pluck('name', 'id'); |
| 323 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor_name-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile-pluck_name_id"); |
| 324 |
|
$tags = [ |
| 325 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 326 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
| 327 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprofile", |
| 328 |
|
]; |
| 329 |
|
|
| 330 |
|
$cachedResults = $this->cache()->tags($tags) |
| 331 |
|
->get($key)['value']; |
| 332 |
|
$liveResults = (new UncachedAuthor)->with('books', 'profile') |
| 333 |
|
->pluck('name', 'id'); |
| 334 |
|
|
| 335 |
|
$this->assertEmpty($authors->diffKeys($cachedResults)); |
| 336 |
|
$this->assertEmpty($liveResults->diffKeys($cachedResults)); |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
public function testSumModelResultsCreatesCache() |
| 340 |
|
{ |
|
@@ 339-357 (lines=19) @@
|
| 336 |
|
$this->assertEmpty($liveResults->diffKeys($cachedResults)); |
| 337 |
|
} |
| 338 |
|
|
| 339 |
|
public function testSumModelResultsCreatesCache() |
| 340 |
|
{ |
| 341 |
|
$authorId = (new Author)->with('books', 'profile') |
| 342 |
|
->sum('id'); |
| 343 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile-sum_id"); |
| 344 |
|
$tags = [ |
| 345 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 346 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
| 347 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprofile", |
| 348 |
|
]; |
| 349 |
|
|
| 350 |
|
$cachedResult = $this->cache()->tags($tags) |
| 351 |
|
->get($key)['value']; |
| 352 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 353 |
|
->sum('id'); |
| 354 |
|
|
| 355 |
|
$this->assertEquals($authorId, $cachedResult); |
| 356 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
public function testValueModelResultsCreatesCache() |
| 360 |
|
{ |
|
@@ 359-377 (lines=19) @@
|
| 356 |
|
$this->assertEquals($liveResult, $cachedResult); |
| 357 |
|
} |
| 358 |
|
|
| 359 |
|
public function testValueModelResultsCreatesCache() |
| 360 |
|
{ |
| 361 |
|
$authorName = (new Author)->with('books', 'profile') |
| 362 |
|
->value('name'); |
| 363 |
|
$key = sha1("genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:authors:genealabslaravelmodelcachingtestsfixturesauthor-authors.deleted_at_null-testing:{$this->testingSqlitePath}testing.sqlite:books-testing:{$this->testingSqlitePath}testing.sqlite:profile-value_name"); |
| 364 |
|
$tags = [ |
| 365 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesauthor", |
| 366 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesbook", |
| 367 |
|
"genealabs:laravel-model-caching:testing:{$this->testingSqlitePath}testing.sqlite:genealabslaravelmodelcachingtestsfixturesprofile", |
| 368 |
|
]; |
| 369 |
|
|
| 370 |
|
$cachedResult = $this->cache()->tags($tags) |
| 371 |
|
->get($key)['value']; |
| 372 |
|
$liveResult = (new UncachedAuthor)->with('books', 'profile') |
| 373 |
|
->value('name'); |
| 374 |
|
|
| 375 |
|
$this->assertEquals($authorName, $cachedResult); |
| 376 |
|
$this->assertEquals($authorName, $liveResult); |
| 377 |
|
} |
| 378 |
|
|
| 379 |
|
public function testNestedRelationshipEagerLoading() |
| 380 |
|
{ |