fix terbaru

This commit is contained in:
Amal Udjir 2025-05-09 05:11:53 +07:00
commit 26f9e2ed8b
2 changed files with 60 additions and 53 deletions

View File

@ -1,6 +1,6 @@
APP_NAME=iCLOP APP_NAME=iCLOP
APP_ENV=local APP_ENV=local
APP_KEY= APP_KEY=base64:7PMb8dvpBWcRs5AMi3nEDHitF2MvqgC9QbOvCE5dvDo=
APP_DEBUG=true APP_DEBUG=true
APP_URL=http://localhost APP_URL=http://localhost
@ -11,10 +11,16 @@ LOG_LEVEL=debug
DB_CONNECTION=mysql DB_CONNECTION=mysql
DB_HOST=127.0.0.1 DB_HOST=127.0.0.1
DB_PORT=3306 DB_PORT=3306
DB_DATABASE=laravel DB_DATABASE=iclop
DB_USERNAME=root DB_USERNAME=root
DB_PASSWORD= DB_PASSWORD=
DB_HOST_SECOND=127.0.0.1
DB_PORT_SECOND=3306
DB_DATABASE_SECOND=test_db
DB_USERNAME_SECOND=root
DB_PASSWORD_SECOND=
NODEJS_DB_HOST=127.0.0.1 NODEJS_DB_HOST=127.0.0.1
NODEJS_DB_PORT=3306 NODEJS_DB_PORT=3306
NODEJS_DB_DATABASE=iclop_nodejs NODEJS_DB_DATABASE=iclop_nodejs

View File

