diff options
author | William Desportes <williamdes@wdes.fr> | 2021-03-06 21:14:16 +0300 |
---|---|---|
committer | William Desportes <williamdes@wdes.fr> | 2021-03-06 21:30:14 +0300 |
commit | 13fdc3e099d314b7c39665648f8c9cd0e07303bf (patch) | |
tree | 258220459d7843cccce3e0e8a78e1b73d3b49ee0 /test/classes/Controllers | |
parent | 5a45a0d34b3a4f63490e1aecdc623996117470e8 (diff) |
Add tests for #16708
Signed-off-by: William Desportes <williamdes@wdes.fr>
Diffstat (limited to 'test/classes/Controllers')
-rw-r--r-- | test/classes/Controllers/Table/ReplaceControllerTest.php | 101 |
1 files changed, 101 insertions, 0 deletions
diff --git a/test/classes/Controllers/Table/ReplaceControllerTest.php b/test/classes/Controllers/Table/ReplaceControllerTest.php new file mode 100644 index 0000000000..f4412b95a0 --- /dev/null +++ b/test/classes/Controllers/Table/ReplaceControllerTest.php @@ -0,0 +1,101 @@ +<?php + +declare(strict_types=1); + +namespace PhpMyAdmin\Tests\Controllers\Table; + +use PhpMyAdmin\Controllers\Table\ReplaceController; +use PhpMyAdmin\Response; +use PhpMyAdmin\Tests\AbstractTestCase; + +class ReplaceControllerTest extends AbstractTestCase +{ + protected function setUp(): void + { + parent::setUp(); + parent::loadDefaultConfig(); + parent::defineVersionConstants(); + parent::setLanguage(); + parent::setTheme(); + parent::setGlobalDbi(); + parent::loadContainerBuilder(); + parent::loadDbiIntoContainerBuilder(); + $GLOBALS['server'] = 1; + $GLOBALS['PMA_PHP_SELF'] = 'index.php'; + parent::loadResponseIntoContainerBuilder(); + $GLOBALS['db'] = 'my_db'; + $GLOBALS['table'] = 'test_tbl'; + + $GLOBALS['cfg']['Server']['user'] = 'user'; + $GLOBALS['cfg']['Server']['DisableIS'] = false; + + //_SESSION + $_SESSION['relation'][$GLOBALS['server']] = [ + 'PMA_VERSION' => PMA_VERSION, + 'table_coords' => 'table_name', + 'displaywork' => 'displaywork', + 'db' => 'information_schema', + 'table_info' => 'table_info', + 'relwork' => 'relwork', + 'relation' => 'relation', + 'mimework' => 'mimework', + 'commwork' => 'commwork', + 'column_info' => 'column_info', + 'pdf_pages' => 'pdf_pages', + 'bookmarkwork' => 'bookmarkwork', + 'bookmark' => 'bookmark', + 'uiprefswork' => 'uiprefswork', + 'table_uiprefs' => 'table_uiprefs', + ]; + } + + public function testReplace(): void + { + global $containerBuilder; + $GLOBALS['url_params'] = []; + Response::getInstance()->setAjax(true); + $_POST['db'] = $GLOBALS['db']; + $_POST['table'] = $GLOBALS['table']; + $_POST['ajax_request'] = 'true'; + $_POST['sql_query'] = ''; + $_POST['clause_is_unique'] = 1; + $_POST['where_clause'] = [ + '`test`.`ser` = 2', + '`test`.`ser` = 1', + ]; + $_POST['rel_fields_list'] = ''; + $_POST['do_transformations'] = true; + $_POST['transform_fields_list'] = '0%5Bvc%5D=sss%20s%20s&1%5Bvc%5D=zzff%20s%20sf%0A'; + $_POST['relational_display'] = 'K'; + $_POST['goto'] = 'index.php?route=/sql'; + $_POST['submit_type'] = 'save'; + $_POST['fields'] = [ + 'multi_edit' => [ + 0 => ['zzff s sf'], + 1 => ['sss s s'], + ], + ]; + $_POST['fields_name'] = [ + 'multi_edit' => [ + 0 => ['vc'], + 1 => ['vc'], + ], + ]; + $_POST['fields_null'] = [ + 'multi_edit' => [ + 0 => [], + 1 => [], + ], + ]; + $GLOBALS['goto'] = 'index.php?route=/sql'; + $containerBuilder->setParameter('db', $GLOBALS['db']); + $containerBuilder->setParameter('table', $GLOBALS['table']); + /** @var ReplaceController $replaceController */ + $replaceController = $containerBuilder->get(ReplaceController::class); + $replaceController->index(); + $this->assertStringContainsString( + 'MySQL returned an empty result set (i.e. zero rows)', + $this->getResponseHtmlResult() + ); + } +} |