Skip to content

Commit c9d498d

Browse files
authored
Merge pull request #24 from fentie/add-where-column-test
Add column-based where test
2 parents 6ab9107 + 84092bb commit c9d498d

File tree

1 file changed

+14
-3
lines changed

1 file changed

+14
-3
lines changed

tests/Unit/CachedBuilderTest.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,7 +413,7 @@ public function testValueModelResultsCreatesCache()
413413
$this->assertEquals($liveResults, $cachedResults);
414414
}
415415

416-
public function testNestedRelationshipEagerloading()
416+
public function testNestedRelationshipEagerLoading()
417417
{
418418
$authors = collect([(new Author)->with('books.publisher')
419419
->first()]);
@@ -522,8 +522,19 @@ public function testExistsRelationshipWhereClauseParsing()
522522

523523
public function testColumnsRelationshipWhereClauseParsing()
524524
{
525-
// ???
526-
$this->markTestIncomplete();
525+
$author = (new Author)->orderBy('name')->first();
526+
527+
$authors = collect([(new Author)->where('name', '=', $author->name)->first()]);
528+
529+
$key = 'genealabslaravelmodelcachingtestsfixturesauthor-name_' . $author->name . '-first';
530+
$tags = ['genealabslaravelmodelcachingtestsfixturesauthor'];
531+
532+
$cachedResults = collect([cache()->tags($tags)->get($key)]);
533+
534+
$liveResults = collect([(new UncachedAuthor)->where('name', '=', $author->name)->first()]);
535+
536+
$this->assertEmpty($authors->diffAssoc($cachedResults));
537+
$this->assertEmpty($liveResults->diffAssoc($cachedResults));
527538
}
528539

529540
public function testRawWhereClauseParsing()

0 commit comments

Comments
 (0)