|
| 1 | +<?php |
| 2 | + |
| 3 | +declare(strict_types=1); |
| 4 | + |
| 5 | +namespace PhpMyAdmin\Tests\Controllers\Table; |
| 6 | + |
| 7 | +use PhpMyAdmin\Controllers\Table\IndexRenameController; |
| 8 | +use PhpMyAdmin\Index; |
| 9 | +use PhpMyAdmin\Table\Indexes; |
| 10 | +use PhpMyAdmin\Template; |
| 11 | +use PhpMyAdmin\Tests\AbstractTestCase; |
| 12 | +use PhpMyAdmin\Tests\Stubs\ResponseRenderer; |
| 13 | + |
| 14 | +/** |
| 15 | + * @covers \PhpMyAdmin\Controllers\Table\IndexRenameController |
| 16 | + */ |
| 17 | +class IndexRenameControllerTest extends AbstractTestCase |
| 18 | +{ |
| 19 | + public function testIndexRenameController(): void |
| 20 | + { |
| 21 | + $GLOBALS['server'] = 2; |
| 22 | + $GLOBALS['db'] = 'test_db'; |
| 23 | + $GLOBALS['table'] = 'test_table'; |
| 24 | + $GLOBALS['text_dir'] = 'ltr'; |
| 25 | + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; |
| 26 | + $GLOBALS['lang'] = 'en'; |
| 27 | + |
| 28 | + $this->dummyDbi->addSelectDb('test_db'); |
| 29 | + $this->dummyDbi->addSelectDb('test_db'); |
| 30 | + $this->dummyDbi->addResult('SHOW TABLES LIKE \'test_table\';', [['test_table']]); |
| 31 | + |
| 32 | + $template = new Template(); |
| 33 | + $expected = $template->render('table/index_rename_form', [ |
| 34 | + 'index' => new Index(), |
| 35 | + 'form_params' => ['db' => 'test_db', 'table' => 'test_table'], |
| 36 | + ]); |
| 37 | + |
| 38 | + $response = new ResponseRenderer(); |
| 39 | + (new IndexRenameController($response, $template, $this->dbi, new Indexes($response, $template, $this->dbi)))(); |
| 40 | + $this->assertSame($expected, $response->getHTMLResult()); |
| 41 | + } |
| 42 | +} |
0 commit comments