Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/phpmyadmin/phpmyadmin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorMo Sureerat <sureemo@gmail.com>2022-11-02 21:05:11 +0300
committerMo Sureerat <sureemo@gmail.com>2022-11-03 01:25:04 +0300
commitf8bee4cd5d187adc6b628f583adf6c4ee83c8514 (patch)
treead339979031aa15d43fc4ab500c4c679c6b71428 /test
parentbfe59e6e41eb07addde7fec1b5b19d2be7d3d6c4 (diff)
[ISSUE-17793] Insert record - fix null not selected if nullable UUID + insert error
Signed-off-by: Mo Sureerat <sureemo@gmail.com>
Diffstat (limited to 'test')
-rw-r--r--test/classes/InsertEditTest.php190
1 files changed, 156 insertions, 34 deletions
diff --git a/test/classes/InsertEditTest.php b/test/classes/InsertEditTest.php
index 96c8621224..7aa2aeda7c 100644
--- a/test/classes/InsertEditTest.php
+++ b/test/classes/InsertEditTest.php
@@ -1659,17 +1659,22 @@ class InsertEditTest extends AbstractTestCase
/**
* Test for getSpecialCharsAndBackupFieldForInsertingMode
+ *
+ * @param array $column Column parameters
+ * @param array $expected Expected result
+ * @psalm-param array<string, string|bool|null> $column
+ * @psalm-param array<bool|string> $expected
+ *
+ * @dataProvider providerForTestGetSpecialCharsAndBackupFieldForInsertingMode
*/
- public function testGetSpecialCharsAndBackupFieldForInsertingMode(): void
- {
- $column = [];
- $column['True_Type'] = 'bit';
- $column['Default'] = 'b\'101\'';
- $column['is_binary'] = true;
+ public function testGetSpecialCharsAndBackupFieldForInsertingMode(
+ array $column,
+ array $expected
+ ): void {
$GLOBALS['cfg']['ProtectBinary'] = false;
$GLOBALS['cfg']['ShowFunctionFields'] = true;
- $result = $this->callFunction(
+ $result = (array) $this->callFunction(
$this->insertEdit,
InsertEdit::class,
'getSpecialCharsAndBackupFieldForInsertingMode',
@@ -1677,37 +1682,154 @@ class InsertEditTest extends AbstractTestCase
);
$this->assertEquals(
- [
- false,
- 'b\'101\'',
- '101',
- '',
- '101',
- ],
+ $expected,
$result
);
+ }
- // case 2
- unset($column['Default']);
- $column['True_Type'] = 'char';
-
- $result = (array) $this->callFunction(
- $this->insertEdit,
- InsertEdit::class,
- 'getSpecialCharsAndBackupFieldForInsertingMode',
- [$column]
- );
-
- $this->assertEquals(
- [
- true,
- '',
- '',
- '',
- '',
+ /**
+ * Data provider for test getSpecialCharsAndBackupFieldForInsertingMode()
+ *
+ * @return array
+ * @psalm-return array<string, array{array<string, string|bool|null>, array<bool|string>}>
+ */
+ public function providerForTestGetSpecialCharsAndBackupFieldForInsertingMode(): array
+ {
+ return [
+ 'bit' => [
+ [
+ 'True_Type' => 'bit',
+ 'Default' => 'b\'101\'',
+ 'is_binary' => true,
+ ],
+ [
+ false,
+ 'b\'101\'',
+ '101',
+ '',
+ '101',
+ ],
],
- $result
- );
+ 'char' => [
+ [
+ 'True_Type' => 'char',
+ 'is_binary' => true,
+ ],
+ [
+ true,
+ '',
+ '',
+ '',
+ '',
+ ],
+ ],
+ 'time with CURRENT_TIMESTAMP value' => [
+ [
+ 'True_Type' => 'time',
+ 'Default' => 'CURRENT_TIMESTAMP',
+ ],
+ [
+ false,
+ 'CURRENT_TIMESTAMP',
+ 'CURRENT_TIMESTAMP',
+ '',
+ 'CURRENT_TIMESTAMP',
+ ],
+ ],
+ 'time with current_timestamp() value' => [
+ [
+ 'True_Type' => 'time',
+ 'Default' => 'current_timestamp()',
+ ],
+ [
+ false,
+ 'current_timestamp()',
+ 'current_timestamp()',
+ '',
+ 'current_timestamp()',
+ ],
+ ],
+ 'time with no dot value' => [
+ [
+ 'True_Type' => 'time',
+ 'Default' => '10',
+ ],
+ [
+ false,
+ '10',
+ '10.000000',
+ '',
+ '10.000000',
+ ],
+ ],
+ 'time with dot value' => [
+ [
+ 'True_Type' => 'time',
+ 'Default' => '10.08',
+ ],
+ [
+ false,
+ '10.08',
+ '10.080000',
+ '',
+ '10.080000',
+ ],
+ ],
+ 'any text with escape text default' => [
+ [
+ 'True_Type' => 'text',
+ 'Default' => '"lorem\"ipsem"',
+ ],
+ [
+ false,
+ '"lorem\"ipsem"',
+ 'lorem"ipsem',
+ '',
+ 'lorem"ipsem',
+ ],
+ ],
+ 'varchar with html special chars' => [
+ [
+ 'True_Type' => 'varchar',
+ 'Default' => 'hello world<br><b>lorem</b> ipsem',
+ ],
+ [
+ false,
+ 'hello world<br><b>lorem</b> ipsem',
+ 'hello world&lt;br&gt;&lt;b&gt;lorem&lt;/b&gt; ipsem',
+ '',
+ 'hello world&lt;br&gt;&lt;b&gt;lorem&lt;/b&gt; ipsem',
+ ],
+ ],
+ 'uuid with nullable' => [
+ [
+ 'True_Type' => 'uuid',
+ 'Default' => 'uuid()',
+ 'Null' => 'YES',
+ ],
+ [
+ true,
+ '',
+ '',
+ '',
+ '',
+ ],
+ ],
+ 'uuid with not nullable' => [
+ [
+ 'True_Type' => 'uuid',
+ 'Default' => 'uuid()',
+ 'Null' => 'NO',
+ ],
+ [
+ false,
+ 'uuid()',
+ 'uuid()',
+ '',
+ 'uuid()',
+ ],
+ ],
+ ];
}
/**