forked from TelegramBot/Api
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUserTest.php
More file actions
119 lines (104 loc) · 2.97 KB
/
UserTest.php
File metadata and controls
119 lines (104 loc) · 2.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
<?php
namespace TelegramBot\Api\Test;
use TelegramBot\Api\Types\User;
class UserTest extends \PHPUnit_Framework_TestCase
{
public function testSetDuration()
{
$item = new User();
$item->setId(1);
$this->assertAttributeEquals(1, 'id', $item);
}
public function testSet64bitId()
{
$item = new User();
$item->setId(2147483648);
$this->assertAttributeEquals(2147483648, 'id', $item);
}
public function testGetDuration()
{
$item = new User();
$item->setId(1);
$this->assertEquals(1, $item->getId());
}
public function testSetFirstName()
{
$item = new User();
$item->setFirstName('Ilya');
$this->assertAttributeEquals('Ilya', 'firstName', $item);
}
public function testGetFirstName()
{
$item = new User();
$item->setFirstName('Ilya');
$this->assertEquals('Ilya', $item->getFirstName());
}
public function testSetLastName()
{
$item = new User();
$item->setLastName('Gusev');
$this->assertAttributeEquals('Gusev', 'lastName', $item);
}
public function testGetLastName()
{
$item = new User();
$item->setLastName('Gusev');
$this->assertEquals('Gusev', $item->getLastName());
}
public function testSetUsername()
{
$item = new User();
$item->setUsername('iGusev');
$this->assertAttributeEquals('iGusev', 'username', $item);
}
public function testGetUsername()
{
$item = new User();
$item->setUsername('iGusev');
$this->assertEquals('iGusev', $item->getUsername());
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testSetIdException()
{
$item = new User();
$item->setId('s');
}
public function testFromResponse()
{
$user = User::fromResponse(array(
'first_name' => 'Ilya',
'last_name' => 'Gusev',
'id' => 123456,
'username' => 'iGusev'
));
$this->assertInstanceOf('\TelegramBot\Api\Types\User', $user);
$this->assertEquals(123456, $user->getId());
$this->assertEquals('Ilya', $user->getFirstName());
$this->assertEquals('Gusev', $user->getLastName());
$this->assertEquals('iGusev', $user->getUsername());
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException1()
{
$user = User::fromResponse(array(
'last_name' => 'Gusev',
'id' => 123456,
'username' => 'iGusev'
));
}
/**
* @expectedException \TelegramBot\Api\InvalidArgumentException
*/
public function testFromResponseException2()
{
$user = User::fromResponse(array(
'first_name' => 'Ilya',
'last_name' => 'Gusev',
'username' => 'iGusev'
));
}
}