packages/sql-semantics-mysql/tests/Unit/Statement/Account/Privilege/Item/PrivilegeKindTest.php
1<?php
2
3declare(strict_types=1);
4
5namespace Tests\Unit\Statement\Account\Privilege\Item;
6
7use PHPUnit\Framework\Attributes\CoversClass;
8use PHPUnit\Framework\Attributes\Small;
9use PHPUnit\Framework\TestCase;
10use SqlSemantics\Platform\MySql\Statement\Account\Privilege\Item\PrivilegeKind;
11
12#[CoversClass(PrivilegeKind::class)]
13#[Small]
14final class PrivilegeKindTest extends TestCase
15{
16 public function testWordsSplitTheKeywords(): void
17 {
18 self::assertSame(['CREATE', 'TEMPORARY', 'TABLES'], PrivilegeKind::CreateTemporaryTables->words());
19 }
20
21 public function testColumnsTellsTheColumnPrivileges(): void
22 {
23 self::assertSame(['Select', 'Insert', 'Update', 'References'], array_column(array_values(array_filter(PrivilegeKind::cases(), static fn (PrivilegeKind $kind): bool => $kind->columns())), 'name'));
24 }
25
26 public function testTableTellsTheTablePrivileges(): void
27 {
28 self::assertSame([true, true, false], [PrivilegeKind::Trigger->table(), PrivilegeKind::GrantOption->table(), PrivilegeKind::Execute->table()]);
29 }
30
31 public function testRoutineTellsTheRoutinePrivileges(): void
32 {
33 self::assertSame(['Usage', 'Execute', 'GrantOption', 'AlterRoutine'], array_column(array_values(array_filter(PrivilegeKind::cases(), static fn (PrivilegeKind $kind): bool => $kind->routine())), 'name'));
34 }
35
36 public function testDatabaseTellsTheDatabasePrivileges(): void
37 {
38 self::assertSame([true, true, false, false], [PrivilegeKind::Event->database(), PrivilegeKind::LockTables->database(), PrivilegeKind::CreateUser->database(), PrivilegeKind::Super->database()]);
39 }
40}
41