diff options
author | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-07-30 01:03:35 +0300 |
---|---|---|
committer | Maurício Meneghini Fauth <mauricio@fauth.dev> | 2022-07-30 01:03:35 +0300 |
commit | 08297d96b8c1dae5b9ee82c96b73f68ac3523136 (patch) | |
tree | b600691dcd625d25ccd324314e2beb2478d67dc2 /test | |
parent | 6e8600f321804d23999af7f06f945ac121b56139 (diff) |
Extract normalization 1NF step 3 action
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test')
-rw-r--r-- | test/classes/Controllers/Normalization/FirstNormalForm/ThirdStepControllerTest.php | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/test/classes/Controllers/Normalization/FirstNormalForm/ThirdStepControllerTest.php b/test/classes/Controllers/Normalization/FirstNormalForm/ThirdStepControllerTest.php new file mode 100644 index 0000000000..0b06272051 --- /dev/null +++ b/test/classes/Controllers/Normalization/FirstNormalForm/ThirdStepControllerTest.php @@ -0,0 +1,51 @@ +<?php + +declare(strict_types=1); + +namespace PhpMyAdmin\Tests\Controllers\Normalization\FirstNormalForm; + +use PhpMyAdmin\ConfigStorage\Relation; +use PhpMyAdmin\Controllers\Normalization\FirstNormalForm\ThirdStepController; +use PhpMyAdmin\Http\ServerRequest; +use PhpMyAdmin\Normalization; +use PhpMyAdmin\Template; +use PhpMyAdmin\Tests\AbstractTestCase; +use PhpMyAdmin\Tests\Stubs\ResponseRenderer; +use PhpMyAdmin\Transformations; + +/** + * @covers \PhpMyAdmin\Controllers\Normalization\FirstNormalForm\ThirdStepController + */ +class ThirdStepControllerTest extends AbstractTestCase +{ + public function testDefault(): void + { + $GLOBALS['db'] = 'test_db'; + $GLOBALS['table'] = 'test_table'; + + $dbiDummy = $this->createDbiDummy(); + $dbiDummy->addSelectDb('test_db'); + + $dbi = $this->createDatabaseInterface($dbiDummy); + $GLOBALS['dbi'] = $dbi; + $response = new ResponseRenderer(); + $template = new Template(); + + $controller = new ThirdStepController( + $response, + $template, + new Normalization($dbi, new Relation($dbi), new Transformations(), $template) + ); + $controller($this->createStub(ServerRequest::class)); + + // phpcs:disable Generic.Files.LineLength.TooLong + $this->assertSame([ + 'legendText' => 'Step 1.3 Move repeating groups', + 'headText' => 'Do you have a group of two or more columns that are closely related and are all repeating the same attribute? For example, a table that holds data on books might have columns such as book_id, author1, author2, author3 and so on which form a repeating group. In this case a new table (book_id, author) should be created.', + 'subText' => 'Check the columns which form a repeating group. If no such group, click on \'No repeating group\'', + 'extra' => '<input type="checkbox" value="id">id [ int(11) ]<br><input type="checkbox" value="name">name [ varchar(20) ]<br><input type="checkbox" value="datetimefield">datetimefield [ datetime ]<br><br><input class="btn btn-secondary" type="submit" id="moveRepeatingGroup" value="Done"><input class="btn btn-secondary" type="submit" value="No repeating group" onclick="goToStep4();">', + 'primary_key' => '["id"]', + ], $response->getJSONResult()); + // phpcs:enable + } +} |