Translated using Weblate (Slovenian)
[phpmyadmin.git] / test / classes / StorageEngineTest.php
blob1240a1693b1346c4bfd537e437fe99f2f707f5cb
1 <?php
2 /**
3 * Tests for StorageEngine.php
4 */
6 declare(strict_types=1);
8 namespace PhpMyAdmin\Tests;
10 use PhpMyAdmin\Engines\Bdb;
11 use PhpMyAdmin\Engines\Berkeleydb;
12 use PhpMyAdmin\Engines\Binlog;
13 use PhpMyAdmin\Engines\Innobase;
14 use PhpMyAdmin\Engines\Innodb;
15 use PhpMyAdmin\Engines\Memory;
16 use PhpMyAdmin\Engines\Merge;
17 use PhpMyAdmin\Engines\MrgMyisam;
18 use PhpMyAdmin\Engines\Myisam;
19 use PhpMyAdmin\Engines\Ndbcluster;
20 use PhpMyAdmin\Engines\Pbxt;
21 use PhpMyAdmin\Engines\PerformanceSchema;
22 use PhpMyAdmin\StorageEngine;
23 use PHPUnit\Framework\MockObject\MockObject;
25 /**
26 * Tests for StorageEngine.php
28 class StorageEngineTest extends AbstractTestCase
30 /** @var StorageEngine|MockObject */
31 protected $object;
33 /**
34 * Sets up the fixture, for example, opens a network connection.
35 * This method is called before a test is executed.
37 * @access protected
39 protected function setUp(): void
41 parent::setUp();
42 $GLOBALS['server'] = 1;
43 $this->object = $this->getMockForAbstractClass(
44 StorageEngine::class,
45 ['dummy']
49 /**
50 * Tears down the fixture, for example, closes a network connection.
51 * This method is called after a test is executed.
53 * @access protected
55 protected function tearDown(): void
57 parent::tearDown();
58 unset($this->object);
61 /**
62 * Test for getStorageEngines
64 public function testGetStorageEngines(): void
66 $this->assertEquals(
68 'dummy' => [
69 'Engine' => 'dummy',
70 'Support' => 'YES',
71 'Comment' => 'dummy comment',
73 'dummy2' => [
74 'Engine' => 'dummy2',
75 'Support' => 'NO',
76 'Comment' => 'dummy2 comment',
78 'FEDERATED' => [
79 'Engine' => 'FEDERATED',
80 'Support' => 'NO',
81 'Comment' => 'Federated MySQL storage engine',
83 'Pbxt' => [
84 'Engine' => 'Pbxt',
85 'Support' => 'NO',
86 'Comment' => 'Pbxt storage engine',
89 $this->object->getStorageEngines()
93 public function testGetArray(): void
95 $actual = $this->object->getArray();
97 $this->assertEquals(
99 'dummy' => [
100 'name' => 'dummy',
101 'comment' => 'dummy comment',
102 'is_default' => false,
105 $actual
110 * Test for StorageEngine::getEngine
112 * @param string $expectedClass Class that should be selected
113 * @param string $engineName Engine name
115 * @psalm-param class-string $expectedClass
117 * @dataProvider providerGetEngine
119 public function testGetEngine(string $expectedClass, string $engineName): void
121 $actual = StorageEngine::getEngine($engineName);
122 $this->assertInstanceOf($expectedClass, $actual);
126 * Provider for testGetEngine
128 * @return array
130 public function providerGetEngine(): array
132 return [
134 StorageEngine::class,
135 'unknown engine',
138 Bdb::class,
139 'Bdb',
142 Berkeleydb::class,
143 'Berkeleydb',
146 Binlog::class,
147 'Binlog',
150 Innobase::class,
151 'Innobase',
154 Innodb::class,
155 'Innodb',
158 Memory::class,
159 'Memory',
162 Merge::class,
163 'Merge',
166 MrgMyisam::class,
167 'Mrg_Myisam',
170 Myisam::class,
171 'Myisam',
174 Ndbcluster::class,
175 'Ndbcluster',
178 Pbxt::class,
179 'Pbxt',
182 PerformanceSchema::class,
183 'Performance_Schema',
189 * Test for isValid
191 public function testIsValid(): void
193 $this->assertTrue(
194 $this->object->isValid('PBMS')
196 $this->assertTrue(
197 $this->object->isValid('dummy')
199 $this->assertTrue(
200 $this->object->isValid('dummy2')
202 $this->assertFalse(
203 $this->object->isValid('invalid')
208 * Test for getPage
210 public function testGetPage(): void
212 $this->assertEquals(
214 $this->object->getPage('Foo')
219 * Test for getInfoPages
221 public function testGetInfoPages(): void
223 $this->assertEquals(
225 $this->object->getInfoPages()
230 * Test for getVariablesLikePattern
232 public function testGetVariablesLikePattern(): void
234 $this->assertEquals(
236 $this->object->getVariablesLikePattern()
241 * Test for getMysqlHelpPage
243 public function testGetMysqlHelpPage(): void
245 $this->assertEquals(
246 'dummy-storage-engine',
247 $this->object->getMysqlHelpPage()
252 * Test for getVariables
254 public function testGetVariables(): void
256 $this->assertEquals(
258 $this->object->getVariables()
263 * Test for getSupportInformationMessage
265 public function testGetSupportInformationMessage(): void
267 $this->assertEquals(
268 'dummy is available on this MySQL server.',
269 $this->object->getSupportInformationMessage()
272 $this->object->support = 1;
273 $this->assertEquals(
274 'dummy has been disabled for this MySQL server.',
275 $this->object->getSupportInformationMessage()
278 $this->object->support = 2;
279 $this->assertEquals(
280 'dummy is available on this MySQL server.',
281 $this->object->getSupportInformationMessage()
284 $this->object->support = 3;
285 $this->assertEquals(
286 'dummy is the default storage engine on this MySQL server.',
287 $this->object->getSupportInformationMessage()
292 * Test for getComment
294 public function testGetComment(): void
296 $this->assertEquals(
297 'dummy comment',
298 $this->object->getComment()
303 * Test for getTitle
305 public function testGetTitle(): void
307 $this->assertEquals(
308 'dummy',
309 $this->object->getTitle()
314 * Test for resolveTypeSize
316 public function testResolveTypeSize(): void
318 $this->assertEquals(
320 0 => 12,
321 1 => 'B',
323 $this->object->resolveTypeSize(12)