Skip to content

Commit 8fb0532

Browse files
authored
Merge pull request #18 from hanneskaeufler/hk-issue-17
Add unit test for raw clause parsing
2 parents 0e0add1 + 73de75f commit 8fb0532

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

tests/Unit/CachedBuilderTest.php

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,18 @@ public function testColumnsRelationshipWhereClauseParsing()
500500

501501
public function testRawWhereClauseParsing()
502502
{
503-
// ->whereRaw(...)
504-
$this->markTestIncomplete();
503+
$authors = collect([(new Author)
504+
->whereRaw('name <> \'\'')->first()]);
505+
506+
$key = 'genealabslaravelmodelcachingtestsfixturesauthor_and_name-first';
507+
$tags = ['genealabslaravelmodelcachingtestsfixturesauthor'];
508+
509+
$cachedResults = collect([cache()->tags($tags)->get($key)]);
510+
511+
$liveResults = collect([(new UncachedAuthor)
512+
->whereRaw('name <> \'\'')->first()]);
513+
514+
$this->assertTrue($authors->diffAssoc($cachedResults)->isEmpty());
515+
$this->assertTrue($liveResults->diffAssoc($cachedResults)->isEmpty());
505516
}
506517
}

0 commit comments

Comments
 (0)