packages/ztd-query-core/tests/Unit/Shadow/FollowedConstraintTest.php

1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Shadow;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\UsesClass;
9use PHPUnit\Framework\TestCase;
10use ZtdQuery\Schema\Key\ForeignKeyDefinition;
11use ZtdQuery\Shadow\FollowedConstraint;
12
13#[CoversClass(FollowedConstraint::class)]
14#[UsesClass(ForeignKeyDefinition::class)]
15final class FollowedConstraintTest extends TestCase
16{
17    public function testCarriesWhatIsNeededToFollowAKeyAndToRefuseIt(): void
18    {
19        $foreignKey = new ForeignKeyDefinition(['parent_id'], 'parents', ['id']);
20
21        $constraint = new FollowedConstraint('children', 'fk', $foreignKey, 'DELETE');
22
23        self::assertSame(
24            ['children', 'fk', $foreignKey, 'DELETE'],
25            [$constraint->childTable, $constraint->constraintName, $constraint->foreignKey, $constraint->sql],
26        );
27    }
28}
29