@ -290,57 +290,59 @@ function unittesting(){
//echo "<pre>$pa</pre>"; //echo "<pre>$pa</pre>";
$sql = DB::select("SELECT * FROM php_testing_rule WHERE testing_name = '$testing_number_one'"); $sql = DB::select("SELECT * FROM php_testing_rule WHERE testing_name = '$testing_number_one'");
$row = $sql[0]; $row = $sql[0];
$html = $row->testing_rule; $html = $row->testing_rule;
$test = str_replace(array("\r\n","\r","\n"," "),"",$html); $test = str_replace(array("\r\n","\r","\n"," "),"",$html);
$result_test = htmlspecialchars($test); $result_test = htmlspecialchars($test);
$string = json_encode($output); $string = json_encode($output);
$text = str_replace("\n", ' ', $output); $text = str_replace("\n", ' ', $output);
$cleaned = preg_replace('/\e\[[;?\d]*m/', '', $string); $cleaned = preg_replace('/\e\[[;?\d]*m/', '', $string);
$pattern = '/Codeception PHP Testing Framework v([\d.]+)/'; // Pola regex untuk mengekstrak versi Codeception
$pattern = '/Codeception PHP Testing Framework v([\d.]+)/';
$pattern_phpunit_version = '/PHPUnit\s+([\d.]+)\s+by/'; // Define patterns to extract relevant information
$pattern_php_runtime = '/Runtime:\s+PHP\s+([\d.]+)/'; $pattern_phpunit_version = '/PHPUnit\s+([\d.]+)\s+by/';
$pattern_configuration = '/Configuration:\s+(.+)/'; $pattern_php_runtime = '/Runtime:\s+PHP\s+([\d.]+)/';
$pattern_failure_count = '/There was (\d+) failure/'; $pattern_configuration = '/Configuration:\s+(.+)/';
$pattern_failure_test_case = '/Failed asserting that \'(.*?)\' contains \'(.*?)\'./'; $pattern_failure_count = '/There was (\d+) failure/';
$pattern_failure_location = '/(C:\\\\.*?\\.php):(\d+)/'; $pattern_failure_test_case = '/Failed asserting that \'(.*?)\' contains \'(.*?)\'./';
$pattern_path = 'C:\\xampp\\htdocs\\iclop\\phpunit.xml'; $pattern_failure_location = '/(C:\\\\.*?\\.php):(\d+)/';
$pattern_time = '/Time:\s+([0-9:.]+)/'; $pattern_path = 'C:\\xampp\\htdocs\\iclop\\phpunit.xml';
$pattern_memory = '/Memory:\s+([\d.]+)\s+(MB|KB|GB)/'; $pattern_time = '/Time:\s+([0-9:.]+)/';
$pattern_ok = '/OK\s+\((\d+)\s+test(?:s)?,\s+(\d+)\s+assertion(?:s)?\)/'; $pattern_memory = '/Memory:\s+([\d.]+)\s+(MB|KB|GB)/';
$pattern_failures = '/Tests:\s+(\d+),\s+Assertions:\s+(\d+),\s+Failures:\s+(\d+)/'; $pattern_ok = '/OK\s+\((\d+)\s+test(?:s)?,\s+(\d+)\s+assertion(?:s)?\)/';
$pattern_failures = '/Tests:\s+(\d+),\s+Assertions:\s+(\d+),\s+Failures:\s+(\d+)/';
preg_match($pattern_phpunit_version, $text, $matches_phpunit_version); // Perform matching
preg_match($pattern_php_runtime, $text, $matches_php_runtime); preg_match($pattern_phpunit_version, $text, $matches_phpunit_version);
preg_match($pattern_configuration, $text, $matches_configuration); preg_match($pattern_php_runtime, $text, $matches_php_runtime);
preg_match($pattern_failure_count, $text, $matches_failure_count); preg_match($pattern_configuration, $text, $matches_configuration);
preg_match($pattern_failure_test_case, $text, $matches_failure_test_case); preg_match($pattern_failure_count, $text, $matches_failure_count);
preg_match($pattern_failure_location, $text, $matches_failure_location); preg_match($pattern_failure_test_case, $text, $matches_failure_test_case);
preg_match($pattern_ok, $text, $matches_ok); preg_match($pattern_failure_location, $text, $matches_failure_location);
preg_match($pattern_time, $text, $matches_time); preg_match($pattern_ok, $text, $matches_ok);
preg_match($pattern_memory, $text, $matches_memory); preg_match($pattern_time, $text, $matches_time);
preg_match($pattern_failures, $text, $matches_failures); preg_match($pattern_memory, $text, $matches_memory);
preg_match($pattern, $cleaned, $matches); preg_match($pattern_failures, $text, $matches_failures);
preg_match($pattern, $cleaned, $matches);
$phpunit_version = $matches_phpunit_version[1] ?? 'Not found'; // Extracted information
$phpunit_stat = isset($matches_ok[0]) ? $matches_ok[0] : "Not found"; $phpunit_version = $matches_phpunit_version[1] ?? 'Not found';
$phpunit_time = isset($matches_time[1]) ? $matches_time[1] : "Not found"; $phpunit_stat = isset($matches_ok[0]) ? $matches_ok[0] : "Not found";
$phpunit_memory = isset($matches_memory[0]) ? $matches_memory[0] : "Not found"; $phpunit_time = isset($matches_time[1]) ? $matches_time[1] : "Not found";
$php_runtime = isset($matches_php_runtime[1]) ? $matches_php_runtime[1] : "Not found"; $phpunit_memory = isset($matches_memory[0]) ? $matches_memory[0] : "Not found";
$configuration_path = isset($matches_configuration[1]) ? $matches_configuration[1] : "Not found"; $php_runtime = isset($matches_php_runtime[1]) ? $matches_php_runtime[1] : "Not found";
$num_failures = isset($matches_failure_count[1]) ? $matches_failure_count[1] : "Not found"; $configuration_path = isset($matches_configuration[1]) ? $matches_configuration[1] : "Not found";
$failed_assertion = isset($matches_failure_test_case[1]) ? htmlspecialchars($matches_failure_test_case[1]) : "Not found"; $num_failures = isset($matches_failure_count[1]) ? $matches_failure_count[1] : "Not found";
$expected_content = isset($matches_failure_test_case[2]) ? htmlspecialchars($matches_failure_test_case[2]) : "Not found"; $failed_assertion = isset($matches_failure_test_case[1]) ? htmlspecialchars($matches_failure_test_case[1]) : "Not found";
$failure_location = isset($matches_failure_location[1]) ? $matches_failure_location[1] : "Not found"; $expected_content = isset($matches_failure_test_case[2]) ? htmlspecialchars($matches_failure_test_case[2]) : "Not found";
$failure_line = isset($matches_failure_location[2]) ? $matches_failure_location[2] : "Not found"; $failure_location = isset($matches_failure_location[1]) ? $matches_failure_location[1] : "Not found";
if (!empty($matches_failures)) { $failure_line = isset($matches_failure_location[2]) ? $matches_failure_location[2] : "Not found";
$tests_assertions_failures = "FAILURES!<br /> Tests: " . $matches_failures[1] . ", Assertions: " . $matches_failures[2] . ", Failures: " . $matches_failures[3]; if (!empty($matches_failures)) {
} $tests_assertions_failures = "FAILURES!<br /> Tests: " . $matches_failures[1] . ", Assertions: " . $matches_failures[2] . ", Failures: " . $matches_failures[3];
}
if($num_failures == 1){ if($num_failures == 1){
$username = Session::get('user_name'); $username = Session::get('user_name');
@ -364,11 +366,10 @@ function unittesting(){
$diff_err = ""; $diff_err = "";
// Memecah string HTML menjadi array per baris // Memecah string HTML menjadi array per baris
$html1_lines = explode("\n", $html1); $html1_lines = explode("\n", $html1);
$html2_lines = explode("\n", $html2); $html2_lines = explode("\n", $html2);
$result_content = str_replace(array("\r\n","\r"," "),"", $html1_lines); $result_content = str_replace(array("\r\n","\r"," "),"", $html1_lines);
$result_content2 = str_replace(array("\r\n","\r"," "),"", $html2_lines); $result_content2 = str_replace(array("\r\n","\r"," "),"", $html2_lines);
// Membandingkan setiap baris // Membandingkan setiap baris
for ($i = 0; $i < count($result_content) && $i < count($result_content2); $i++) { for ($i = 0; $i < count($result_content) && $i < count($result_content2); $i++) {
if ($result_content[$i] != $result_content2[$i]) { if ($result_content[$i] != $result_content2[$i]) {