From 4245ff138d763e4b932ac19b73c7000f410a8608 Mon Sep 17 00:00:00 2001 From: Cameron Date: Tue, 11 Sep 2018 14:16:10 -0700 Subject: [PATCH] Work in Progress. --- tests/unit/db_verifyTest.php | 72 +++++++++++++++++++++++++++++++++++- 1 file changed, 70 insertions(+), 2 deletions(-) diff --git a/tests/unit/db_verifyTest.php b/tests/unit/db_verifyTest.php index 15be116d9..444ee1a64 100644 --- a/tests/unit/db_verifyTest.php +++ b/tests/unit/db_verifyTest.php @@ -67,12 +67,26 @@ { } - +*/ public function testCompare() { + e107::getDB()->gen('ALTER TABLE `#submitnews` CHANGE `submitnews_id` `submitnews_id` INT(10) UNSIGNED NOT NULL;'); + e107::getDB()->gen('ALTER TABLE `#submitnews` DROP INDEX submitnews_id;'); + + $this->dbv->__construct(); + + print_r($this->dbv); + + // $this->dbv->compare('e107_submitnews'); + + $result = $this->dbv->errors['submitnews']; + + print_r($this->dbv->errors); + + // print_r($this->dbv->results); } - +/* public function testToMysql() { @@ -112,6 +126,26 @@ { $tests = array( + 'missing_index' => + "CREATE TABLE `e107_submitnews` ( + `submitnews_id` int(10) unsigned NOT NULL, + `submitnews_name` varchar(100) NOT NULL DEFAULT '', + `submitnews_email` varchar(100) NOT NULL DEFAULT '', + `submitnews_title` varchar(200) NOT NULL DEFAULT '', + `submitnews_category` tinyint(3) unsigned NOT NULL DEFAULT '0', + `submitnews_item` text NOT NULL, + `submitnews_datestamp` int(10) unsigned NOT NULL DEFAULT '0', + `submitnews_ip` varchar(45) NOT NULL DEFAULT '', + `submitnews_auth` tinyint(3) unsigned NOT NULL DEFAULT '0', + `submitnews_file` text NOT NULL, + `submitnews_keywords` varchar(255) NOT NULL DEFAULT '', + `submitnews_description` text, + `submitnews_summary` text, + `submitnews_media` text, + `submitnews_user` int(10) unsigned NOT NULL DEFAULT '0' + ) ENGINE=MyISAM DEFAULT CHARSET=utf8;", + + 'user_extended' => "CREATE TABLE `e107_user_extended` ( `user_extended_id` int(10) unsigned NOT NULL DEFAULT '0', @@ -183,6 +217,37 @@ ); $expected = array( + + 'missing_index' => array ( + 'tables' => + array ( + 0 => 'submitnews', + ), + 'data' => + array ( + 0 => '`submitnews_id` int(10) unsigned NOT NULL, + `submitnews_name` varchar(100) NOT NULL DEFAULT \'\', + `submitnews_email` varchar(100) NOT NULL DEFAULT \'\', + `submitnews_title` varchar(200) NOT NULL DEFAULT \'\', + `submitnews_category` tinyint(3) unsigned NOT NULL DEFAULT \'0\', + `submitnews_item` text NOT NULL, + `submitnews_datestamp` int(10) unsigned NOT NULL DEFAULT \'0\', + `submitnews_ip` varchar(45) NOT NULL DEFAULT \'\', + `submitnews_auth` tinyint(3) unsigned NOT NULL DEFAULT \'0\', + `submitnews_file` text NOT NULL, + `submitnews_keywords` varchar(255) NOT NULL DEFAULT \'\', + `submitnews_description` text, + `submitnews_summary` text, + `submitnews_media` text, + `submitnews_user` int(10) unsigned NOT NULL DEFAULT \'0\'', + ), + 'engine' => + array ( + 0 => 'MyISAM', + ), + ), + + 'user_extended' => array ( 'tables' => array ( @@ -294,11 +359,14 @@ ); + foreach($tests as $table => $sql) { $actual = $this->dbv->getSqlFileTables($sql); + + $this->assertEquals($actual['tables'], $expected[$table]['tables'], "Table ".$table." could not be parsed."); foreach($expected[$table]['data'] as $k=>$data)