forked from TelegramBot/Api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathVideoTest.php
More file actions
267 lines (244 loc) · 7.09 KB
/
VideoTest.php
File metadata and controls
267 lines (244 loc) · 7.09 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
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
<?php
namespace TelegramBot\Api\Test;
use TelegramBot\Api\Types\PhotoSize;
use TelegramBot\Api\Types\Video;
class VideoTest extends \PHPUnit_Framework_TestCase
{
public function testSetFileId()
{
$item = new Video();
$item->setFileId('testfileId');
$this->assertAttributeEquals('testfileId', 'fileId', $item);
}
public function testGetFileId()
{
$item = new Video();
$item->setFileId('testfileId');
$this->assertEquals('testfileId', $item->getFileId());
}
public function testSetDuration()
{
$item = new Video();
$item->setDuration(1);
$this->assertAttributeEquals(1, 'duration', $item);
}
public function testGetDuration()
{
$item = new Video();
$item->setDuration(1);
$this->assertEquals(1, $item->getDuration());
}
public function testSetFileSize()
{
$item = new Video();
$item->setFileSize(5);
$this->assertAttributeEquals(5, 'fileSize', $item);
}
public function testGetFileSize()
{
$item = new Video();
$item->setFileSize(6);
$this->assertEquals(6, $item->getFileSize());
}
public function testSetMimeType()
{
$item = new Video();
$item->setMimeType('video/mp4');
$this->assertAttributeEquals('video/mp4', 'mimeType', $item);
}
public function testGetMimeType()
{
$item = new Video();
$item->setMimeType('video/mp4');
$this->assertEquals('video/mp4', $item->getMimeType());
}
public function testSetThumb()
{
$item = new Video();
$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 Video();
$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 testSetWidth()
{
$item = new Video();
$item->setWidth(1);
$this->assertAttributeEquals(1, 'width', $item);
}
public function testGetWidth()
{
$item = new Video();
$item->setWidth(2);
$this->assertEquals(2, $item->getWidth());
}
public function testSetHeight()
{
$item = new Video();
$item->setHeight(3);
$this->assertAttributeEquals(3, 'height', $item);
}
public function testGetHeight()
{
$item = new Video();
$item->setHeight(4);
$this->assertEquals(4, $item->getHeight());
}
public function testFromResponse()
{
$item = Video::fromResponse(array(
'file_id' => 'testFileId1',
'width' => 1,
'height' => 2,
'duration' => 3,
'mime_type' => 'video/mp4',
'file_size' => 4,
'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\Video', $item);
$this->assertAttributeEquals('testFileId1', 'fileId', $item);
$this->assertAttributeEquals(1, 'width', $item);
$this->assertAttributeEquals(2, 'height', $item);
$this->assertAttributeEquals(3, 'duration', $item);
$this->assertAttributeEquals('video/mp4', 'mimeType', $item);
$this->assertAttributeEquals(4, 'fileSize', $item);
$this->assertAttributeEquals($thumb, 'thumb', $item);
$this->assertInstanceOf('\TelegramBot\Api\Types\PhotoSize', $item->getThumb());
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetHeightException()
{
$item = new Video();
$item->setHeight('s');
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetWidthException()
{
$item = new Video();
$item->setWidth('s');
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetDurationException()
{
$item = new Video();
$item->setDuration('s');
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetFileSizeException()
{
$item = new Video();
$item->setFileSize('s');
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException1()
{
$item = Video::fromResponse(array(
'width' => 1,
'height' => 2,
'duration' => 3,
'mime_type' => 'video/mp4',
'file_size' => 4,
'thumb' => array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
)
));
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException2()
{
$item = Video::fromResponse(array(
'file_id' => 'testFileId1',
'height' => 2,
'duration' => 3,
'mime_type' => 'video/mp4',
'file_size' => 4,
'thumb' => array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
)
));
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException3()
{
$item = Video::fromResponse(array(
'file_id' => 'testFileId1',
'width' => 1,
'duration' => 3,
'mime_type' => 'video/mp4',
'file_size' => 4,
'thumb' => array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
)
));
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException4()
{
$item = Video::fromResponse(array(
'file_id' => 'testFileId1',
'width' => 1,
'height' => 2,
'mime_type' => 'video/mp4',
'file_size' => 4,
'thumb' => array(
'file_id' => 'testFileId1',
'width' => 5,
'height' => 6,
'file_size' => 7
)
));
}
}