Remove some useless comments
[phpmyadmin.git] / test / classes / Engines / PbxtTest.php
blob7619823fe37fcd1ca67573bc31448c488c11278f
1 <?php
2 /**
3 * Tests for PMA_StorageEngine_pbxt
4 */
6 declare(strict_types=1);
8 namespace PhpMyAdmin\Tests\Engines;
10 use PhpMyAdmin\Core;
11 use PhpMyAdmin\Engines\Pbxt;
12 use PhpMyAdmin\Tests\AbstractTestCase;
13 use function sprintf;
15 class PbxtTest extends AbstractTestCase
17 /** @var Pbxt */
18 protected $object;
20 /**
21 * Sets up the fixture, for example, opens a network connection.
22 * This method is called before a test is executed.
24 * @access protected
26 protected function setUp(): void
28 parent::setUp();
29 parent::loadDefaultConfig();
31 $GLOBALS['server'] = 0;
32 $this->object = new Pbxt('pbxt');
35 /**
36 * Tears down the fixture, for example, closes a network connection.
37 * This method is called after a test is executed.
39 * @access protected
41 protected function tearDown(): void
43 parent::tearDown();
44 unset($this->object);
47 /**
48 * Test for getVariables
50 public function testGetVariables(): void
52 $this->assertEquals(
53 $this->object->getVariables(),
55 'pbxt_index_cache_size' => [
56 'title' => __('Index cache size'),
57 'desc' => __(
58 'This is the amount of memory allocated to the'
59 . ' index cache. Default value is 32MB. The memory'
60 . ' allocated here is used only for caching index pages.'
62 'type' => 1,
64 'pbxt_record_cache_size' => [
65 'title' => __('Record cache size'),
66 'desc' => __(
67 'This is the amount of memory allocated to the'
68 . ' record cache used to cache table data. The default'
69 . ' value is 32MB. This memory is used to cache changes to'
70 . ' the handle data (.xtd) and row pointer (.xtr) files.'
72 'type' => 1,
74 'pbxt_log_cache_size' => [
75 'title' => __('Log cache size'),
76 'desc' => __(
77 'The amount of memory allocated to the'
78 . ' transaction log cache used to cache on transaction log'
79 . ' data. The default is 16MB.'
81 'type' => 1,
83 'pbxt_log_file_threshold' => [
84 'title' => __('Log file threshold'),
85 'desc' => __(
86 'The size of a transaction log before rollover,'
87 . ' and a new log is created. The default value is 16MB.'
89 'type' => 1,
91 'pbxt_transaction_buffer_size' => [
92 'title' => __('Transaction buffer size'),
93 'desc' => __(
94 'The size of the global transaction log buffer'
95 . ' (the engine allocates 2 buffers of this size).'
96 . ' The default is 1MB.'
98 'type' => 1,
100 'pbxt_checkpoint_frequency' => [
101 'title' => __('Checkpoint frequency'),
102 'desc' => __(
103 'The amount of data written to the transaction'
104 . ' log before a checkpoint is performed.'
105 . ' The default value is 24MB.'
107 'type' => 1,
109 'pbxt_data_log_threshold' => [
110 'title' => __('Data log threshold'),
111 'desc' => __(
112 'The maximum size of a data log file. The default'
113 . ' value is 64MB. PBXT can create a maximum of 32000 data'
114 . ' logs, which are used by all tables. So the value of'
115 . ' this variable can be increased to increase the total'
116 . ' amount of data that can be stored in the database.'
118 'type' => 1,
120 'pbxt_garbage_threshold' => [
121 'title' => __('Garbage threshold'),
122 'desc' => __(
123 'The percentage of garbage in a data log file'
124 . ' before it is compacted. This is a value between 1 and'
125 . ' 99. The default is 50.'
127 'type' => 2,
129 'pbxt_log_buffer_size' => [
130 'title' => __('Log buffer size'),
131 'desc' => __(
132 'The size of the buffer used when writing a data'
133 . ' log. The default is 256MB. The engine allocates one'
134 . ' buffer per thread, but only if the thread is required'
135 . ' to write a data log.'
137 'type' => 1,
139 'pbxt_data_file_grow_size' => [
140 'title' => __('Data file grow size'),
141 'desc' => __('The grow size of the handle data (.xtd) files.'),
142 'type' => 1,
144 'pbxt_row_file_grow_size' => [
145 'title' => __('Row file grow size'),
146 'desc' => __('The grow size of the row pointer (.xtr) files.'),
147 'type' => 1,
149 'pbxt_log_file_count' => [
150 'title' => __('Log file count'),
151 'desc' => __(
152 'This is the number of transaction log files'
153 . ' (pbxt/system/xlog*.xt) the system will maintain. If the'
154 . ' number of logs exceeds this value then old logs will be'
155 . ' deleted, otherwise they are renamed and given the next'
156 . ' highest number.'
158 'type' => 2,
165 * Test for resolveTypeSize
167 * @param string $formatted_size the size expression (for example 8MB)
168 * @param array $output Expected output
170 * @dataProvider providerFortTestResolveTypeSize
172 public function testResolveTypeSize(string $formatted_size, array $output): void
174 $this->assertEquals(
175 $this->object->resolveTypeSize($formatted_size),
176 $output
181 * Provider for testResolveTypeSize
183 * @return array
185 public function providerFortTestResolveTypeSize(): array
187 return [
189 '8MB',
191 0 => '8,192',
192 1 => 'KiB',
196 '10mb',
198 0 => '-1',
199 1 => 'B',
203 'A4',
205 0 => '0',
206 1 => 'B',
213 * Test for getInfoPages
215 public function testGetInfoPages(): void
217 $this->assertEquals(
218 $this->object->getInfoPages(),
219 ['Documentation' => 'Documentation']
224 * Test for getPage
226 public function testGetPage(): void
228 $this->assertEquals(
229 $this->object->getPage('Documentation'),
230 '<p>'
231 . sprintf(
233 'Documentation and further information about PBXT'
234 . ' can be found on the %sPrimeBase XT Home Page%s.'
236 '<a href="' . Core::linkURL('https://mariadb.com/kb/en/mariadb/about-pbxt/')
237 . '" rel="noopener noreferrer" target="_blank">',
238 '</a>'
240 . '</p>' . "\n"
243 $this->assertEquals(
244 $this->object->getPage('NonExistMethod'),
245 false