mirror of
https://github.com/e107inc/e107.git
synced 2025-08-02 20:57:26 +02:00
Issue #5382 - Fix history table creation.
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -17,6 +17,7 @@ class db_verifyTest extends \Codeception\Test\Unit
|
|||||||
|
|
||||||
protected function _before()
|
protected function _before()
|
||||||
{
|
{
|
||||||
|
|
||||||
require_once(e_HANDLER . "db_verify_class.php");
|
require_once(e_HANDLER . "db_verify_class.php");
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
@@ -32,6 +33,7 @@ class db_verifyTest extends \Codeception\Test\Unit
|
|||||||
|
|
||||||
public function testGetFields()
|
public function testGetFields()
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = "table_id int(10) unsigned NOT NULL auto_increment,
|
$data = "table_id int(10) unsigned NOT NULL auto_increment,
|
||||||
table_name varchar(100) NOT NULL default '',
|
table_name varchar(100) NOT NULL default '',
|
||||||
table_email 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()
|
public function testClearCache()
|
||||||
{
|
{
|
||||||
@@ -296,6 +299,7 @@ class db_verifyTest extends \Codeception\Test\Unit
|
|||||||
*/
|
*/
|
||||||
public function testGetIndexOptionalLengthAndSortOrder()
|
public function testGetIndexOptionalLengthAndSortOrder()
|
||||||
{
|
{
|
||||||
|
|
||||||
$data = <<<EOF
|
$data = <<<EOF
|
||||||
`field1` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
`field1` int(10) unsigned NOT NULL AUTO_INCREMENT,
|
||||||
`field2` varchar(100) NOT NULL DEFAULT '',
|
`field2` varchar(100) NOT NULL DEFAULT '',
|
||||||
@@ -338,6 +342,51 @@ EOF;
|
|||||||
self::assertEquals($expected, $result);
|
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!
|
* FIXME: This test has no assertions!
|
||||||
*/
|
*/
|
||||||
@@ -445,6 +494,7 @@ EOF;
|
|||||||
|
|
||||||
public function testToMysql()
|
public function testToMysql()
|
||||||
{
|
{
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
0 =>
|
0 =>
|
||||||
array(
|
array(
|
||||||
@@ -510,6 +560,7 @@ EOF;
|
|||||||
*/
|
*/
|
||||||
public function testGetSqlFileTables()
|
public function testGetSqlFileTables()
|
||||||
{
|
{
|
||||||
|
|
||||||
$tests = array(
|
$tests = array(
|
||||||
|
|
||||||
|
|
||||||
@@ -817,7 +868,7 @@ EOF;
|
|||||||
self::assertEquals($data, $actual['data'][$k], "Table " . $table . "['data'][" . $k . "] did not match.");
|
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,
|
$sql = "`schedule_id` int(10) unsigned NOT NULL auto_increment,
|
||||||
`schedule_user_id` int(11) NOT NULL,
|
`schedule_user_id` int(11) NOT NULL,
|
||||||
`schedule_invoice_id` int(11) NOT NULL,
|
`schedule_invoice_id` int(11) NOT NULL,
|
||||||
@@ -874,7 +924,7 @@ EOF;
|
|||||||
KEY `schedule_invoice_id` (`schedule_invoice_id`)
|
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']);
|
$this->dbv->prepareResults('schedule', 'myplugin', $result['sqlData'], $result['fileData']);
|
||||||
|
|
||||||
@@ -1002,9 +1052,9 @@ EOF;
|
|||||||
|
|
||||||
$result = $this->dbv->prepareResults('schedule', 'myplugin', $result['sqlData'], $result['fileData']);
|
$result = $this->dbv->prepareResults('schedule', 'myplugin', $result['sqlData'], $result['fileData']);
|
||||||
$resultFields = $this->dbv->getErrors();
|
$resultFields = $this->dbv->getErrors();
|
||||||
$expected = array (
|
$expected = array(
|
||||||
'schedule' =>
|
'schedule' =>
|
||||||
array (
|
array(
|
||||||
'_status' => 8,
|
'_status' => 8,
|
||||||
'_file' => 'myplugin',
|
'_file' => 'myplugin',
|
||||||
'_valid_8' => 'utf8mb4',
|
'_valid_8' => 'utf8mb4',
|
||||||
@@ -1018,6 +1068,7 @@ EOF;
|
|||||||
|
|
||||||
public function testSyntaxCheck()
|
public function testSyntaxCheck()
|
||||||
{
|
{
|
||||||
|
|
||||||
$file = "`affiliate_id` int(10) unsigned NOT NULL auto_increment,
|
$file = "`affiliate_id` int(10) unsigned NOT NULL auto_increment,
|
||||||
`affiliate_code` varchar(10) NOT NULL DEFAULT '',
|
`affiliate_code` varchar(10) NOT NULL DEFAULT '',
|
||||||
`affiliate_name` varchar(30) NOT NULL DEFAULT '',
|
`affiliate_name` varchar(30) NOT NULL DEFAULT '',
|
||||||
@@ -1042,7 +1093,6 @@ EOF;
|
|||||||
$result = $this->dbv->hasSyntaxIssue($file);
|
$result = $this->dbv->hasSyntaxIssue($file);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
var_export($result);
|
var_export($result);
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -1071,6 +1121,7 @@ EOF;
|
|||||||
|
|
||||||
public function testGetCanonicalStorageEngine()
|
public function testGetCanonicalStorageEngine()
|
||||||
{
|
{
|
||||||
|
|
||||||
$input = "InnoDB";
|
$input = "InnoDB";
|
||||||
|
|
||||||
$output = $this->dbv->getCanonicalStorageEngine($input);
|
$output = $this->dbv->getCanonicalStorageEngine($input);
|
||||||
@@ -1080,6 +1131,7 @@ EOF;
|
|||||||
|
|
||||||
public function testGetCanonicalStorageEngineUnknownStorageEngine()
|
public function testGetCanonicalStorageEngineUnknownStorageEngine()
|
||||||
{
|
{
|
||||||
|
|
||||||
$this->expectException(UnexpectedValueException::class);
|
$this->expectException(UnexpectedValueException::class);
|
||||||
|
|
||||||
$this->dbv->getCanonicalStorageEngine("FakeEngine");
|
$this->dbv->getCanonicalStorageEngine("FakeEngine");
|
||||||
@@ -1087,6 +1139,7 @@ EOF;
|
|||||||
|
|
||||||
public function testGetCanonicalCharsetUtf8Alias()
|
public function testGetCanonicalCharsetUtf8Alias()
|
||||||
{
|
{
|
||||||
|
|
||||||
$input = "utf8";
|
$input = "utf8";
|
||||||
$expected = "utf8mb4";
|
$expected = "utf8mb4";
|
||||||
|
|
||||||
@@ -1097,6 +1150,7 @@ EOF;
|
|||||||
|
|
||||||
public function testGetCanonicalCharsetOther()
|
public function testGetCanonicalCharsetOther()
|
||||||
{
|
{
|
||||||
|
|
||||||
$inputs = ["latin1", "utf8mb3", "utf8mb4"];
|
$inputs = ["latin1", "utf8mb3", "utf8mb4"];
|
||||||
|
|
||||||
foreach($inputs as $input)
|
foreach($inputs as $input)
|
||||||
@@ -1109,6 +1163,7 @@ EOF;
|
|||||||
|
|
||||||
public function testGetIntendedStorageEngine()
|
public function testGetIntendedStorageEngine()
|
||||||
{
|
{
|
||||||
|
|
||||||
$output = $this->dbv->getIntendedStorageEngine("MyISAM");
|
$output = $this->dbv->getIntendedStorageEngine("MyISAM");
|
||||||
self::assertEquals("InnoDB", $output);
|
self::assertEquals("InnoDB", $output);
|
||||||
|
|
||||||
@@ -1130,6 +1185,7 @@ EOF;
|
|||||||
|
|
||||||
public function testGetIntendedCharset()
|
public function testGetIntendedCharset()
|
||||||
{
|
{
|
||||||
|
|
||||||
$output = $this->dbv->getIntendedCharset("");
|
$output = $this->dbv->getIntendedCharset("");
|
||||||
self::assertEquals("utf8mb4", $output);
|
self::assertEquals("utf8mb4", $output);
|
||||||
|
|
||||||
@@ -1154,6 +1210,7 @@ EOF;
|
|||||||
|
|
||||||
public function testRunFix()
|
public function testRunFix()
|
||||||
{
|
{
|
||||||
|
|
||||||
self::markTestSkipped('Inconsistent behavior');
|
self::markTestSkipped('Inconsistent behavior');
|
||||||
|
|
||||||
$sql = e107::getDb();
|
$sql = e107::getDb();
|
||||||
@@ -1165,7 +1222,7 @@ EOF;
|
|||||||
|
|
||||||
// Prepare table.
|
// Prepare table.
|
||||||
$sql->gen('ALTER TABLE `#rss` CONVERT TO CHARACTER SET utf8 COLLATE utf8_general_ci;');
|
$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');
|
$row = $sql->fetch('assoc');
|
||||||
|
|
||||||
if(isset($row['Collation'])) // TODO Get Working on all.
|
if(isset($row['Collation'])) // TODO Get Working on all.
|
||||||
@@ -1181,7 +1238,7 @@ EOF;
|
|||||||
|
|
||||||
|
|
||||||
// validate table.
|
// validate table.
|
||||||
$sql->gen('SHOW TABLE STATUS WHERE Name = "'.MPREFIX.'rss"');
|
$sql->gen('SHOW TABLE STATUS WHERE Name = "' . MPREFIX . 'rss"');
|
||||||
$row = $sql->fetch('assoc');
|
$row = $sql->fetch('assoc');
|
||||||
|
|
||||||
if(isset($row['Collation'])) // TODO Get Working on all.
|
if(isset($row['Collation'])) // TODO Get Working on all.
|
||||||
@@ -1190,7 +1247,6 @@ EOF;
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user