Skip to content

Commit

Permalink
Add tests for input message content
Browse files Browse the repository at this point in the history
  • Loading branch information
punyflash committed Sep 4, 2020
1 parent f2c135a commit 1fc15ea
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
2 changes: 2 additions & 0 deletions tests/Feature/HandleUpdatesTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public function testHandleUpdates()
echo $update;
}]);

// Please don't specify offset so I don't need to resend messages to my bot
$updates = $this->bot->getUpdates();

foreach ($updates as $update)
Expand Down Expand Up @@ -61,5 +62,6 @@ public function testGetBotCommand()
{
$commands = StartCommandHandler::getBotCommand();
$this->assertContainsOnlyInstancesOf(BotCommand::class, $commands);
$this->assertCount(2, $commands);
}
}
42 changes: 42 additions & 0 deletions tests/Unit/InputMessageContentTest.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
<?php

namespace WeStacks\TeleBot\Tests\Unit;

use PHPUnit\Framework\TestCase;
use WeStacks\TeleBot\Exception\TeleBotObjectException;
use WeStacks\TeleBot\Objects\InputMessageContent;
use WeStacks\TeleBot\Objects\InputMessageContent\InputContactMessageContent;
use WeStacks\TeleBot\Objects\InputMessageContent\InputLocationMessageContent;
use WeStacks\TeleBot\Objects\InputMessageContent\InputTextMessageContent;
use WeStacks\TeleBot\Objects\InputMessageContent\InputVenueMessageContent;

class InputMessageContentTest extends TestCase
{
public function testInputMessageContent()
{
$object = InputMessageContent::create(['message_text' => 'Test']);
$this->assertInstanceOf(InputTextMessageContent::class, $object);

$object = InputMessageContent::create([
'address' => 'Test',
'latitude' => 23.043235
]);
$this->assertInstanceOf(InputVenueMessageContent::class, $object);

$object = InputMessageContent::create([
'latitude' => 23.043235
]);
$this->assertInstanceOf(InputLocationMessageContent::class, $object);

$object = InputMessageContent::create([
'phone_number' => '+380111111111'
]);
$this->assertInstanceOf(InputContactMessageContent::class, $object);
}

public function testWrongInputMessageContent()
{
$this->expectException(TeleBotObjectException::class);
InputMessageContent::create(['something_wrong' => 'some_wrong_type']);
}
}

0 comments on commit 1fc15ea

Please sign in to comment.