From b7be672324bdfc709787b49c22df84fd97734726 Mon Sep 17 00:00:00 2001 From: Jonas Staudenmeir Date: Fri, 26 Apr 2019 03:23:57 +0200 Subject: [PATCH] Fix tests --- tests/BelongsToThroughTest.php | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/tests/BelongsToThroughTest.php b/tests/BelongsToThroughTest.php index 943c89c..38cd6c4 100644 --- a/tests/BelongsToThroughTest.php +++ b/tests/BelongsToThroughTest.php @@ -2,6 +2,7 @@ namespace Tests; +use Illuminate\Database\Eloquent\Builder; use Illuminate\Support\Arr; use Tests\Models\Comment; @@ -12,7 +13,9 @@ public function testLazyLoading() $country = Comment::first()->country; $this->assertEquals(1, $country->id); - $this->assertEquals(1, $country->users_count); + if (method_exists(Builder::class, 'withCount')) { + $this->assertEquals(1, $country->users_count); + } } public function testLazyLoadingWithSingleThroughModel() @@ -50,7 +53,9 @@ public function testEagerLoading() $this->assertEquals(1, $comments[0]->country->id); $this->assertEquals(2, $comments[1]->country->id); $this->assertNull($comments[2]->country); - $this->assertEquals(1, $comments[0]->country->users_count); + if (method_exists(Builder::class, 'withCount')) { + $this->assertEquals(1, $comments[0]->country->users_count); + } } public function testEagerLoadingWithPrefix()