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
path: root/test
diff options
context:
space:
mode:
authorMaurício Meneghini Fauth <mauricio@fauth.dev>2022-07-30 23:49:12 +0300
committerMaurício Meneghini Fauth <mauricio@fauth.dev>2022-07-30 23:49:12 +0300
commitefc04db52b7e77b6ec067fad427fa3a3a2c88689 (patch)
treeedeb7f077776ddb15e574b1a403e38bb1c7ff899 /test
parentdd25695569bc86f66e6be393bf92394229639549 (diff)
Extract normalization 3NF step 1 action
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
Diffstat (limited to 'test')
-rw-r--r--test/classes/Controllers/Normalization/SecondNormalForm/FirstStepControllerTest.php2
-rw-r--r--test/classes/Controllers/Normalization/ThirdNormalForm/FirstStepControllerTest.php51
2 files changed, 51 insertions, 2 deletions
diff --git a/test/classes/Controllers/Normalization/SecondNormalForm/FirstStepControllerTest.php b/test/classes/Controllers/Normalization/SecondNormalForm/FirstStepControllerTest.php
index 52cb33daaa..c5ec7dda6f 100644
--- a/test/classes/Controllers/Normalization/SecondNormalForm/FirstStepControllerTest.php
+++ b/test/classes/Controllers/Normalization/SecondNormalForm/FirstStepControllerTest.php
@@ -35,7 +35,6 @@ class FirstStepControllerTest extends AbstractTestCase
);
$controller($this->createStub(ServerRequest::class));
- // phpcs:disable Generic.Files.LineLength.TooLong
$this->assertSame([
'legendText' => 'Step 2.1 Find partial dependencies',
'headText' => 'No partial dependencies possible as the primary key ( id ) has just one column.<br>',
@@ -43,6 +42,5 @@ class FirstStepControllerTest extends AbstractTestCase
'extra' => '<h3>Table is already in second normal form.</h3>',
'primary_key' => 'id',
], $response->getJSONResult());
- // phpcs:enable
}
}
diff --git a/test/classes/Controllers/Normalization/ThirdNormalForm/FirstStepControllerTest.php b/test/classes/Controllers/Normalization/ThirdNormalForm/FirstStepControllerTest.php
new file mode 100644
index 0000000000..dd55cef91e
--- /dev/null
+++ b/test/classes/Controllers/Normalization/ThirdNormalForm/FirstStepControllerTest.php
@@ -0,0 +1,51 @@
+<?php
+
+declare(strict_types=1);
+
+namespace PhpMyAdmin\Tests\Controllers\Normalization\ThirdNormalForm;
+
+use PhpMyAdmin\ConfigStorage\Relation;
+use PhpMyAdmin\Controllers\Normalization\ThirdNormalForm\FirstStepController;
+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\ThirdNormalForm\FirstStepController
+ */
+class FirstStepControllerTest extends AbstractTestCase
+{
+ public function testDefault(): void
+ {
+ $GLOBALS['db'] = 'test_db';
+ $GLOBALS['table'] = 'test_table';
+ $_POST['tables'] = ['test_table'];
+
+ $dbiDummy = $this->createDbiDummy();
+ $dbiDummy->addSelectDb('test_db');
+
+ $dbi = $this->createDatabaseInterface($dbiDummy);
+ $GLOBALS['dbi'] = $dbi;
+ $response = new ResponseRenderer();
+ $template = new Template();
+
+ $controller = new FirstStepController(
+ $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 3.1 Find transitive dependencies',
+ 'headText' => 'Please answer the following question(s) carefully to obtain a correct normalization.',
+ 'subText' => 'For each column below, please select the <b>minimal set</b> of columns among given set whose values combined together are sufficient to determine the value of the column.<br>Note: A column may have no transitive dependency, in that case you don\'t have to select any.',
+ 'extra' => '<b>\'name\' depends on:</b><br><form id="td_1" data-colname="name" data-tablename="test_table" class="smallIndent"><input type="checkbox" name="pd" value="name"><span>name</span><input type="checkbox" name="pd" value="datetimefield"><span>datetimefield</span></form><br><br><b>\'datetimefield\' depends on:</b><br><form id="td_2" data-colname="datetimefield" data-tablename="test_table" class="smallIndent"><input type="checkbox" name="pd" value="name"><span>name</span><input type="checkbox" name="pd" value="datetimefield"><span>datetimefield</span></form><br><br>',
+ ], $response->getJSONResult());
+ // phpcs:enable
+ }
+}