packages/ztd-query-core/tests/Unit/Schema/Partition/TablePartitionRelationTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Schema\Partition;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\TestCase;
9use ZtdQuery\Schema\Partition\TablePartitionRelation;
10
11#[CoversClass(TablePartitionRelation::class)]
12final class TablePartitionRelationTest extends TestCase
13{
14    public function testSpecificPartitionUsesItsPredicate(): void
15    {
16        $relation = new TablePartitionRelation('events', 'created_at >= DATE \'2024-01-01\'');
17
18        self::assertSame('events', $relation->parentTable);
19        self::assertSame('created_at >= DATE \'2024-01-01\'', $relation->predicate);
20    }
21
22    public function testDefaultPartitionExcludesSpecificSiblingsAndIncludesNull(): void
23    {
24        $relation = new TablePartitionRelation('events', null);
25
26        self::assertSame('events', $relation->parentTable);
27        self::assertNull($relation->predicate);
28    }
29
30}
31