phpmyadmin/test/classes/Controllers/Table/ZoomSearchControllerTest.php
Maurício Meneghini Fauth 3c618c22a9
Add ServerRequest parameter to all controllers
Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2022-07-28 01:00:08 -03:00

76 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers\Table;
use PhpMyAdmin\ConfigStorage\Relation;
use PhpMyAdmin\Controllers\Table\ZoomSearchController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Table\Search;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
/**
* @covers \PhpMyAdmin\Controllers\Table\ZoomSearchController
*/
class ZoomSearchControllerTest extends AbstractTestCase
{
/** @var DatabaseInterface */
protected $dbi;
/** @var DbiDummy */
protected $dummyDbi;
protected function setUp(): void
{
parent::setUp();
$this->dummyDbi = $this->createDbiDummy();
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
$GLOBALS['dbi'] = $this->dbi;
}
public function testZoomSearchController(): void
{
$GLOBALS['server'] = 2;
$GLOBALS['db'] = 'test_db';
$GLOBALS['table'] = 'test_table';
$GLOBALS['text_dir'] = 'ltr';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['Server']['DisableIS'] = true;
$this->dummyDbi->addSelectDb('test_db');
$this->dummyDbi->addResult('SHOW TABLES LIKE \'test_table\';', [['test_table']]);
$response = new ResponseRenderer();
$template = new Template();
$controller = new ZoomSearchController(
$response,
$template,
new Search($this->dbi),
new Relation($this->dbi),
$this->dbi
);
$controller($this->createStub(ServerRequest::class));
$expected = $template->render('table/zoom_search/index', [
'db' => $GLOBALS['db'],
'table' => $GLOBALS['table'],
'goto' => 'index.php?route=/sql&server=2&lang=en',
'self' => $controller,
'geom_column_flag' => false,
'column_names' => ['id', 'name', 'datetimefield'],
'data_label' => 'name',
'keys' => [],
'criteria_column_names' => null,
'criteria_column_types' => null,
'max_plot_limit' => 500,
]);
$this->assertSame($expected, $response->getHTMLResult());
}
}