Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'test/classes/Controllers/Normalization/ThirdNormalForm/CreateNewTablesControllerTest.php')
-rw-r--r--test/classes/Controllers/Normalization/ThirdNormalForm/CreateNewTablesControllerTest.php64
1 files changed, 64 insertions, 0 deletions
diff --git a/test/classes/Controllers/Normalization/ThirdNormalForm/CreateNewTablesControllerTest.php b/test/classes/Controllers/Normalization/ThirdNormalForm/CreateNewTablesControllerTest.php
new file mode 100644
index 0000000000..a6980ce7ee
--- /dev/null
+++ b/test/classes/Controllers/Normalization/ThirdNormalForm/CreateNewTablesControllerTest.php
@@ -0,0 +1,64 @@
+<?php
+
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Tests\Controllers\Normalization\ThirdNormalForm;
+
+use PhpMyAdmin\ConfigStorage\Relation;
+use PhpMyAdmin\Controllers\Normalization\ThirdNormalForm\CreateNewTablesController;
+use PhpMyAdmin\Http\ServerRequest;
+use PhpMyAdmin\Normalization;
+use PhpMyAdmin\Template;
+use PhpMyAdmin\Tests\AbstractTestCase;
+use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
+use PhpMyAdmin\Transformations;
+
+use function json_encode;
+
+/**
+ * @covers \PhpMyAdmin\Controllers\Normalization\ThirdNormalForm\CreateNewTablesController
+ */
+class CreateNewTablesControllerTest extends AbstractTestCase
+{
+ public function testDefault(): void
+ {
+ $GLOBALS['db'] = 'test_db';
+ $GLOBALS['table'] = 'test_table';
+ $_POST['newTables'] = json_encode([
+ 'test_table' => [
+ 'event' => [
+ 'pk' => 'eventID',
+ 'nonpk' => 'Start_time, DateOfEvent, NumberOfGuests, NameOfVenue, LocationOfVenue',
+ ],
+ 'table2' => ['pk' => 'Start_time', 'nonpk' => 'TypeOfEvent, period'],
+ ],
+ ]);
+
+ // phpcs:disable Generic.Files.LineLength.TooLong
+ $dbiDummy = $this->createDbiDummy();
+ $dbiDummy->addSelectDb('test_db');
+ $dbiDummy->addResult('CREATE TABLE `event` SELECT DISTINCT `eventID`, `Start_time`, `DateOfEvent`, `NumberOfGuests`, `NameOfVenue`, `LocationOfVenue` FROM `test_table`;', []);
+ $dbiDummy->addResult('CREATE TABLE `table2` SELECT DISTINCT `Start_time`, `TypeOfEvent`, `period` FROM `test_table`;', []);
+ $dbiDummy->addResult('DROP TABLE `test_table`', []);
+ // phpcs:enable
+
+ $dbi = $this->createDatabaseInterface($dbiDummy);
+ $GLOBALS['dbi'] = $dbi;
+ $response = new ResponseRenderer();
+ $template = new Template();
+
+ $controller = new CreateNewTablesController(
+ $response,
+ $template,
+ new Normalization($dbi, new Relation($dbi), new Transformations(), $template)
+ );
+ $controller($this->createStub(ServerRequest::class));
+
+ $this->assertSame([
+ 'legendText' => 'End of step',
+ 'headText' => '<h3>The third step of normalization is complete.</h3>',
+ 'queryError' => false,
+ 'extra' => '',
+ ], $response->getJSONResult());
+ }
+}