1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
|
<?php
declare(strict_types=1);
namespace PhpMyAdmin\Tests\Controllers\Server;
use PhpMyAdmin\Controllers\Server\BinlogController;
use PhpMyAdmin\DatabaseInterface;
use PhpMyAdmin\Http\ServerRequest;
use PhpMyAdmin\Template;
use PhpMyAdmin\Tests\AbstractTestCase;
use PhpMyAdmin\Tests\Stubs\DbiDummy;
use PhpMyAdmin\Tests\Stubs\ResponseRenderer;
use PhpMyAdmin\Url;
use PhpMyAdmin\Utils\SessionCache;
/**
* @covers \PhpMyAdmin\Controllers\Server\BinlogController
*/
class BinlogControllerTest extends AbstractTestCase
{
/** @var DatabaseInterface */
protected $dbi;
/** @var DbiDummy */
protected $dummyDbi;
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['cfg']['MaxRows'] = 10;
$GLOBALS['cfg']['ServerDefault'] = 'server';
$GLOBALS['cfg']['Server']['DisableIS'] = false;
$GLOBALS['server'] = 1;
$GLOBALS['db'] = 'db';
$GLOBALS['table'] = 'table';
$GLOBALS['PMA_PHP_SELF'] = 'index.php';
SessionCache::set('profiling_supported', true);
}
public function testIndex(): void
{
$response = new ResponseRenderer();
$controller = new BinlogController($response, new Template(), $GLOBALS['dbi']);
$request = $this->createStub(ServerRequest::class);
$request->method('getParsedBodyParam')->willReturnMap([
['log', null, 'index1'],
['pos', 0, '3'],
]);
$this->dummyDbi->addSelectDb('mysql');
$controller($request);
$this->dummyDbi->assertAllSelectsConsumed();
$actual = $response->getHTMLResult();
$this->assertStringContainsString('Select binary log to view', $actual);
$this->assertStringContainsString('<option value="index1" selected>', $actual);
$this->assertStringContainsString('<option value="index2">', $actual);
$this->assertStringContainsString('Your SQL query has been executed successfully', $actual);
$this->assertStringContainsString("SHOW BINLOG EVENTS IN 'index1' LIMIT 3, 10", $actual);
$this->assertStringContainsString(
'<table class="table table-striped table-hover align-middle" id="binlogTable">',
$actual
);
$urlNavigation = Url::getFromRoute('/server/binlog') . '" data-post="log=index1&pos=3&'
. 'is_full_query=1&server=1&';
$this->assertStringContainsString($urlNavigation, $actual);
$this->assertStringContainsString('title="Previous"', $actual);
$this->assertStringContainsString('Log name', $actual);
$this->assertStringContainsString('Position', $actual);
$this->assertStringContainsString('Event type', $actual);
$this->assertStringContainsString('Server ID', $actual);
$this->assertStringContainsString('Original position', $actual);
$this->assertStringContainsString('index1_Log_name', $actual);
$this->assertStringContainsString('index1_Pos', $actual);
$this->assertStringContainsString('index1_Event_type', $actual);
$this->assertStringContainsString('index1_Server_id', $actual);
$this->assertStringContainsString('index1_Orig_log_pos', $actual);
$this->assertStringContainsString('index1_Info', $actual);
}
}
|