forked from TelegramBot/Api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDocumentTest.php
More file actions
149 lines (133 loc) · 4.19 KB
/
DocumentTest.php
File metadata and controls
149 lines (133 loc) · 4.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
<?php
namespace TelegramBot\Api\Test;
use TelegramBot\Api\Types\Document;
use TelegramBot\Api\Types\PhotoSize;
class DocumentTest extends \PHPUnit_Framework_TestCase
{
public function testSetFileId()
{
$item = new Document();
$item->setFileId('testfileId');
$this->assertAttributeEquals('testfileId', 'fileId', $item);
}
public function testGetFileId()
{
$item = new Document();
$item->setFileId('testfileId');
$this->assertEquals('testfileId', $item->getFileId());
}
public function testSetThumb()
{
$item = new Document();
$thumb = PhotoSize::fromResponse(array(
"file_id" => 'testFileId1',
'width' => 1,
'height' => 2,
'file_size' => 3
));
$item->setThumb($thumb);
$this->assertAttributeEquals($thumb, 'thumb', $item);
}
public function testGetThumb()
{
$item = new Document();
$thumb = PhotoSize::fromResponse(array(
"file_id" => 'testFileId1',
'width' => 1,
'height' => 2,
'file_size' => 3
));
$item->setThumb($thumb);
$this->assertEquals($thumb, $item->getThumb());
$this->assertInstanceOf('\TelegramBot\Api\Types\PhotoSize', $item->getThumb());
}
public function testSetFileName()
{
$item = new Document();
$item->setFileName('testfileName');
$this->assertAttributeEquals('testfileName', 'fileName', $item);
}
public function testGetFileName()
{
$item = new Document();
$item->setFileName('testfileName');
$this->assertEquals('testfileName', $item->getFileName());
}
public function testSetFileSize()
{
$item = new Document();
$item->setFileSize(5);
$this->assertAttributeEquals(5, 'fileSize', $item);
}
public function testGetFileSize()
{
$item = new Document();
$item->setFileSize(6);
$this->assertEquals(6, $item->getFileSize());
}
public function testSetMimeType()
{
$item = new Document();
$item->setMimeType('audio/mp3');
$this->assertAttributeEquals('audio/mp3', 'mimeType', $item);
}
public function testGetMimeType()
{
$item = new Document();
$item->setMimeType('audio/mp3');
$this->assertEquals('audio/mp3', $item->getMimeType());
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetFileSizeException()
{
$item = new Document();
$item->setFileSize('s');
}
public function testFromResponse()
{
$item = Document::fromResponse(array(
'file_id' => 'testFileId1',
'file_name' => 'testFileName',
'mime_type' => 'audio/mp3',
'file_size' => 3,
'thumb' => array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
)
));
$thumb = PhotoSize::fromResponse(array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
));
$this->assertInstanceOf('\TelegramBot\Api\Types\Document', $item);
$this->assertAttributeEquals('testFileId1', 'fileId', $item);
$this->assertAttributeEquals('testFileName', 'fileName', $item);
$this->assertAttributeEquals('audio/mp3', 'mimeType', $item);
$this->assertAttributeEquals(3, 'fileSize', $item);
$this->assertAttributeEquals($thumb, 'thumb', $item);
$this->assertInstanceOf('\TelegramBot\Api\Types\PhotoSize', $item->getThumb());
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException1()
{
$item = Document::fromResponse(array(
'file_name' => 'testFileName',
'mime_type' => 'audio/mp3',
'file_size' => 3,
'thumb' => array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
)
));
}
}