Skip to content

Commit

Permalink
Test withAttributes querying on many-to-many
Browse files Browse the repository at this point in the history
  • Loading branch information
tontonsb committed Dec 1, 2024
1 parent 768de8d commit 7139b93
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions tests/Database/DatabaseEloquentBelongsToManyWithAttributesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit 7139b93

Please sign in to comment.