Refactored ConfigFile class so that it is no longer a singleton
[phpmyadmin.git] / test / engines / PMA_StorageEngine_pbxt_test.php
bloba14914d59b273361ffded4c252fbf1bf5de660db
1 <?php
2 /* vim: set expandtab sw=4 ts=4 sts=4: */
3 /**
4 * Tests for PMA_StorageEngine_pbxt
6 * @package PhpMyAdmin-test
7 */
9 /*
10 * Include to test.
13 require_once 'libraries/StorageEngine.class.php';
14 require_once 'libraries/engines/pbxt.lib.php';
15 require_once 'libraries/php-gettext/gettext.inc';
16 require_once 'libraries/Util.class.php';
17 require_once 'libraries/core.lib.php';
18 require_once 'libraries/database_interface.inc.php';
19 require_once 'libraries/Tracker.class.php';
21 class PMA_StorageEngine_pbxt_Test extends PHPUnit_Framework_TestCase
23 /**
24 * @access protected
26 protected $object;
28 /**
29 * Sets up the fixture, for example, opens a network connection.
30 * This method is called before a test is executed.
32 * @access protected
33 * @return void
35 protected function setUp()
37 $this->object = new PMA_StorageEngine_pbxt('pbxt');
40 /**
41 * Tears down the fixture, for example, closes a network connection.
42 * This method is called after a test is executed.
44 * @access protected
45 * @return void
47 protected function tearDown()
49 unset($this->object);
52 /**
53 * Test for getVariables
55 * @return void
57 public function testGetVariables()
59 $this->assertEquals(
60 $this->object->getVariables(),
61 array(
62 'pbxt_index_cache_size' => array(
63 'title' => __('Index cache size'),
64 'desc' => __('This is the amount of memory allocated to the index cache. Default value is 32MB. The memory allocated here is used only for caching index pages.'),
65 'type' => 1
67 'pbxt_record_cache_size' => array(
68 'title' => __('Record cache size'),
69 'desc' => __('This is the amount of memory allocated to the record cache used to cache table data. The default value is 32MB. This memory is used to cache changes to the handle data (.xtd) and row pointer (.xtr) files.'),
70 'type' => 1
72 'pbxt_log_cache_size' => array(
73 'title' => __('Log cache size'),
74 'desc' => __('The amount of memory allocated to the transaction log cache used to cache on transaction log data. The default is 16MB.'),
75 'type' => 1
77 'pbxt_log_file_threshold' => array(
78 'title' => __('Log file threshold'),
79 'desc' => __('The size of a transaction log before rollover, and a new log is created. The default value is 16MB.'),
80 'type' => 1
82 'pbxt_transaction_buffer_size' => array(
83 'title' => __('Transaction buffer size'),
84 'desc' => __('The size of the global transaction log buffer (the engine allocates 2 buffers of this size). The default is 1MB.'),
85 'type' => 1
87 'pbxt_checkpoint_frequency' => array(
88 'title' => __('Checkpoint frequency'),
89 'desc' => __('The amount of data written to the transaction log before a checkpoint is performed. The default value is 24MB.'),
90 'type' => 1
92 'pbxt_data_log_threshold' => array(
93 'title' => __('Data log threshold'),
94 'desc' => __('The maximum size of a data log file. The default value is 64MB. PBXT can create a maximum of 32000 data logs, which are used by all tables. So the value of this variable can be increased to increase the total amount of data that can be stored in the database.'),
95 'type' => 1
97 'pbxt_garbage_threshold' => array(
98 'title' => __('Garbage threshold'),
99 'desc' => __('The percentage of garbage in a data log file before it is compacted. This is a value between 1 and 99. The default is 50.'),
100 'type' => 2
102 'pbxt_log_buffer_size' => array(
103 'title' => __('Log buffer size'),
104 'desc' => __('The size of the buffer used when writing a data log. The default is 256MB. The engine allocates one buffer per thread, but only if the thread is required to write a data log.'),
105 'type' => 1
107 'pbxt_data_file_grow_size' => array(
108 'title' => __('Data file grow size'),
109 'desc' => __('The grow size of the handle data (.xtd) files.'),
110 'type' => 1
112 'pbxt_row_file_grow_size' => array(
113 'title' => __('Row file grow size'),
114 'desc' => __('The grow size of the row pointer (.xtr) files.'),
115 'type' => 1
117 'pbxt_log_file_count' => array(
118 'title' => __('Log file count'),
119 'desc' => __('This is the number of transaction log files (pbxt/system/xlog*.xt) the system will maintain. If the number of logs exceeds this value then old logs will be deleted, otherwise they are renamed and given the next highest number.'),
120 'type' => 2
127 * Test for resolveTypeSize
129 * @param string $formatted_size the size expression (for example 8MB)
131 * @dataProvider providerFortTestResolveTypeSize
133 * @return void
135 public function testResolveTypeSize($formatted_size, $output)
137 $this->assertEquals(
138 $this->object->resolveTypeSize($formatted_size),
139 $output
144 * Provider for testResolveTypeSize
146 * @return array
148 public function providerFortTestResolveTypeSize()
150 return array(
151 array(
152 '8MB',
153 array (
154 0 => '8,192',
155 1 => 'KiB'
158 array(
159 '10mb',
160 array (
161 0 => '-1',
162 1 => 'B'
165 array(
166 'A4',
167 array (
168 0 => '0',
169 1 => 'B'
176 * Test for getInfoPages
178 * @return void
180 public function testGetInfoPages()
182 $this->assertEquals(
183 $this->object->getInfoPages(),
184 array(
185 'Documentation' => 'Documentation'
191 * Test for getPage
193 * @return void
195 public function testGetPage()
197 $this->assertEquals(
198 $this->object->getPage('Documentation'),
199 '<p>'
200 . sprintf(__('Documentation and further information about PBXT can be found on the %sPrimeBase XT Home Page%s.'), '<a href="' . PMA_linkURL('http://www.primebase.com/xt/') . '" target="_blank">', '</a>')
201 . '</p>' . "\n"
202 . '<h3>' . __('Related Links') . '</h3>' . "\n"
203 . '<ul>' . "\n"
204 . '<li><a href="' . PMA_linkURL('http://pbxt.blogspot.com/')
205 . '" target="_blank">'
206 . __('The PrimeBase XT Blog by Paul McCullagh')
207 . '</a></li>' . "\n" . '</ul>' . "\n"
210 $this->assertEquals(
211 $this->object->getPage('NonExistMethod'),
212 false