Skip to content

Commit c9bf84a

Browse files
committed
Correct phpunit tests
1 parent 8ce1ea4 commit c9bf84a

File tree

5 files changed

+4
-115
lines changed

5 files changed

+4
-115
lines changed

lib/telegram_webhook.php

Lines changed: 1 addition & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ public static function send($msg_count, $email_to, $webhook_token) {
2020
self::delete_webhook($webhook_token);
2121
// Get the chat ID
2222
$chatId = self::get_chat_id($webhook_token);
23-
// var_dump($chatId);
24-
// print_r('chatId response: ');
25-
// print_r($chatId);
2623
if (!empty($chatId)) {
2724
$text = "You have received: $msg_count unread email.s\nTo: $email_to";
2825
$curl_handle = Hm_Functions::c_init();
@@ -61,9 +58,7 @@ public static function get_chat_id($webhook_token) {
6158

6259
curl_close($ch);
6360
if (trim($curl_result)) {
64-
$response_data = json_decode($curl_result, true);
65-
file_put_contents('./debug.log', 'Raw cURL result: ' . $response_data['result'] . "\n", FILE_APPEND);
66-
61+
$response_data = json_decode($curl_result, true);
6762
// Log the decoded response data for debugging
6863
if (isset($response_data['result'][0]['message']['chat']['id']) && !empty($response_data['result'][0]['message']['chat']['id'])) {
6964
$chatId = $response_data['result'][0]['message']['chat']['id'];
@@ -73,35 +68,6 @@ public static function get_chat_id($webhook_token) {
7368
return '';
7469
}
7570
}
76-
77-
78-
79-
80-
81-
// $curl_handle = Hm_Functions::c_init();
82-
// Hm_Functions::c_setopt($curl_handle, CURLOPT_URL, static::PREFIX_URI . 'bot' . $webhook_token . '/getUpdates');
83-
// Hm_Functions::c_setopt($curl_handle, CURLOPT_RETURNTRANSFER, true);
84-
// $curl_result = Hm_Functions::c_exec($curl_handle);
85-
// file_put_contents('./debug.log', 'Raw cURL result: ' . $curl_result . "\n", FILE_APPEND);
86-
87-
// if ($curl_result === false) {
88-
// // Hm_Msgs::add('cURL Error: ' . Hm_Functions::c_error($curl_handle) . '<br>');
89-
// // Hm_Functions::c_close($curl_handle);
90-
// return '';
91-
// }
92-
93-
// // Hm_Functions::c_close($curl_handle);
94-
95-
// if (trim($curl_result)) {
96-
// $response_data = json_decode($curl_result, true);
97-
// if (isset($response_data['result'][0]['message']['chat']['id']) && !empty($response_data['result'][0]['message']['chat']['id'])) {
98-
// $chatId = $response_data['result'][0]['message']['chat']['id'];
99-
// return $chatId;
100-
// } else {
101-
// Hm_Msgs::add('ERRNo messages found. Please send a message to your bot first.<br>');
102-
// return '';
103-
// }
104-
// }
10571
}
10672

10773
/**
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
{"version":1,"defects":{"Hm_Test_Telegram_Webhook::test_send":8,"Hm_Test_Telegram_Webhook::test_get_chat_id":5,"Hm_Test_Telegram_Webhook::test_delete_webhook":5,"Hm_Test_Telegram_Webhook::test_send_with_correct_token":8,"Hm_Test_Telegram_Webhook::test_send_with_bad_token":8,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_bad_token":8,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_correct_token":8},"times":{"Hm_Test_Telegram_Webhook::test_get_chat_id":0.001,"Hm_Test_Telegram_Webhook::test_delete_webhook":0.002,"Hm_Test_Telegram_Webhook::test_send":0.004,"Hm_Test_Telegram_Webhook::test_send_with_bad_token":2.015,"Hm_Test_Telegram_Webhook::test_send_with_correct_token":2.014,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_bad_token":2.013,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_correct_token":0.885}}
1+
{"version":1,"defects":{"Hm_Test_Telegram_Webhook::test_send":8,"Hm_Test_Telegram_Webhook::test_get_chat_id":5,"Hm_Test_Telegram_Webhook::test_delete_webhook":5,"Hm_Test_Telegram_Webhook::test_send_with_correct_token":8,"Hm_Test_Telegram_Webhook::test_send_with_bad_token":8,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_bad_token":8,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_correct_token":7},"times":{"Hm_Test_Telegram_Webhook::test_get_chat_id":0.001,"Hm_Test_Telegram_Webhook::test_delete_webhook":0.002,"Hm_Test_Telegram_Webhook::test_send":0.004,"Hm_Test_Telegram_Webhook::test_send_with_bad_token":2.015,"Hm_Test_Telegram_Webhook::test_send_with_correct_token":2.014,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_bad_token":2.013,"Hm_Test_Telegram_Webhook::test_get_chat_id_with_correct_token":0.599}}

tests/phpunit/modules/core/output_modules.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,10 +444,10 @@ public function test_js_data() {
444444
$test = new Output_Test('js_data', 'core');
445445
$test->handler_response = array('disable_delete_prompt' => true);
446446
$res = $test->run();
447-
$this->assertStringStartsWith('<script type="text/javascript">var globals = {};var hm_is_logged = function () { return 0; };var hm_empty_folder = function() { return "So alone"; };var hm_mobile = function() { return 0; };var hm_debug = function() { return "0"; };var hm_mailto = function() { return 0; };var hm_page_name = function() { return ""; };var hm_language_direction = function() { return "ltr"; };var hm_list_path = function() { return ""; };var hm_list_parent = function() { return ""; };var hm_msg_uid = function() { return Hm_Utils.get_from_global("msg_uid", ""); };var hm_encrypt_ajax_requests = function() { return ""; };var hm_encrypt_local_storage = function() { return ""; };var hm_web_root_path = function() { return ""; };var hm_flag_image_src = function() { return "<i class=\\"bi bi-star-half\\"></i>"; };var hm_check_dirty_flag = function() { return 0; };var hm_data_sources = function() { return []; };var hm_delete_prompt = function() { return true; };', implode($res->output_response));
447+
$this->assertStringStartsWith('<script type="text/javascript">var globals = {};var hm_is_logged = function () { return 0; };var hm_empty_folder = function() { return "So alone"; };var hm_mobile = function() { return 0; };var hm_debug = function() { return "0"; };var hm_mailto = function() { return 0; };var hm_page_name = function() { return ""; };var hm_language_direction = function() { return "ltr"; };var hm_list_path = function() { return ""; };var hm_list_parent = function() { return ""; };var hm_msg_uid = function() { return Hm_Utils.get_from_global("msg_uid", ""); };var hm_encrypt_ajax_requests = function() { return ""; };var hm_encrypt_local_storage = function() { return ""; };var hm_web_root_path = function() { return ""; };var hm_flag_image_src = function() { return "<i class=\"bi bi-star-half\"></i>"; };var hm_check_dirty_flag = function() { return 0; };var hm_telegram_webhook_interval = function() { return ; };var hm_data_sources = function() { return []; };var hm_delete_prompt = function() { return true; };', implode($res->output_response));
448448
$test->handler_response = array();
449449
$res = $test->run();
450-
$this->assertStringStartsWith('<script type="text/javascript">var globals = {};var hm_is_logged = function () { return 0; };var hm_empty_folder = function() { return "So alone"; };var hm_mobile = function() { return 0; };var hm_debug = function() { return "0"; };var hm_mailto = function() { return 0; };var hm_page_name = function() { return ""; };var hm_language_direction = function() { return "ltr"; };var hm_list_path = function() { return ""; };var hm_list_parent = function() { return ""; };var hm_msg_uid = function() { return Hm_Utils.get_from_global("msg_uid", ""); };var hm_encrypt_ajax_requests = function() { return ""; };var hm_encrypt_local_storage = function() { return ""; };var hm_web_root_path = function() { return ""; };var hm_flag_image_src = function() { return "<i class=\\"bi bi-star-half\\"></i>"; };var hm_check_dirty_flag = function() { return 0; };var hm_data_sources = function() { return []; };var hm_delete_prompt = function() { return confirm("Are you sure?"); };', implode($res->output_response));
450+
$this->assertStringStartsWith('<script type="text/javascript">var globals = {};var hm_is_logged = function () { return 0; };var hm_empty_folder = function() { return "So alone"; };var hm_mobile = function() { return 0; };var hm_debug = function() { return "0"; };var hm_mailto = function() { return 0; };var hm_page_name = function() { return ""; };var hm_language_direction = function() { return "ltr"; };var hm_list_path = function() { return ""; };var hm_list_parent = function() { return ""; };var hm_msg_uid = function() { return Hm_Utils.get_from_global("msg_uid", ""); };var hm_encrypt_ajax_requests = function() { return ""; };var hm_encrypt_local_storage = function() { return ""; };var hm_web_root_path = function() { return ""; };var hm_flag_image_src = function() { return "<i class=\"bi bi-star-half\"></i>"; };var hm_check_dirty_flag = function() { return 0; };var hm_telegram_webhook_interval = function() { return ; };var hm_data_sources = function() { return []; };var hm_delete_prompt = function() { return confirm("Are you sure?"); };', implode($res->output_response));
451451
}
452452
/**
453453
* @preserveGlobalState disabled

tests/phpunit/phpunit.xml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,6 @@
6464
<testsuite name="transform">
6565
<file>./transform.php</file>
6666
</testsuite>
67-
<testsuite name="webhook">
68-
<file>./telegram_webhook.php</file>
69-
</testsuite>
7067
<testsuite name="auth">
7168
<file>./auth.php</file>
7269
</testsuite>

tests/phpunit/telegram_webhook.php

Lines changed: 0 additions & 74 deletions
This file was deleted.

0 commit comments

Comments
 (0)