forked from TelegramBot/Api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAudioTest.php
More file actions
152 lines (134 loc) · 3.97 KB
/
AudioTest.php
File metadata and controls
152 lines (134 loc) · 3.97 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
<?php
namespace TelegramBot\Api\Test;
use TelegramBot\Api\Types\Audio;
class AudioTest extends \PHPUnit_Framework_TestCase
{
public function testSetFileId()
{
$item = new Audio();
$item->setFileId('testfileId');
$this->assertAttributeEquals('testfileId', 'fileId', $item);
}
public function testGetFileId()
{
$item = new Audio();
$item->setFileId('testfileId');
$this->assertEquals('testfileId', $item->getFileId());
}
public function testSetDuration()
{
$item = new Audio();
$item->setDuration(1);
$this->assertAttributeEquals(1, 'duration', $item);
}
public function testGetDuration()
{
$item = new Audio();
$item->setDuration(1);
$this->assertEquals(1, $item->getDuration());
}
public function testSetPerformer()
{
$item = new Audio();
$item->setPerformer('test');
$this->assertAttributeEquals('test', 'performer', $item);
}
public function testGetPerformer()
{
$item = new Audio();
$item->setPerformer('test');
$this->assertEquals('test', $item->getPerformer());
}
public function testSetTitle()
{
$item = new Audio();
$item->setTitle('test');
$this->assertAttributeEquals('test', 'title', $item);
}
public function testGetTitle()
{
$item = new Audio();
$item->setTitle('test');
$this->assertEquals('test', $item->getTitle());
}
public function testSetFileSize()
{
$item = new Audio();
$item->setFileSize(5);
$this->assertAttributeEquals(5, 'fileSize', $item);
}
public function testGetFileSize()
{
$item = new Audio();
$item->setFileSize(6);
$this->assertEquals(6, $item->getFileSize());
}
public function testSetMimeType()
{
$item = new Audio();
$item->setMimeType('audio/mp3');
$this->assertAttributeEquals('audio/mp3', 'mimeType', $item);
}
public function testGetMimeType()
{
$item = new Audio();
$item->setMimeType('audio/mp3');
$this->assertEquals('audio/mp3', $item->getMimeType());
}
public function testFromResponse()
{
$item = Audio::fromResponse(array(
'file_id' => 'testFileId1',
'duration' => 1,
'performer' => 'testperformer',
'title' => 'testtitle',
'mime_type' => 'audio/mp3',
'file_size' => 3
));
$this->assertInstanceOf('\TelegramBot\Api\Types\Audio', $item);
$this->assertAttributeEquals('testFileId1', 'fileId', $item);
$this->assertAttributeEquals(1, 'duration', $item);
$this->assertAttributeEquals('testperformer', 'performer', $item);
$this->assertAttributeEquals('testtitle', 'title', $item);
$this->assertAttributeEquals('audio/mp3', 'mimeType', $item);
$this->assertAttributeEquals(3, 'fileSize', $item);
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException()
{
$item = Audio::fromResponse(array(
'duration' => 1,
'mime_type' => 'audio/mp3',
'file_size' => 3
));
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException2()
{
$item = Audio::fromResponse(array(
'file_id' => 'testFileId1',
'mime_type' => 'audio/mp3',
'file_size' => 3
));
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetDurationException()
{
$item = new Audio();
$item->setDuration('s');
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetFileSizeException()
{
$item = new Audio();
$item->setFileSize('s');
}
}