1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-31 20:00:37 +02:00

Issue #5382 - Fix history table creation.

This commit is contained in:
camer0n
2025-04-08 17:29:10 -07:00
parent 62d53cd5d8
commit e5edbf665c
2 changed files with 606 additions and 509 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -17,6 +17,7 @@ class db_verifyTest extends \Codeception\Test\Unit
protected function _before()
{
require_once(e_HANDLER . "db_verify_class.php");
try
{
@@ -32,6 +33,7 @@ class db_verifyTest extends \Codeception\Test\Unit
public function testGetFields()
{
$data = "table_id int(10) unsigned NOT NULL auto_increment,
table_name varchar(100) NOT NULL default '',
table_email varchar(100) NOT NULL default '',
@@ -216,6 +218,7 @@ class db_verifyTest extends \Codeception\Test\Unit
}
/*
public function testClearCache()
{
@@ -296,6 +299,7 @@ class db_verifyTest extends \Codeception\Test\Unit
*/
public function testGetIndexOptionalLengthAndSortOrder()
{
$data = <<<EOF
`field1` int(10) unsigned NOT NULL AUTO_INCREMENT,
`field2` varchar(100) NOT NULL DEFAULT '',
@@ -338,6 +342,51 @@ EOF;
self::assertEquals($expected, $result);
}
function testGetIndexCompositeKeys()
{
$data = <<<DATA
history_id int(10) unsigned NOT NULL auto_increment,
history_table varchar(64) NOT NULL default '',
history_pid varchar(64) NOT NULL default '',
history_record_id int(10) unsigned NOT NULL default '0',
history_action enum('delete','restore','update') NOT NULL,
history_data LONGTEXT DEFAULT NULL,
history_user_id int(10) unsigned NOT NULL default '0',
history_datestamp int(10) unsigned NOT NULL default '0',
history_restored int(10) unsigned NOT NULL default '0',
PRIMARY KEY (history_id),
KEY history_table_record (history_table, history_record_id),
KEY history_datestamp (history_datestamp)
DATA;
$expected = array(
'history_id' =>
array(
'type' => 'PRIMARY',
'keyname' => 'history_id',
'field' => 'history_id',
),
'history_table_record' =>
array(
'type' => '',
'keyname' => 'history_table,history_record_id',
'field' => 'history_table_record',
),
'history_datestamp' =>
array(
'type' => '',
'keyname' => 'history_datestamp',
'field' => 'history_datestamp',
),
);
$actual = $this->dbv->getIndex($data);
self::assertEquals($expected, $actual);
}
/**
* FIXME: This test has no assertions!
*/
@@ -445,6 +494,7 @@ EOF;
public function testToMysql()
{
$tests = array(
0 =>
array(
@@ -510,6 +560,7 @@ EOF;
*/
public function testGetSqlFileTables()
{
$tests = array(
@@ -817,7 +868,7 @@ EOF;
self::assertEquals($data, $actual['data'][$k], "Table " . $table . "['data'][" . $k . "] did not match.");
}
self::assertEquals($expected[$table]['engine'], $actual['engine'], "Test Key: '" . $table. "' failed on 'engine'");
self::assertEquals($expected[$table]['engine'], $actual['engine'], "Test Key: '" . $table . "' failed on 'engine'");
}
@@ -850,7 +901,6 @@ EOF;
{
$sql = "`schedule_id` int(10) unsigned NOT NULL auto_increment,
`schedule_user_id` int(11) NOT NULL,
`schedule_invoice_id` int(11) NOT NULL,
@@ -874,7 +924,7 @@ EOF;
KEY `schedule_invoice_id` (`schedule_invoice_id`)
";
$result = $this->prepareResults($file,$sql);
$result = $this->prepareResults($file, $sql);
$this->dbv->prepareResults('schedule', 'myplugin', $result['sqlData'], $result['fileData']);
@@ -1002,9 +1052,9 @@ EOF;
$result = $this->dbv->prepareResults('schedule', 'myplugin', $result['sqlData'], $result['fileData']);
$resultFields = $this->dbv->getErrors();
$expected = array (
$expected = array(
'schedule' =>
array (
array(
'_status' => 8,
'_file' => 'myplugin',
'_valid_8' => 'utf8mb4',
@@ -1018,6 +1068,7 @@ EOF;
public function testSyntaxCheck()
{
$file = "`affiliate_id` int(10) unsigned NOT NULL auto_increment,
`affiliate_code` varchar(10) NOT NULL DEFAULT '',
`affiliate_name` varchar(30) NOT NULL DEFAULT '',
@@ -1042,7 +1093,6 @@ EOF;
$result = $this->dbv->hasSyntaxIssue($file);
var_export($result);
}
@@ -1071,6 +1121,7 @@ EOF;
public function testGetCanonicalStorageEngine()
{
$input = "InnoDB";
$output = $this->dbv->getCanonicalStorageEngine($input);
@@ -1080,6 +1131,7 @@ EOF;
public function testGetCanonicalStorageEngineUnknownStorageEngine()
{
$this->expectException(UnexpectedValueException::class);
$this->dbv->getCanonicalStorageEngine("FakeEngine");
@@ -1087,6 +1139,7 @@ EOF;
public function testGetCanonicalCharsetUtf8Alias()
{
$input = "utf8";
$expected = "utf8mb4";
@@ -1097,6 +1150,7 @@ EOF;
public function testGetCanonicalCharsetOther()
{
$inputs = ["latin1", "utf8mb3", "utf8mb4"];
foreach($inputs as $input)
@@ -1109,6 +1163,7 @@ EOF;
public function testGetIntendedStorageEngine()
{
$output = $this->dbv->getIntendedStorageEngine("MyISAM");
self::assertEquals("InnoDB", $output);
@@ -1130,6 +1185,7 @@ EOF;
public function testGetIntendedCharset()
{
$output = $this->dbv->getIntendedCharset("");
self::assertEquals("utf8mb4", $output);
@@ -1154,6 +1210,7 @@ EOF;
public function testRunFix()
{
self::markTestSkipped('Inconsistent behavior');
$sql = e107::getDb();
@@ -1165,7 +1222,7 @@ EOF;
// Prepare table.
$sql->gen('ALTER TABLE `#rss` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;');
$sql->gen('SHOW TABLE STATUS WHERE Name = "'.MPREFIX.'rss"');
$sql->gen('SHOW TABLE STATUS WHERE Name = "' . MPREFIX . 'rss"');
$row = $sql->fetch('assoc');
if(isset($row['Collation'])) // TODO Get Working on all.
@@ -1181,7 +1238,7 @@ EOF;
// validate table.
$sql->gen('SHOW TABLE STATUS WHERE Name = "'.MPREFIX.'rss"');
$sql->gen('SHOW TABLE STATUS WHERE Name = "' . MPREFIX . 'rss"');
$row = $sql->fetch('assoc');
if(isset($row['Collation'])) // TODO Get Working on all.
@@ -1190,7 +1247,6 @@ EOF;
}
}
}