dummyDbi = $this->createDbiDummy(); $this->dbi = $this->createDatabaseInterface($this->dummyDbi); DatabaseInterface::$instance = $this->dbi; } public function testIndexParametrized(): void { $this->setLanguage(); $config = Config::getInstance(); $config->selectedServer['user'] = 'user'; // Some params were not added as they are not required for this test Sql::$showAsPhp = null; Current::$database = 'pma_test'; Current::$table = 'table1'; Current::$sqlQuery = 'SELECT A.*' . "\n" . 'FROM table1 A' . "\n" . 'WHERE A.nomEtablissement = :nomEta AND foo = :1 AND `:a` IS NULL'; $request = ServerRequestFactory::create()->createServerRequest('POST', 'https://example.com')->withParsedBody([ 'db' => Current::$database, 'table' => Current::$table, 'parameters' => [':nomEta' => 'Saint-Louis - Châteaulin', ':1' => '4'], 'sql_query' => Current::$sqlQuery, 'parameterized' => '1', ]); $this->dummyDbi->addResult( 'SELECT A.* FROM table1 A WHERE A.nomEtablissement = \'Saint-Louis - Châteaulin\'' . ' AND foo = 4 AND `:a` IS NULL LIMIT 0, 25', [], ['nomEtablissement', 'foo'], ); $this->dummyDbi->addResult( 'SHOW CREATE TABLE `pma_test`.`table1`', [], ); $this->dummyDbi->addResult( 'SELECT `COLUMN_NAME` AS `Field`, `COLUMN_TYPE` AS `Type`, `COLLATION_NAME` AS `Collation`,' . ' `IS_NULLABLE` AS `Null`, `COLUMN_KEY` AS `Key`,' . ' `COLUMN_DEFAULT` AS `Default`, `EXTRA` AS `Extra`, `PRIVILEGES` AS `Privileges`,' . ' `COLUMN_COMMENT` AS `Comment`' . ' FROM `information_schema`.`COLUMNS`' . ' WHERE `TABLE_SCHEMA` COLLATE utf8_bin = \'pma_test\' AND' . ' `TABLE_NAME` COLLATE utf8_bin = \'table1\'' . ' ORDER BY `ORDINAL_POSITION`', [], ); $responseRenderer = new ResponseRenderer(); $relation = new Relation($this->dbi, $config); $bookmarkRepository = new BookmarkRepository($this->dbi, $relation, $config); $template = new Template($config); $sql = new Sql( $this->dbi, $relation, self::createStub(RelationCleanup::class), self::createStub(Transformations::class), $template, $bookmarkRepository, $config, $responseRenderer, ); $importController = new ImportController( $responseRenderer, new Import($this->dbi, $responseRenderer, $config), $sql, $this->dbi, $bookmarkRepository, $config, ); $this->dummyDbi->addSelectDb('pma_test'); $this->dummyDbi->addSelectDb('pma_test'); $importController($request); $this->dummyDbi->assertAllSelectsConsumed(); self::assertTrue($responseRenderer->hasSuccessState(), 'expected the request not to fail'); $output = $responseRenderer->getHTMLResult(); self::assertStringContainsString('MySQL returned an empty result set (i.e. zero rows).', $output); self::assertStringContainsString( 'SELECT A.*' . "\n" . 'FROM table1 A' . "\n" . 'WHERE A.nomEtablissement = \'Saint-Louis - Châteaulin\' AND foo = 4 AND `:a` IS NULL', $output, ); $this->dummyDbi->assertAllQueriesConsumed(); } }