From 73de75f1f538d668585f958e949cf38428644998 Mon Sep 17 00:00:00 2001 From: Hannes Kaeufler Date: Thu, 12 Oct 2017 20:55:40 +0200 Subject: [PATCH] Add unit test for raw where clause parsing --- tests/Unit/CachedBuilderTest.php | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/tests/Unit/CachedBuilderTest.php b/tests/Unit/CachedBuilderTest.php index 1a995df..a07e1f4 100644 --- a/tests/Unit/CachedBuilderTest.php +++ b/tests/Unit/CachedBuilderTest.php @@ -500,7 +500,18 @@ public function testColumnsRelationshipWhereClauseParsing() public function testRawWhereClauseParsing() { - // ->whereRaw(...) - $this->markTestIncomplete(); + $authors = collect([(new Author) + ->whereRaw('name <> \'\'')->first()]); + + $key = 'genealabslaravelmodelcachingtestsfixturesauthor_and_name-first'; + $tags = ['genealabslaravelmodelcachingtestsfixturesauthor']; + + $cachedResults = collect([cache()->tags($tags)->get($key)]); + + $liveResults = collect([(new UncachedAuthor) + ->whereRaw('name <> \'\'')->first()]); + + $this->assertTrue($authors->diffAssoc($cachedResults)->isEmpty()); + $this->assertTrue($liveResults->diffAssoc($cachedResults)->isEmpty()); } }