From 7139b930290d9add92c1488f95f0bfb3b406e51b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?D=C5=BEuris?= Date: Sun, 1 Dec 2024 21:26:29 +0200 Subject: [PATCH] Test withAttributes querying on many-to-many --- ...loquentBelongsToManyWithAttributesTest.php | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/Database/DatabaseEloquentBelongsToManyWithAttributesTest.php b/tests/Database/DatabaseEloquentBelongsToManyWithAttributesTest.php index a98abd2f546c..1cc961124d3e 100755 --- a/tests/Database/DatabaseEloquentBelongsToManyWithAttributesTest.php +++ b/tests/Database/DatabaseEloquentBelongsToManyWithAttributesTest.php @@ -36,6 +36,28 @@ public function testCreatesWithAttributesAndPivotValues(): void $this->assertSame($tag->id, $pivot->tag_id); } + public function testQueriesWithAttributesAndPivotValues(): void + { + $post = new ManyToManyWithAttributesPost(['id' => 2]); + $wheres = $post->metaTags()->toBase()->wheres; + + $this->assertContains([ + 'type' => 'Basic', + 'column' => 'visible', + 'operator' => '=', + 'value' => true, + 'boolean' => 'and', + ], $wheres); + + $this->assertContains([ + 'type' => 'Basic', + 'column' => 'with_attributes_pivot.type', + 'operator' => '=', + 'value' => 'meta', + 'boolean' => 'and', + ], $wheres); + } + protected function createSchema() { $this->schema()->create('with_attributes_posts', function ($table) {