tgbot-dialog-id/test/DialogIdTest.php

40 lines
1.4 KiB
PHP
Raw Normal View History

2024-05-09 23:46:12 +02:00
<?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));
}
}