1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Created by PhpStorm. |
4
|
|
|
* Team: jungle |
5
|
|
|
* User: Roma Baranenko |
6
|
|
|
* Contacts: <[email protected]> |
7
|
|
|
* Date: 05.12.17 |
8
|
|
|
* Time: 18:50 |
9
|
|
|
*/ |
10
|
|
|
|
11
|
|
|
namespace TelegramBotAPI\Tests\Types; |
12
|
|
|
|
13
|
|
|
|
14
|
|
|
use TelegramBotAPI\Types\User; |
15
|
|
|
use TelegramBotAPI\Types\Chat; |
16
|
|
|
use TelegramBotAPI\Types\Game; |
17
|
|
|
use TelegramBotAPI\Types\Audio; |
18
|
|
|
use PHPUnit\Framework\TestCase; |
19
|
|
|
use TelegramBotAPI\Types\Venue; |
20
|
|
|
use TelegramBotAPI\Types\Video; |
21
|
|
|
use TelegramBotAPI\Types\Voice; |
22
|
|
|
use TelegramBotAPI\Types\Contact; |
23
|
|
|
use TelegramBotAPI\Types\Invoice; |
24
|
|
|
use TelegramBotAPI\Types\Message; |
25
|
|
|
use TelegramBotAPI\Types\Sticker; |
26
|
|
|
use TelegramBotAPI\Types\Document; |
27
|
|
|
use TelegramBotAPI\Types\Location; |
28
|
|
|
use TelegramBotAPI\Types\VideoNote; |
29
|
|
|
use TelegramBotAPI\Types\SuccessfulPayment; |
30
|
|
|
|
31
|
|
|
/** |
32
|
|
|
* Class MessageTest |
33
|
|
|
* @package TelegramBotAPI\Tests\Types |
34
|
|
|
* @author Roma Baranenko <[email protected]> |
35
|
|
|
*/ |
36
|
|
|
class MessageTest extends TestCase { |
37
|
|
|
|
38
|
|
|
public function testAccessors() { |
39
|
|
|
|
40
|
|
|
$obj = new Message(); |
41
|
|
|
|
42
|
|
|
$obj->setMessageId(123456); |
43
|
|
|
$obj->setFrom(new User()); |
44
|
|
|
$obj->setDate(654321); |
45
|
|
|
$obj->setChat(new Chat()); |
46
|
|
|
$obj->setForwardFrom(new User()); |
47
|
|
|
$obj->setForwardFromChat(new Chat()); |
48
|
|
|
$obj->setForwardFromMessageId(1); |
49
|
|
|
$obj->setForwardDate(765432); |
50
|
|
|
$obj->setReplyToMessage(new Message()); |
51
|
|
|
$obj->setEditDate(876543); |
52
|
|
|
$obj->setText('text'); |
53
|
|
|
$obj->setEntities(array()); |
54
|
|
|
$obj->setAudio(new Audio()); |
55
|
|
|
$obj->setDocument(new Document()); |
56
|
|
|
$obj->setGame(new Game()); |
57
|
|
|
$obj->setPhoto(array()); |
58
|
|
|
$obj->setSticker(new Sticker()); |
59
|
|
|
$obj->setVideo(new Video()); |
60
|
|
|
$obj->setVideoNote(new VideoNote()); |
61
|
|
|
$obj->setNewChatMembers(array()); |
62
|
|
|
$obj->setVoice(new Voice()); |
63
|
|
|
$obj->setCaption('caption'); |
64
|
|
|
$obj->setContact(new Contact()); |
65
|
|
|
$obj->setLocation(new Location()); |
66
|
|
|
$obj->setVenue(new Venue()); |
67
|
|
|
$obj->setLeftChatMember(new User()); |
68
|
|
|
$obj->setNewChatTitle('new chat title'); |
69
|
|
|
$obj->setNewChatPhoto(array()); |
70
|
|
|
$obj->setDeleteChatPhoto(true); |
71
|
|
|
$obj->setGroupChatCreated(true); |
72
|
|
|
$obj->setSupergroupChatCreated(true); |
73
|
|
|
$obj->setChannelChatCreated(true); |
74
|
|
|
$obj->setMigrateToChatId(1); |
75
|
|
|
$obj->setMigrateFromChatId(2); |
76
|
|
|
$obj->setPinnedMessage(new Message()); |
77
|
|
|
$obj->setInvoice(new Invoice()); |
78
|
|
|
$obj->setSuccessfulPayment(new SuccessfulPayment()); |
79
|
|
|
$obj->setAuthorSignature('author_signature'); |
80
|
|
|
$obj->setForwardSignature('forward_signature'); |
81
|
|
|
$obj->setCaptionEntities(array()); |
82
|
|
|
|
83
|
|
|
$this->assertEquals(123456, $obj->getMessageId()); |
84
|
|
|
$this->assertInstanceOf(User::class, $obj->getFrom()); |
85
|
|
|
$this->assertEquals(654321, $obj->getDate()); |
86
|
|
|
$this->assertInstanceOf(Chat::class, $obj->getChat()); |
87
|
|
|
$this->assertInstanceOf(User::class, $obj->getForwardFrom()); |
88
|
|
|
$this->assertInstanceOf(Chat::class, $obj->getForwardFromChat()); |
89
|
|
|
$this->assertEquals(1, $obj->getForwardFromMessageId()); |
90
|
|
|
$this->assertEquals(765432, $obj->getForwardDate()); |
91
|
|
|
$this->assertInstanceOf(Message::class, $obj->getReplyToMessage()); |
92
|
|
|
$this->assertEquals(876543, $obj->getEditDate()); |
93
|
|
|
$this->assertEquals('text', $obj->getText()); |
94
|
|
|
$this->assertInstanceOf(Audio::class, $obj->getAudio()); |
95
|
|
|
$this->assertInstanceOf(Document::class, $obj->getDocument()); |
96
|
|
|
$this->assertInstanceOf(Game::class, $obj->getGame()); |
97
|
|
|
$this->assertInstanceOf(Sticker::class, $obj->getSticker()); |
98
|
|
|
$this->assertInstanceOf(Video::class, $obj->getVideo()); |
99
|
|
|
$this->assertInstanceOf(VideoNote::class, $obj->getVideoNote()); |
100
|
|
|
$this->assertEquals('array', gettype($obj->getNewChatMembers())); |
101
|
|
|
$this->assertInstanceOf(Voice::class, $obj->getVoice()); |
102
|
|
|
$this->assertEquals('caption', $obj->getCaption()); |
103
|
|
|
$this->assertInstanceOf(Contact::class, $obj->getContact()); |
104
|
|
|
$this->assertInstanceOf(Location::class, $obj->getLocation()); |
105
|
|
|
$this->assertInstanceOf(Venue::class, $obj->getVenue()); |
106
|
|
|
$this->assertInstanceOf(User::class, $obj->getLeftChatMember()); |
107
|
|
|
$this->assertEquals('new chat title', $obj->getNewChatTitle()); |
108
|
|
|
$this->assertEquals('array', gettype($obj->getNewChatPhoto())); |
109
|
|
|
$this->assertTrue($obj->isDeleteChatPhoto()); |
110
|
|
|
$this->assertTrue($obj->isGroupChatCreated()); |
111
|
|
|
$this->assertTrue($obj->isSupergroupChatCreated()); |
112
|
|
|
$this->assertTrue($obj->isChannelChatCreated()); |
113
|
|
|
$this->assertEquals(1, $obj->getMigrateToChatId()); |
114
|
|
|
$this->assertEquals(2, $obj->getMigrateFromChatId()); |
115
|
|
|
$this->assertInstanceOf(Message::class, $obj->getPinnedMessage()); |
116
|
|
|
$this->assertInstanceOf(Invoice::class, $obj->getInvoice()); |
117
|
|
|
$this->assertInstanceOf(SuccessfulPayment::class, $obj->getSuccessfulPayment()); |
118
|
|
|
$this->assertEquals('author_signature', $obj->getAuthorSignature()); |
119
|
|
|
$this->assertEquals('forward_signature', $obj->getForwardSignature()); |
120
|
|
|
$this->assertEquals('array', gettype($obj->getCaptionEntities())); |
121
|
|
|
|
122
|
|
|
$this->assertJson(json_encode($obj)); |
123
|
|
|
} |
124
|
|
|
} |
125
|
|
|
|