From 606e0c4e6482fe21fc604a86c0f5dbc1876fff8c Mon Sep 17 00:00:00 2001 From: Steven Ngesera Date: Mon, 15 Jul 2024 00:12:13 +0300 Subject: [PATCH] Correct phpunit tests --- lib/telegram_webhook.php | 36 +------------------ tests/phpunit/modules/core/output_modules.php | 2 +- 2 files changed, 2 insertions(+), 36 deletions(-) diff --git a/lib/telegram_webhook.php b/lib/telegram_webhook.php index 98ed39aad1..312a299258 100644 --- a/lib/telegram_webhook.php +++ b/lib/telegram_webhook.php @@ -20,9 +20,6 @@ public static function send($msg_count, $email_to, $webhook_token) { self::delete_webhook($webhook_token); // Get the chat ID $chatId = self::get_chat_id($webhook_token); - // var_dump($chatId); - // print_r('chatId response: '); - // print_r($chatId); if (!empty($chatId)) { $text = "You have received: $msg_count unread email.s\nTo: $email_to"; $curl_handle = Hm_Functions::c_init(); @@ -61,9 +58,7 @@ public static function get_chat_id($webhook_token) { curl_close($ch); if (trim($curl_result)) { - $response_data = json_decode($curl_result, true); - file_put_contents('./debug.log', 'Raw cURL result: ' . $response_data['result'] . "\n", FILE_APPEND); - + $response_data = json_decode($curl_result, true); // Log the decoded response data for debugging if (isset($response_data['result'][0]['message']['chat']['id']) && !empty($response_data['result'][0]['message']['chat']['id'])) { $chatId = $response_data['result'][0]['message']['chat']['id']; @@ -73,35 +68,6 @@ public static function get_chat_id($webhook_token) { return ''; } } - - - - - - // $curl_handle = Hm_Functions::c_init(); - // Hm_Functions::c_setopt($curl_handle, CURLOPT_URL, static::PREFIX_URI . 'bot' . $webhook_token . '/getUpdates'); - // Hm_Functions::c_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true); - // $curl_result = Hm_Functions::c_exec($curl_handle); - // file_put_contents('./debug.log', 'Raw cURL result: ' . $curl_result . "\n", FILE_APPEND); - - // if ($curl_result === false) { - // // Hm_Msgs::add('cURL Error: ' . Hm_Functions::c_error($curl_handle) . '
'); - // // Hm_Functions::c_close($curl_handle); - // return ''; - // } - - // // Hm_Functions::c_close($curl_handle); - - // if (trim($curl_result)) { - // $response_data = json_decode($curl_result, true); - // if (isset($response_data['result'][0]['message']['chat']['id']) && !empty($response_data['result'][0]['message']['chat']['id'])) { - // $chatId = $response_data['result'][0]['message']['chat']['id']; - // return $chatId; - // } else { - // Hm_Msgs::add('ERRNo messages found. Please send a message to your bot first.
'); - // return ''; - // } - // } } /** diff --git a/tests/phpunit/modules/core/output_modules.php b/tests/phpunit/modules/core/output_modules.php index 71d404263e..b7bbdc7a47 100644 --- a/tests/phpunit/modules/core/output_modules.php +++ b/tests/phpunit/modules/core/output_modules.php @@ -444,7 +444,7 @@ public function test_js_data() { $test = new Output_Test('js_data', 'core'); $test->handler_response = array('disable_delete_prompt' => true); $res = $test->run(); - $this->assertStringStartsWith('