1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
namespace OAuth\Unit\UserData\Extractor; |
4
|
|
|
|
5
|
|
|
use OAuth\UserData\Extractor\Linkedin; |
6
|
|
|
|
7
|
|
|
/** |
8
|
|
|
* Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-02-09 at 10:22:38. |
9
|
|
|
*/ |
10
|
|
|
class LinkedinTest extends \PHPUnit_Framework_TestCase |
11
|
|
|
{ |
12
|
|
|
const PROFILE_RESPONSE = |
13
|
|
|
'{ |
14
|
|
|
"emailAddress": "[email protected]", |
15
|
|
|
"firstName": "John", |
16
|
|
|
"headline": "Frontend Web Developer", |
17
|
|
|
"id": "ABCDEFGH", |
18
|
|
|
"industry": "Computer Software", |
19
|
|
|
"lastName": "Doe", |
20
|
|
|
"location": { |
21
|
|
|
"country": {"code": "it"}, |
22
|
|
|
"name": "Rome Area, Italy" |
23
|
|
|
}, |
24
|
|
|
"memberUrlResources": { |
25
|
|
|
"_total": 1, |
26
|
|
|
"values": [{ |
27
|
|
|
"id": 11, |
28
|
|
|
"name": "Company Website", |
29
|
|
|
"url": "http://www.johnnydonny.com" |
30
|
|
|
}, |
31
|
|
|
{ |
32
|
|
|
"id": 12, |
33
|
|
|
"name": "Blog", |
34
|
|
|
"url": "http://blog.johnnydonny.com" |
35
|
|
|
}] |
36
|
|
|
}, |
37
|
|
|
"pictureUrl": "http://m.c.lnkd.licdn.com/mpr/mprx/someweirdstring", |
38
|
|
|
"publicProfileUrl": "http://www.linkedin.com/in/johnnydonny", |
39
|
|
|
"summary": "I am who I am" |
40
|
|
|
} |
41
|
|
|
'; |
42
|
|
|
|
43
|
|
|
/** |
44
|
|
|
* @var Linkedin |
45
|
|
|
*/ |
46
|
|
|
protected $extractor; |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* Sets up the fixture, for example, opens a network connection. |
50
|
|
|
* This method is called before a test is executed. |
51
|
|
|
*/ |
52
|
|
|
protected function setUp() |
53
|
|
|
{ |
54
|
|
|
$this->extractor = new Linkedin; |
55
|
|
|
$service = $this->getMockBuilder('\\OAuth\\OAuth2\\Service\\Linkedin') |
56
|
|
|
->disableOriginalConstructor() |
57
|
|
|
->getMock(); |
58
|
|
|
$service->expects($this->any()) |
59
|
|
|
->method('request') |
60
|
|
|
->with(Linkedin::createProfileRequestUrl()) |
61
|
|
|
->will($this->returnValue(LinkedinTest::PROFILE_RESPONSE)); |
62
|
|
|
/** |
63
|
|
|
* @var \OAuth\Common\Service\ServiceInterface $service |
64
|
|
|
*/ |
65
|
|
|
$this->extractor->setService($service); |
66
|
|
|
} |
67
|
|
|
|
68
|
|
|
/** |
69
|
|
|
* Tears down the fixture, for example, closes a network connection. |
70
|
|
|
* This method is called after a test is executed. |
71
|
|
|
*/ |
72
|
|
|
protected function tearDown() |
73
|
|
|
{ |
74
|
|
|
} |
75
|
|
|
|
76
|
|
|
public function testDoesNotSupportUsername() |
77
|
|
|
{ |
78
|
|
|
$this->assertFalse($this->extractor->supportsUsername()); |
79
|
|
|
$this->assertNull($this->extractor->getUsername()); |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
public function testGetUniqueId() |
83
|
|
|
{ |
84
|
|
|
$this->assertEquals('ABCDEFGH', $this->extractor->getUniqueId()); |
85
|
|
|
} |
86
|
|
|
|
87
|
|
|
public function testGetFirstName() |
88
|
|
|
{ |
89
|
|
|
$this->assertEquals('John', $this->extractor->getFirstName()); |
90
|
|
|
} |
91
|
|
|
|
92
|
|
|
public function testGetLastName() |
93
|
|
|
{ |
94
|
|
|
$this->assertEquals('Doe', $this->extractor->getLastName()); |
95
|
|
|
} |
96
|
|
|
|
97
|
|
|
public function testGetFullName() |
98
|
|
|
{ |
99
|
|
|
$this->assertEquals('John Doe', $this->extractor->getFullName()); |
100
|
|
|
} |
101
|
|
|
|
102
|
|
|
public function testGetEmail() |
103
|
|
|
{ |
104
|
|
|
$this->assertEquals('[email protected]', $this->extractor->getEmail()); |
105
|
|
|
} |
106
|
|
|
|
107
|
|
|
public function testGetDescription() |
108
|
|
|
{ |
109
|
|
|
$this->assertEquals('I am who I am', $this->extractor->getDescription()); |
110
|
|
|
} |
111
|
|
|
|
112
|
|
|
public function testGetImageUrl() |
113
|
|
|
{ |
114
|
|
|
$this->assertEquals('http://m.c.lnkd.licdn.com/mpr/mprx/someweirdstring', $this->extractor->getImageUrl()); |
115
|
|
|
} |
116
|
|
|
|
117
|
|
|
public function testGetProfileUrl() |
118
|
|
|
{ |
119
|
|
|
$this->assertEquals('http://www.linkedin.com/in/johnnydonny', $this->extractor->getProfileUrl()); |
120
|
|
|
} |
121
|
|
|
|
122
|
|
|
public function testGetLocation() |
123
|
|
|
{ |
124
|
|
|
$this->assertEquals('Rome Area, Italy', $this->extractor->getLocation()); |
125
|
|
|
} |
126
|
|
|
|
127
|
|
|
public function testGetWebsites() |
128
|
|
|
{ |
129
|
|
|
$expected = array( |
130
|
|
|
'http://www.johnnydonny.com', |
131
|
|
|
'http://blog.johnnydonny.com' |
132
|
|
|
); |
133
|
|
|
$this->assertEquals($expected, $this->extractor->getWebsites()); |
134
|
|
|
} |
135
|
|
|
|
136
|
|
|
public function testIsEmailVerified() |
137
|
|
|
{ |
138
|
|
|
$this->assertTrue($this->extractor->isEmailVerified()); |
139
|
|
|
} |
140
|
|
|
|
141
|
|
|
public function testGetExtras() |
142
|
|
|
{ |
143
|
|
|
$extras = $this->extractor->getExtras(); |
144
|
|
|
$this->assertArrayHasKey('industry', $extras); |
145
|
|
|
$this->assertArrayHasKey('headline', $extras); |
146
|
|
|
|
147
|
|
|
$this->assertArrayNotHasKey('id', $extras); |
148
|
|
|
$this->assertArrayNotHasKey('firstName', $extras); |
149
|
|
|
$this->assertArrayNotHasKey('lastName', $extras); |
150
|
|
|
} |
151
|
|
|
} |
152
|
|
|
|