diff --git a/e107_tests/tests/_bootstrap.php b/e107_tests/tests/_bootstrap.php index 0a9d508de..d2b4cc181 100644 --- a/e107_tests/tests/_bootstrap.php +++ b/e107_tests/tests/_bootstrap.php @@ -1,57 +1,66 @@ $testDir\n", FILE_APPEND); + } +} else { + file_put_contents($logFile, "Plugins Dir not found or not a directory\n", FILE_APPEND); } file_put_contents($logFile, "Included: " . json_encode($pluginTestDirs, JSON_PRETTY_PRINT) . "\n", FILE_APPEND); +file_put_contents($logFile, "e_PLUGIN after scan: " . (defined('e_PLUGIN') ? e_PLUGIN : 'not defined') . "\n", FILE_APPEND); -if(!empty($pluginTestDirs)) -{ - Configuration::append(['include' => $pluginTestDirs]); - codecept_debug("Dynamic includes added: " . json_encode($pluginTestDirs)); -} -else -{ - codecept_debug("No plugin test directories found"); -} +// Skip Configuration::append to avoid config errors +// if (!empty($pluginTestDirs)) { +// Configuration::append(['include' => $pluginTestDirs]); +// codecept_debug("Dynamic includes added: " . json_encode($pluginTestDirs)); +// } else { +// codecept_debug("No plugin test directories found"); +// } +// Include required e107 file include(codecept_root_dir() . "/lib/PriorityCallbacks.php"); \ No newline at end of file diff --git a/e107_tests/tests/unit.suite.yml b/e107_tests/tests/unit.suite.yml index 58a64a506..d540b7f85 100644 --- a/e107_tests/tests/unit.suite.yml +++ b/e107_tests/tests/unit.suite.yml @@ -3,7 +3,6 @@ # Suite for unit or integration tests. actor: UnitTester -shuffle: true modules: enabled: - Asserts diff --git a/e107_tests/tests/unit/db_verifyTest.php b/e107_tests/tests/unit/db_verifyTest.php index 303e4dbc9..f7674fccc 100644 --- a/e107_tests/tests/unit/db_verifyTest.php +++ b/e107_tests/tests/unit/db_verifyTest.php @@ -823,13 +823,34 @@ EOF; } - - public function testPrepareResults() + private function prepareResults(string $file, string $sql) { $fileData = array(); $sqlData = array(); + $fileData['field'] = $this->dbv->getFields($file); + $sqlData['field'] = $this->dbv->getFields($sql); + + $fileData['index'] = $this->dbv->getIndex($file); + $sqlData['index'] = $this->dbv->getIndex($sql); + + $fileData['engine'] = $this->dbv->getIntendedStorageEngine("InnoDB"); + $sqlData['engine'] = $this->dbv->getCanonicalStorageEngine("InnoDB"); + + $fileData['charset'] = $this->dbv->getIntendedCharset("utf8mb4"); + $sqlData['charset'] = $this->dbv->getCanonicalCharset("utf8mb4"); + + + return ['fileData' => $fileData, 'sqlData' => $sqlData]; + + } + + public function testPrepareResults() + { + + + $sql = "`schedule_id` int(10) unsigned NOT NULL auto_increment, `schedule_user_id` int(11) NOT NULL, `schedule_invoice_id` int(11) NOT NULL, @@ -853,20 +874,9 @@ EOF; KEY `schedule_invoice_id` (`schedule_invoice_id`) "; + $result = $this->prepareResults($file,$sql); - $fileData['field'] = $this->dbv->getFields($file); - $sqlData['field'] = $this->dbv->getFields($sql); - - $fileData['index'] = $this->dbv->getIndex($file); - $sqlData['index'] = $this->dbv->getIndex($sql); - - $fileData['engine'] = $this->dbv->getIntendedStorageEngine("InnoDB"); - $sqlData['engine'] = $this->dbv->getCanonicalStorageEngine("InnoDB"); - - $fileData['charset'] = $this->dbv->getIntendedCharset("utf8mb4"); - $sqlData['charset'] = $this->dbv->getCanonicalCharset("utf8mb4"); - - $this->dbv->prepareResults('schedule', 'myplugin', $sqlData, $fileData); + $this->dbv->prepareResults('schedule', 'myplugin', $result['sqlData'], $result['fileData']); $resultFields = $this->dbv->getResults(); $expected = array( @@ -987,10 +997,10 @@ EOF; self::assertEquals($expected, $resultIndices); - $fileData['charset'] = "utf8mb4"; - $sqlData['charset'] = "utf8"; + $result['fileData']['charset'] = "utf8mb4"; + $result['sqlData']['charset'] = "utf8"; - $result = $this->dbv->prepareResults('schedule', 'myplugin', $sqlData, $fileData); + $result = $this->dbv->prepareResults('schedule', 'myplugin', $result['sqlData'], $result['fileData']); $resultFields = $this->dbv->getErrors(); $expected = array ( 'schedule' => @@ -1004,6 +1014,36 @@ EOF; self::assertSame($expected, $resultFields); self::assertSame(1, $this->dbv->errors()); + } + + 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 '', + 'affiliate_email` varchar(50) NOT NULL DEFAULT '', + 'affiliate_phone` varchar(16) NOT NULL DEFAULT '', + `affiliate_sef` varchar(30) NOT NULL DEFAULT '', + `affiliate_schema` varchar(30) NOT NULL DEFAULT '', + `affiliate_cust_id` int(11) NOT NULL, + `affiliate_user_id` int(11) NOT NULL, + `affiliate_date` int(11) NOT NULL, + `affiliate_discount` DECIMAL(6,2) NOT NULL DEFAULT '0.00', + `affiliate_expires` int(11) NOT NULL, + `affiliate_earned` int(6) NOT NULL, + `affiliate_spent` int(6) NOT NULL, + `affiliate_balance` int(6) NOT NULL, + `affiliate_history` text, + `affiliate_assignee` INT(3) NOT NULL DEFAULT 0, + PRIMARY KEY (`affiliate_id`), + UNIQUE KEY `affiliate_code` (`affiliate_code`)"; + + + $result = $this->dbv->hasSyntaxIssue($file); + + + + var_export($result); }