mirror of
https://github.com/danog/tgbot-dialog-id.git
synced 2024-11-30 07:39:01 +01:00
40 lines
1.4 KiB
PHP
40 lines
1.4 KiB
PHP
<?php declare(strict_types=1);
|
|
|
|
namespace danog\TestDialogId;
|
|
|
|
use AssertionError;
|
|
use danog\DialogId\DialogType;
|
|
use PHPUnit\Framework\TestCase;
|
|
|
|
final class DialogIdTest extends TestCase
|
|
{
|
|
public function testAll(): void
|
|
{
|
|
$this->assertSame(DialogType::USER, DialogType::from(101374607));
|
|
$this->assertSame(DialogType::CHAT, DialogType::from(-101374607));
|
|
$this->assertSame(DialogType::CHANNEL_OR_SUPERGROUP, DialogType::from(-1001234567890));
|
|
$this->assertSame(DialogType::SECRET_CHAT, DialogType::from(-1999898625393));
|
|
|
|
$this->assertTrue(DialogType::isUser(1099511627775));
|
|
$this->assertTrue(DialogType::isChat(-999_999_999_999));
|
|
$this->assertTrue(DialogType::isSupergroupOrChannel(-1997852516352));
|
|
$this->assertTrue(DialogType::isSecretChat(-2002147483648));
|
|
|
|
$this->assertTrue(DialogType::isUser(101374607));
|
|
$this->assertTrue(DialogType::isChat(-101374607));
|
|
$this->assertTrue(DialogType::isSupergroupOrChannel(-1001234567890));
|
|
$this->assertTrue(DialogType::isSecretChat(-1999898625393));
|
|
}
|
|
|
|
public function testException1(): void
|
|
{
|
|
$this->expectException(AssertionError::class);
|
|
$this->assertTrue(DialogType::isSecretChat(-2999898625393));
|
|
}
|
|
public function testException2(): void
|
|
{
|
|
$this->expectException(AssertionError::class);
|
|
$this->assertTrue(DialogType::from(0));
|
|
}
|
|
}
|