[ 'event', 'event', 'event', 'event', 'NameOfVenue', 'event', 'period', 'event', 'event', ], ]); $_POST['pd'] = json_encode([ '' => [], 'event' => [ 'TypeOfEvent', 'period', 'Start_time', 'NameOfVenue', 'LocationOfVenue', ], 'NameOfVenue' => ['DateOfEvent'], 'period' => ['NumberOfGuests'], ]); $GLOBALS['goto'] = 'index.php?route=/sql'; $containerBuilder->setParameter('db', $GLOBALS['db']); $containerBuilder->setParameter('table', $GLOBALS['table']); /** @var NormalizationController $normalizationController */ $normalizationController = $containerBuilder->get(NormalizationController::class); $normalizationController->index(); $this->getResponseJsonResult();// Will echo the contents $data = (string) json_encode( [ 'html' => '

In order to put the original table \'test_tbl\' into ' . 'Third normal form we need to create the following tables:' . '

' . '( event, TypeOfEvent, period, Start_time, NameOfVenue, LocationOfVenue )' . '

' . '( NameOfVenue, DateOfEvent )

' . '( period, NumberOfGuests )', 'newTables' => [ 'test_tbl' => [ 'test_tbl' => [ 'pk' => 'event', 'nonpk' => 'TypeOfEvent, period, Start_time, NameOfVenue, LocationOfVenue', ], 'table2' => [ 'pk' => 'NameOfVenue', 'nonpk' => 'DateOfEvent', ], 'table3' => [ 'pk' => 'period', 'nonpk' => 'NumberOfGuests', ], ], ], 'success' => true, ] ); $this->expectOutputString($data); } public function testGetNewTables2NF(): void { global $containerBuilder; $_POST['getNewTables2NF'] = 1; $_POST['pd'] = json_encode([ 'ID, task' => [], 'task' => ['timestamp'], ]); $GLOBALS['goto'] = 'index.php?route=/sql'; $containerBuilder->setParameter('db', $GLOBALS['db']); $containerBuilder->setParameter('table', $GLOBALS['table']); /** @var NormalizationController $normalizationController */ $normalizationController = $containerBuilder->get(NormalizationController::class); $normalizationController->index(); $this->expectOutputString( '

In order to put the original table \'test_tbl\' into Second normal' . ' form we need to create the following tables:

( ID, task )

( task, timestamp )' ); } public function testCreateNewTables2NF(): void { global $containerBuilder; $_POST['createNewTables2NF'] = 1; $_POST['pd'] = json_encode([ 'ID, task' => [], 'task' => ['timestamp'], ]); $_POST['newTablesName'] = json_encode([ 'ID, task' => 'batch_log2', 'task' => 'table2', ]); $GLOBALS['goto'] = 'index.php?route=/sql'; $containerBuilder->setParameter('db', $GLOBALS['db']); $containerBuilder->setParameter('table', $GLOBALS['table']); /** @var NormalizationController $normalizationController */ $normalizationController = $containerBuilder->get(NormalizationController::class); $normalizationController->index(); $this->assertSame( $this->getResponseJsonResult(), [ 'legendText' => 'End of step', 'headText' => '

The second step of normalization is complete for table \'test_tbl\'.

', 'queryError' => false, 'extra' => '', ] ); } public function testCreateNewTables3NF(): void { global $containerBuilder; $_POST['createNewTables3NF'] = 1; $_POST['newTables'] = json_encode([ 'test_tbl' => [ 'event' => [ 'pk' => 'eventID', 'nonpk' => 'Start_time, DateOfEvent, NumberOfGuests, NameOfVenue, LocationOfVenue', ], 'table2' => [ 'pk' => 'Start_time', 'nonpk' => 'TypeOfEvent, period', ], ], ]); $GLOBALS['goto'] = 'index.php?route=/sql'; $containerBuilder->setParameter('db', $GLOBALS['db']); $containerBuilder->setParameter('table', $GLOBALS['table']); /** @var NormalizationController $normalizationController */ $normalizationController = $containerBuilder->get(NormalizationController::class); $normalizationController->index(); $this->assertSame( $this->getResponseJsonResult(), [ 'legendText' => 'End of step', 'headText' => '

The third step of normalization is complete.

', 'queryError' => false, 'extra' => '', ] ); } }