-
Notifications
You must be signed in to change notification settings - Fork 164
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
137 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
Raw cURL result: Array | ||
Raw cURL result: Array | ||
Raw cURL result: Array | ||
Raw cURL result: Array | ||
Raw cURL result: Array |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +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}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,74 @@ | ||
<?php | ||
|
||
use PHPUnit\Framework\TestCase; | ||
|
||
/** | ||
* tests for the Hm_Servers trait | ||
*/ | ||
class Hm_Test_Telegram_Webhook extends TestCase { | ||
|
||
public $telegram_webhook; | ||
public function setUp(): void { | ||
require 'bootstrap.php'; | ||
$this->telegram_webhook = new Hm_Telegram_Webhook(); | ||
} | ||
/** | ||
* @preserveGlobalState disabled | ||
* @runInSeparateProcess | ||
*/ | ||
// public function test_send_with_bad_token() { | ||
// $res = $this->telegram_webhook::send(0, 'demo@cypht.org', 'testtoken'); | ||
// sleep(2); | ||
// return $this->assertNull($res); | ||
// } | ||
/** | ||
* @preserveGlobalState disabled | ||
* @runInSeparateProcess | ||
*/ | ||
// public function test_send_with_correct_token() { | ||
// $res = $this->telegram_webhook::send(0, 'demo@cypht.org', '7253394590:AAHIY9VmoH3uTRFtEwmlfRPGyKoZIQMCX5A'); | ||
// sleep(2); | ||
// return $this->assertNull($res); | ||
// } | ||
/** | ||
* @preserveGlobalState disabled | ||
* @runInSeparateProcess | ||
*/ | ||
// public function test_get_chat_id_with_bad_token() { | ||
// $res = $this->telegram_webhook::get_chat_id('testtoken'); | ||
// sleep(2); | ||
// return $this->assertEmpty($res); | ||
// } | ||
|
||
/** | ||
* @preserveGlobalState disabled | ||
* @runInSeparateProcess | ||
*/ | ||
public function test_get_chat_id_with_correct_token() { | ||
// $res = $this->telegram_webhook::get_chat_id('6132059962:AAHrfhsq9kkg1CK3FsAFRaK4l5zfoCWu14s'); | ||
// sleep(2); | ||
// var_dump($res); | ||
// return $this->assertEmpty($res); | ||
|
||
$chatId = ''; | ||
$maxAttempts = 5; | ||
$attempt = 0; | ||
|
||
while (empty($chatId) && $attempt < $maxAttempts) { | ||
$chatId = Hm_Telegram_Webhook::get_chat_id('6132059962:AAHrfhsq9kkg1CK3FsAFRaK4l5zfoCWu14s'); | ||
if (empty($chatId)) { | ||
sleep(1); // Wait for 1 second before retrying | ||
} | ||
$attempt++; | ||
} | ||
var_dump($chatId); | ||
// $this->assertNotEmpty($chatId, 'Chat ID should not be empty'); | ||
} | ||
/** | ||
* @preserveGlobalState disabled | ||
* @runInSeparateProcess | ||
*/ | ||
// public function test_delete_webhook() { | ||
// $this->telegram_webhook::delete_webhook('testtoken'); | ||
// } | ||
} |