phpmyadmin/test/classes/Controllers/Server/Status/Monitor/LogVarsControllerTest.php
Maurício Meneghini Fauth 556594b4cd
Fix coding standard spacing issues
- Fixes one line doc comments
- Fixes parent call spacing
- Fixes constant spacing

Signed-off-by: Maurício Meneghini Fauth <mauricio@fauth.dev>
2023-02-24 21:06:17 -03:00

86 lines
2.3 KiB
PHP

<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers\Server\Status\Monitor;
use PhpMyAdmin\Controllers\Server\Status\Monitor\LogVarsController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Server\Status\Data;
use PhpMyAdmin\Server\Status\Monitor;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
/** @covers \PhpMyAdmin\Controllers\Server\Status\Monitor\LogVarsController */
class LogVarsControllerTest extends AbstractTestCase
{
/** @var DatabaseInterface */
protected $dbi;
/** @var DbiDummy */
protected $dummyDbi;
/** @var Data */
private $data;
protected function setUp(): void
{
parent::setUp();
$GLOBALS['text_dir'] = 'ltr';
parent::setGlobalConfig();
parent::setTheme();
$this->dummyDbi = $this->createDbiDummy();
$this->dbi = $this->createDatabaseInterface($this->dummyDbi);
$GLOBALS['dbi'] = $this->dbi;
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['cfg']['Server']['host'] = 'localhost';
$this->data = new Data($this->dbi);
}
public function testLogVars(): void
{
$value = [
'general_log' => 'OFF',
'log_output' => 'FILE',
'long_query_time' => '10.000000',
'slow_query_log' => 'OFF',
];
$response = new ResponseRenderer();
$response->setAjax(true);
$controller = new LogVarsController(
$response,
new Template(),
$this->data,
new Monitor($GLOBALS['dbi']),
$GLOBALS['dbi'],
);
$request = $this->createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([
['varName', null, 'varName'],
]);
$this->dummyDbi->addSelectDb('mysql');
$controller($request);
$this->dummyDbi->assertAllSelectsConsumed();
$ret = $response->getJSONResult();
$this->assertEquals($value, $ret['message']);
}
}