3 declare(strict_types
=1);
5 namespace PhpMyAdmin\Tests\Plugins\Export\Helpers
;
7 use PhpMyAdmin\Plugins\Export\Helpers\TableProperty
;
8 use PhpMyAdmin\Tests\AbstractTestCase
;
10 class TablePropertyTest
extends AbstractTestCase
12 /** @var TableProperty */
16 * Configures global environment.
18 protected function setUp(): void
21 $GLOBALS['server'] = 0;
30 $this->object = new TableProperty($row);
34 * tearDown for test cases
36 protected function tearDown(): void
42 public function testConstructor(): void
56 $this->object->nullable
66 $this->object->defaultValue
75 public function testGetPureType(): void
77 $this->object->type
= 'int(10)';
81 $this->object->getPureType()
84 $this->object->type
= 'char';
88 $this->object->getPureType()
93 * @param string $nullable nullable value
94 * @param string $expected expected output
96 * @dataProvider isNotNullProvider
98 public function testIsNotNull(string $nullable, string $expected): void
100 $this->object->nullable
= $nullable;
104 $this->object->isNotNull()
109 * Data provider for testIsNotNull
111 * @return array Test Data
113 public function isNotNullProvider(): array
132 * @param string $key key value
133 * @param string $expected expected output
135 * @dataProvider isUniqueProvider
137 public function testIsUnique(string $key, string $expected): void
139 $this->object->key
= $key;
143 $this->object->isUnique()
148 * Data provider for testIsUnique
150 * @return array Test Data
152 public function isUniqueProvider(): array
179 * @param string $type type value
180 * @param string $expected expected output
182 * @dataProvider getDotNetPrimitiveTypeProvider
184 public function testGetDotNetPrimitiveType(string $type, string $expected): void
186 $this->object->type
= $type;
190 $this->object->getDotNetPrimitiveType()
195 * Data provider for testGetDotNetPrimitiveType
197 * @return array Test Data
199 public function getDotNetPrimitiveTypeProvider(): array
250 * @param string $type type value
251 * @param string $expected expected output
253 * @dataProvider getDotNetObjectTypeProvider
255 public function testGetDotNetObjectType(string $type, string $expected): void
257 $this->object->type
= $type;
261 $this->object->getDotNetObjectType()
266 * Data provider for testGetDotNetObjectType
268 * @return array Test Data
270 public function getDotNetObjectTypeProvider(): array
320 public function testGetIndexName(): void
322 $this->object->name
= "ä'7<ab>";
323 $this->object->key
= 'PRI';
326 "index=\"ä'7<ab>\"",
327 $this->object->getIndexName()
330 $this->object->key
= '';
334 $this->object->getIndexName()
338 public function testIsPK(): void
340 $this->object->key
= 'PRI';
343 $this->object->isPK()
346 $this->object->key
= '';
349 $this->object->isPK()
353 public function testFormatCs(): void
355 $this->object->name
= 'Name#name#123';
359 $this->object->formatCs('text123#name#')
363 public function testFormatXml(): void
365 $this->object->name
= '"a\'';
368 '"a\'index=""a\'"',
369 $this->object->formatXml('#name##indexName#')
373 public function testFormat(): void
376 'NameintInt32intfalsetrue',
377 $this->object->format(
378 '#ucfirstName##dotNetPrimitiveType##dotNetObjectType##type#' .