|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace PhpMyAdmin\Tests\Config\Forms\Page; |
| 6 | + |
| 7 | +use PhpMyAdmin\Config\ConfigFile; |
| 8 | +use PhpMyAdmin\Config\Form; |
| 9 | +use PhpMyAdmin\Config\FormDisplay; |
| 10 | +use PhpMyAdmin\Config\Forms\BaseForm; |
| 11 | +use PhpMyAdmin\Config\Forms\Page\TableStructureForm; |
| 12 | +use PhpMyAdmin\Tests\AbstractTestCase; |
| 13 | +use PHPUnit\Framework\Attributes\CoversClass; |
| 14 | + |
| 15 | +#[CoversClass(TableStructureForm::class)] |
| 16 | +#[CoversClass(BaseForm::class)] |
| 17 | +#[CoversClass(FormDisplay::class)] |
| 18 | +#[CoversClass(Form::class)] |
| 19 | +final class TableStructureFormTest extends AbstractTestCase |
| 20 | +{ |
| 21 | + public function testRegisteredForms(): void |
| 22 | + { |
| 23 | + Form::resetGroupCounter(); |
| 24 | + |
| 25 | + $tableStructureForm = new TableStructureForm(new ConfigFile([]), 1); |
| 26 | + self::assertSame('', TableStructureForm::getName()); |
| 27 | + |
| 28 | + $forms = $tableStructureForm->getRegisteredForms(); |
| 29 | + self::assertCount(1, $forms); |
| 30 | + |
| 31 | + self::assertArrayHasKey('TableStructure', $forms); |
| 32 | + $form = $forms['TableStructure']; |
| 33 | + self::assertSame('TableStructure', $form->name); |
| 34 | + self::assertSame(1, $form->index); |
| 35 | + self::assertSame([], $form->default); |
| 36 | + self::assertSame( |
| 37 | + [ |
| 38 | + 'HideStructureActions' => 'HideStructureActions', |
| 39 | + 'ShowColumnComments' => 'ShowColumnComments', |
| 40 | + ':group:Default transformations' => ':group:Default transformations', |
| 41 | + 'Hex' => 'DefaultTransformations/Hex', |
| 42 | + 'Substring' => 'DefaultTransformations/Substring', |
| 43 | + 'Bool2Text' => 'DefaultTransformations/Bool2Text', |
| 44 | + 'External' => 'DefaultTransformations/External', |
| 45 | + 'PreApPend' => 'DefaultTransformations/PreApPend', |
| 46 | + 'DateFormat' => 'DefaultTransformations/DateFormat', |
| 47 | + 'Inline' => 'DefaultTransformations/Inline', |
| 48 | + 'TextImageLink' => 'DefaultTransformations/TextImageLink', |
| 49 | + 'TextLink' => 'DefaultTransformations/TextLink', |
| 50 | + ':group:end:0' => ':group:end:0', |
| 51 | + ], |
| 52 | + $form->fields, |
| 53 | + ); |
| 54 | + } |
| 55 | + |
| 56 | + public function testGetFields(): void |
| 57 | + { |
| 58 | + self::assertSame( |
| 59 | + [ |
| 60 | + 'HideStructureActions', |
| 61 | + 'ShowColumnComments', |
| 62 | + ':group:Default transformations', |
| 63 | + 'DefaultTransformations/Hex', |
| 64 | + 'DefaultTransformations/Substring', |
| 65 | + 'DefaultTransformations/Bool2Text', |
| 66 | + 'DefaultTransformations/External', |
| 67 | + 'DefaultTransformations/PreApPend', |
| 68 | + 'DefaultTransformations/DateFormat', |
| 69 | + 'DefaultTransformations/Inline', |
| 70 | + 'DefaultTransformations/TextImageLink', |
| 71 | + 'DefaultTransformations/TextLink', |
| 72 | + ':group:end', |
| 73 | + ], |
| 74 | + TableStructureForm::getFields(), |
| 75 | + ); |
| 76 | + } |
| 77 | +} |
0 commit comments