Skip to content

Commit

Permalink
Correct phpunit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
Shadow243 committed Jul 14, 2024
1 parent 8ce1ea4 commit 3d92d40
Show file tree
Hide file tree
Showing 6 changed files with 3 additions and 120 deletions.
5 changes: 0 additions & 5 deletions debug.log

This file was deleted.

36 changes: 1 addition & 35 deletions lib/telegram_webhook.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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'];
Expand All @@ -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) . '<br>');
// // 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.<br>');
// return '';
// }
// }
}

/**
Expand Down
1 change: 0 additions & 1 deletion tests/phpunit/.phpunit.cache/test-results

This file was deleted.

4 changes: 2 additions & 2 deletions tests/phpunit/modules/core/output_modules.php
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ 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('<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));
$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));
$test->handler_response = array();
$res = $test->run();
$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));
$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));
}
/**
* @preserveGlobalState disabled
Expand Down
3 changes: 0 additions & 3 deletions tests/phpunit/phpunit.xml
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@
<testsuite name="transform">
<file>./transform.php</file>
</testsuite>
<testsuite name="webhook">
<file>./telegram_webhook.php</file>
</testsuite>
<testsuite name="auth">
<file>./auth.php</file>
</testsuite>
Expand Down
74 changes: 0 additions & 74 deletions tests/phpunit/telegram_webhook.php

This file was deleted.

0 comments on commit 3d92d40

Please sign in to comment.