phpmyadmin/test/classes/Controllers/Database/MultiTableQuery/TablesControllerTest.php
Maurício Meneghini Fauth 63d57b1f1c
Push dbi and dummyDbi members down
The idea is to only load the DBI when needed.

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-07-13 00:15:53 -03:00

63 lines
1.8 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers\Database\MultiTableQuery;
use PhpMyAdmin\Controllers\Database\MultiTableQuery\TablesController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
/**
* @covers \PhpMyAdmin\Controllers\Database\MultiTableQuery\TablesController
*/
class TablesControllerTest extends AbstractTestCase
{
/** @var DatabaseInterface */
protected $dbi;
/** @var DbiDummy */
protected $dummyDbi;
protected function setUp(): void
{
parent::setUp();
parent::setLanguage();
$this->dummyDbi = $this->createDbiDummy();
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
$GLOBALS['dbi'] = $this->dbi;
parent::loadContainerBuilder();
parent::loadDbiIntoContainerBuilder();
$GLOBALS['server'] = 1;
$GLOBALS['PMA_PHP_SELF'] = '';
parent::loadResponseIntoContainerBuilder();
}
public function testGetForeignKeyConstrainsForTable(): void
{
$_GET['tables'] = [
'table1',
'table2',
];
$_GET['db'] = 'test';
/** @var TablesController $multiTableQueryController */
$multiTableQueryController = $GLOBALS['containerBuilder']->get(TablesController::class);
$multiTableQueryController();
$this->assertSame(
[
'foreignKeyConstrains' => [
[
'TABLE_NAME' => 'table2',
'COLUMN_NAME' => 'idtable2',
'REFERENCED_TABLE_NAME' => 'table1',
'REFERENCED_COLUMN_NAME' => 'idtable1',
],
],
],
$this->getResponseJsonResult()
);
}
}