|
1
|
|
|
<?php |
|
2
|
|
|
namespace OAuth\Unit\UserData\Extractor; |
|
3
|
|
|
|
|
4
|
|
|
use OAuth\UserData\Extractor\Twitter; |
|
5
|
|
|
|
|
6
|
|
|
/** |
|
7
|
|
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-02-08 at 00:52:53. |
|
8
|
|
|
*/ |
|
9
|
|
|
class TwitterTest extends \PHPUnit_Framework_TestCase |
|
10
|
|
|
{ |
|
11
|
|
|
const PROFILE_RESPONSE = |
|
12
|
|
|
'{ |
|
13
|
|
|
"name": "Matt Harris", |
|
14
|
|
|
"profile_sidebar_border_color": "C0DEED", |
|
15
|
|
|
"profile_background_tile": false, |
|
16
|
|
|
"profile_sidebar_fill_color": "DDEEF6", |
|
17
|
|
|
"location": "San Francisco", |
|
18
|
|
|
"profile_image_url": "http://a1.twimg.com/profile_images/554181350/matt_normal.jpg", |
|
19
|
|
|
"created_at": "Sat Feb 17 20:49:54 +0000 2007", |
|
20
|
|
|
"profile_link_color": "0084B4", |
|
21
|
|
|
"favourites_count": 95, |
|
22
|
|
|
"url": "http://themattharris.com", |
|
23
|
|
|
"entities": { |
|
24
|
|
|
"url": { |
|
25
|
|
|
"urls": [{ |
|
26
|
|
|
"url": "http:\/\/t.co\/78pYTvWfJd", |
|
27
|
|
|
"expanded_url": "http:\/\/dev.twitter.com", |
|
28
|
|
|
"display_url": "dev.twitter.com", |
|
29
|
|
|
"indices": [0, 22] |
|
30
|
|
|
}] |
|
31
|
|
|
}, |
|
32
|
|
|
"description": { |
|
33
|
|
|
"urls": [] |
|
34
|
|
|
} |
|
35
|
|
|
}, |
|
36
|
|
|
"contributors_enabled": false, |
|
37
|
|
|
"utc_offset": -28800, |
|
38
|
|
|
"id": 777925, |
|
39
|
|
|
"profile_use_background_image": true, |
|
40
|
|
|
"profile_text_color": "333333", |
|
41
|
|
|
"protected": false, |
|
42
|
|
|
"followers_count": 1025, |
|
43
|
|
|
"lang": "en", |
|
44
|
|
|
"verified": false, |
|
45
|
|
|
"profile_background_color": "C0DEED", |
|
46
|
|
|
"geo_enabled": true, |
|
47
|
|
|
"notifications": false, |
|
48
|
|
|
"description": "Developer Advocate at Twitter.", |
|
49
|
|
|
"time_zone": "Tijuana", |
|
50
|
|
|
"friends_count": 294, |
|
51
|
|
|
"statuses_count": 2924, |
|
52
|
|
|
"profile_background_image_url": "http://s.twimg.com/a/1276711174/images/themes/theme1/bg.png", |
|
53
|
|
|
"status": { |
|
54
|
|
|
"coordinates": { |
|
55
|
|
|
"coordinates": [ |
|
56
|
|
|
-122.40075845, |
|
57
|
|
|
37.78264991 |
|
58
|
|
|
], |
|
59
|
|
|
"type": "Point" |
|
60
|
|
|
}, |
|
61
|
|
|
"favorited": false, |
|
62
|
|
|
"created_at": "Tue Jun 22 18:17:48 +0000 2010", |
|
63
|
|
|
"truncated": false, |
|
64
|
|
|
"text": "Going through and updating @twitterapi documentation", |
|
65
|
|
|
"contributors": null, |
|
66
|
|
|
"id": 16789004997, |
|
67
|
|
|
"geo": { |
|
68
|
|
|
"coordinates": [ |
|
69
|
|
|
37.78264991, |
|
70
|
|
|
-122.40075845 |
|
71
|
|
|
], |
|
72
|
|
|
"type": "Point" |
|
73
|
|
|
}, |
|
74
|
|
|
"in_reply_to_user_id": null, |
|
75
|
|
|
"place": null, |
|
76
|
|
|
"source": "<a href=\"http://itunes.apple.com/app/twitter/id333903271?mt=8\" rel=\"nofollow\">Twitter for iPhone</a>", |
|
77
|
|
|
"in_reply_to_screen_name": null, |
|
78
|
|
|
"in_reply_to_status_id": null |
|
79
|
|
|
}, |
|
80
|
|
|
"screen_name": "themattharris", |
|
81
|
|
|
"following": false |
|
82
|
|
|
}'; |
|
83
|
|
|
|
|
84
|
|
|
/** |
|
85
|
|
|
* @var Twitter |
|
86
|
|
|
*/ |
|
87
|
|
|
protected $extractor; |
|
88
|
|
|
|
|
89
|
|
|
/** |
|
90
|
|
|
* Sets up the fixture, for example, opens a network connection. |
|
91
|
|
|
* This method is called before a test is executed. |
|
92
|
|
|
*/ |
|
93
|
|
|
protected function setUp() |
|
94
|
|
|
{ |
|
95
|
|
|
$this->extractor = new Twitter(); |
|
96
|
|
|
$service = $this->getMockBuilder('\\OAuth\\OAuth1\\Service\\Twitter') |
|
97
|
|
|
->disableOriginalConstructor() |
|
98
|
|
|
->getMock(); |
|
99
|
|
|
$service->expects($this->any()) |
|
100
|
|
|
->method('request') |
|
101
|
|
|
->with(Twitter::REQUEST_PROFILE) |
|
102
|
|
|
->will($this->returnValue(TwitterTest::PROFILE_RESPONSE)); |
|
103
|
|
|
/** |
|
104
|
|
|
* @var \OAuth\Common\Service\ServiceInterface $service |
|
105
|
|
|
*/ |
|
106
|
|
|
$this->extractor->setService($service); |
|
107
|
|
|
} |
|
108
|
|
|
|
|
109
|
|
|
/** |
|
110
|
|
|
* Tears down the fixture, for example, closes a network connection. |
|
111
|
|
|
* This method is called after a test is executed. |
|
112
|
|
|
*/ |
|
113
|
|
|
protected function tearDown() |
|
114
|
|
|
{ |
|
115
|
|
|
} |
|
116
|
|
|
|
|
117
|
|
|
public function testDoesNotSupportEmail() |
|
118
|
|
|
{ |
|
119
|
|
|
$this->assertFalse($this->extractor->supportsEmail()); |
|
120
|
|
|
$this->assertNull($this->extractor->getEmail()); |
|
121
|
|
|
} |
|
122
|
|
|
|
|
123
|
|
|
public function testDoesNotSupportVerifiedEmail() |
|
124
|
|
|
{ |
|
125
|
|
|
$this->assertFalse($this->extractor->supportsVerifiedEmail()); |
|
126
|
|
|
$this->assertNull($this->extractor->isEmailVerified()); |
|
127
|
|
|
} |
|
128
|
|
|
|
|
129
|
|
|
public function testGetUniqueId() |
|
130
|
|
|
{ |
|
131
|
|
|
$this->assertEquals(777925, $this->extractor->getUniqueId()); |
|
132
|
|
|
} |
|
133
|
|
|
|
|
134
|
|
|
public function testGetUsername() |
|
135
|
|
|
{ |
|
136
|
|
|
$this->assertEquals('themattharris', $this->extractor->getUsername()); |
|
137
|
|
|
} |
|
138
|
|
|
|
|
139
|
|
|
public function testGetFullName() |
|
140
|
|
|
{ |
|
141
|
|
|
$this->assertEquals('Matt Harris', $this->extractor->getFullName()); |
|
142
|
|
|
} |
|
143
|
|
|
|
|
144
|
|
|
public function testGetFistName() |
|
145
|
|
|
{ |
|
146
|
|
|
$this->assertEquals('Matt', $this->extractor->getFirstName()); |
|
147
|
|
|
} |
|
148
|
|
|
|
|
149
|
|
|
public function testGetLastName() |
|
150
|
|
|
{ |
|
151
|
|
|
$this->assertEquals('Harris', $this->extractor->getLastName()); |
|
152
|
|
|
} |
|
153
|
|
|
|
|
154
|
|
|
public function testGetDescription() |
|
155
|
|
|
{ |
|
156
|
|
|
$this->assertEquals('Developer Advocate at Twitter.', $this->extractor->getDescription()); |
|
157
|
|
|
} |
|
158
|
|
|
|
|
159
|
|
|
public function testGetLocation() |
|
160
|
|
|
{ |
|
161
|
|
|
$this->assertEquals('San Francisco', $this->extractor->getLocation()); |
|
162
|
|
|
} |
|
163
|
|
|
|
|
164
|
|
|
public function testGetProfileUrl() |
|
165
|
|
|
{ |
|
166
|
|
|
$this->assertEquals('https://twitter.com/themattharris', $this->extractor->getProfileUrl()); |
|
167
|
|
|
} |
|
168
|
|
|
|
|
169
|
|
|
public function testGetImageUrl() |
|
170
|
|
|
{ |
|
171
|
|
|
$this->assertEquals( |
|
172
|
|
|
'http://a1.twimg.com/profile_images/554181350/matt_normal.jpg', |
|
173
|
|
|
$this->extractor->getImageUrl() |
|
174
|
|
|
); |
|
175
|
|
|
} |
|
176
|
|
|
|
|
177
|
|
|
public function testGetWebsites() |
|
178
|
|
|
{ |
|
179
|
|
|
$websites = array( |
|
180
|
|
|
'http://themattharris.com', |
|
181
|
|
|
'http://dev.twitter.com' |
|
182
|
|
|
); |
|
183
|
|
|
$this->assertEquals($websites, $this->extractor->getWebsites()); |
|
184
|
|
|
} |
|
185
|
|
|
|
|
186
|
|
|
public function testGetExtra() |
|
187
|
|
|
{ |
|
188
|
|
|
$extra = $this->extractor->getExtras(); |
|
189
|
|
|
|
|
190
|
|
|
$this->assertArrayHasKey('profile_sidebar_border_color', $extra); |
|
191
|
|
|
$this->assertArrayHasKey('profile_background_tile', $extra); |
|
192
|
|
|
$this->assertArrayHasKey('profile_sidebar_fill_color', $extra); |
|
193
|
|
|
|
|
194
|
|
|
$this->assertArrayNotHasKey('name', $extra); |
|
195
|
|
|
$this->assertArrayNotHasKey('id', $extra); |
|
196
|
|
|
$this->assertArrayNotHasKey('description', $extra); |
|
197
|
|
|
} |
|
198
|
|
|
} |
|
199
|
|
|
|