forked from TelegramBot/Api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserProfilePhotosTest.php
More file actions
104 lines (93 loc) · 3.12 KB
/
Copy pathUserProfilePhotosTest.php
File metadata and controls
104 lines (93 loc) · 3.12 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
<?php
namespace TelegramBot\Api\Test;
use TelegramBot\Api\Types\PhotoSize;
use TelegramBot\Api\Types\UserProfilePhotos;
class UserProfilePhotosTest extends \PHPUnit_Framework_TestCase
{
public function testSetTotalCount()
{
$userProfilePhotos = new UserProfilePhotos();
$userProfilePhotos->setTotalCount(1);
$this->assertAttributeEquals(1, 'totalCount', $userProfilePhotos);
}
public function testGetTotalCount()
{
$userProfilePhotos = new UserProfilePhotos();
$userProfilePhotos->setTotalCount(1);
$this->assertEquals(1, $userProfilePhotos->getTotalCount());
}
public function testSetPhotos()
{
$userProfilePhotos = new UserProfilePhotos();
$photos = array();
for ($i = 0; $i < 10; $i++) {
$photos[] = array(
PhotoSize::fromResponse(array(
"file_id" => 'testFileId1',
'width' => $i,
'height' => $i * 2,
'file_size' => $i * 3
))
);
}
$userProfilePhotos->setPhotos($photos);
$this->assertAttributeEquals($photos, 'photos', $userProfilePhotos);
}
public function testGetPhotos()
{
$userProfilePhotos = new UserProfilePhotos();
$photos = array();
for ($i = 0; $i < 10; $i++) {
$photos[] = PhotoSize::fromResponse(array(
"file_id" => 'testFileId1',
'width' => $i,
'height' => $i * 2,
'file_size' => $i * 3
));
}
$userProfilePhotos->setPhotos($photos);
$this->assertEquals($photos, $userProfilePhotos->getPhotos());
}
public function testFromResponse()
{
$userProfilePhotos = UserProfilePhotos::fromResponse(array(
"total_count" => 1,
'photos' => array(
array(
array(
"file_id" => 'testFileId1',
'width' => 1,
'height' => 2,
'file_size' => 3
)
)
)
));
$photos = array(
array(
PhotoSize::fromResponse(array(
"file_id" => 'testFileId1',
'width' => 1,
'height' => 2,
'file_size' => 3
))
)
);
$this->assertInstanceOf('\TelegramBot\Api\Types\UserProfilePhotos', $userProfilePhotos);
$this->assertAttributeEquals(1, 'totalCount', $userProfilePhotos);
$this->assertAttributeEquals($photos, 'photos', $userProfilePhotos);
foreach ($userProfilePhotos->getPhotos() as $photoArray) {
foreach($photoArray as $photo) {
$this->assertInstanceOf('\TelegramBot\Api\Types\PhotoSize', $photo);
}
}
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetTotalCountException()
{
$item = new UserProfilePhotos();
$item->setTotalCount('s');
}
}