From 2eee413986b93f63c1f681a7f2332f8427d55cf9 Mon Sep 17 00:00:00 2001 From: Camilo Sperberg Date: Sun, 25 Jun 2017 18:59:04 +0200 Subject: [PATCH] Bot may be able to unset the webhook now, fixes #36 --- src/Telegram/Methods/SetWebhook.php | 2 +- tests/Mock/MockData/SetWebhook-unset.json | 1 + tests/Telegram/Methods/SetWebhookTest.php | 14 ++++++++++++++ 3 files changed, 16 insertions(+), 1 deletion(-) create mode 100644 tests/Mock/MockData/SetWebhook-unset.json diff --git a/src/Telegram/Methods/SetWebhook.php b/src/Telegram/Methods/SetWebhook.php index fa2781f..ca56537 100644 --- a/src/Telegram/Methods/SetWebhook.php +++ b/src/Telegram/Methods/SetWebhook.php @@ -37,7 +37,7 @@ class SetWebhook extends TelegramMethods * Optional. HTTPS url to send updates to. Use an empty string to remove webhook integration * @var string */ - public $url = ''; + public $url; /** * Optional. Upload your public key certificate so that the root certificate in use can be checked. See our diff --git a/tests/Mock/MockData/SetWebhook-unset.json b/tests/Mock/MockData/SetWebhook-unset.json new file mode 100644 index 0000000..cbf7b42 --- /dev/null +++ b/tests/Mock/MockData/SetWebhook-unset.json @@ -0,0 +1 @@ +{"ok":true,"result":true,"description":"Webhook was deleted"} diff --git a/tests/Telegram/Methods/SetWebhookTest.php b/tests/Telegram/Methods/SetWebhookTest.php index 7d81fdc..f97d41b 100644 --- a/tests/Telegram/Methods/SetWebhookTest.php +++ b/tests/Telegram/Methods/SetWebhookTest.php @@ -53,4 +53,18 @@ public function testSetWebhook() $this->assertInstanceOf(ResultBoolean::class, $result); $this->assertTrue($result->data); } + + public function testUnsetWebhook() + { + $this->tgLog->specificTest = 'unset'; + + $setWebhook = new SetWebhook(); + $setWebhook->url = ''; + + /** @var ResultBoolean $result */ + $result = $this->tgLog->performApiRequest($setWebhook); + + $this->assertInstanceOf(ResultBoolean::class, $result); + $this->assertTrue($result->data); + } }