3 * Tests for StorageEngine.php
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
;
26 * Tests for StorageEngine.php
28 class StorageEngineTest
extends AbstractTestCase
30 /** @var StorageEngine|MockObject */
34 * Sets up the fixture, for example, opens a network connection.
35 * This method is called before a test is executed.
39 protected function setUp(): void
42 $GLOBALS['server'] = 1;
43 $this->object = $this->getMockForAbstractClass(
50 * Tears down the fixture, for example, closes a network connection.
51 * This method is called after a test is executed.
55 protected function tearDown(): void
62 * Test for getStorageEngines
64 public function testGetStorageEngines(): void
71 'Comment' => 'dummy comment',
76 'Comment' => 'dummy2 comment',
79 'Engine' => 'FEDERATED',
81 'Comment' => 'Federated MySQL storage engine',
86 'Comment' => 'Pbxt storage engine',
89 $this->object->getStorageEngines()
93 public function testGetArray(): void
95 $actual = $this->object->getArray();
101 'comment' => 'dummy comment',
102 'is_default' => false,
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
130 public function providerGetEngine(): array
134 StorageEngine
::class,
182 PerformanceSchema
::class,
183 'Performance_Schema',
191 public function testIsValid(): void
194 $this->object->isValid('PBMS')
197 $this->object->isValid('dummy')
200 $this->object->isValid('dummy2')
203 $this->object->isValid('invalid')
210 public function testGetPage(): void
214 $this->object->getPage('Foo')
219 * Test for getInfoPages
221 public function testGetInfoPages(): void
225 $this->object->getInfoPages()
230 * Test for getVariablesLikePattern
232 public function testGetVariablesLikePattern(): void
236 $this->object->getVariablesLikePattern()
241 * Test for getMysqlHelpPage
243 public function testGetMysqlHelpPage(): void
246 'dummy-storage-engine',
247 $this->object->getMysqlHelpPage()
252 * Test for getVariables
254 public function testGetVariables(): void
258 $this->object->getVariables()
263 * Test for getSupportInformationMessage
265 public function testGetSupportInformationMessage(): void
268 'dummy is available on this MySQL server.',
269 $this->object->getSupportInformationMessage()
272 $this->object->support
= 1;
274 'dummy has been disabled for this MySQL server.',
275 $this->object->getSupportInformationMessage()
278 $this->object->support
= 2;
280 'dummy is available on this MySQL server.',
281 $this->object->getSupportInformationMessage()
284 $this->object->support
= 3;
286 'dummy is the default storage engine on this MySQL server.',
287 $this->object->getSupportInformationMessage()
292 * Test for getComment
294 public function testGetComment(): void
298 $this->object->getComment()
305 public function testGetTitle(): void
309 $this->object->getTitle()
314 * Test for resolveTypeSize
316 public function testResolveTypeSize(): void
323 $this->object->resolveTypeSize(12)