InstagramTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 15
rs 9.4285
cc 1
eloc 10
nc 1
nop 0
1
<?php
2
3
namespace OAuth\Unit\UserData\Extractor;
4
5
use OAuth\UserData\Extractor\Instagram;
6
7
/**
8
 * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-02-10 at 16:20:53.
9
 */
10
class InstagramTest extends \PHPUnit_Framework_TestCase
11
{
12
    const PROFILE_RESPONSE =
13
'{
14
  "meta":  {
15
    "code": 200
16
  },
17
  "data":  {
18
    "username": "johnnydonny",
19
    "bio": "A life on the edge",
20
    "website": "http://blog.johnnydonny.com",
21
    "profile_picture": "http://images.ak.instagram.com/profiles/profile_weird_numbers.jpg",
22
    "full_name": "John Doe",
23
    "counts":  {
24
      "media": 131,
25
      "followed_by": 80,
26
      "follows": 64
27
    },
28
    "id": "1111222333"
29
  }
30
}';
31
32
    /**
33
     * @var Instagram
34
     */
35
    protected $extractor;
36
37
    /**
38
     * Sets up the fixture, for example, opens a network connection.
39
     * This method is called before a test is executed.
40
     */
41
    protected function setUp()
42
    {
43
        $this->extractor = new Instagram();
44
        $service = $this->getMockBuilder('\\OAuth\\OAuth2\\Service\\Instagram')
45
            ->disableOriginalConstructor()
46
            ->getMock();
47
        $service->expects($this->any())
48
            ->method('request')
49
            ->with(Instagram::REQUEST_PROFILE)
50
            ->will($this->returnValue(InstagramTest::PROFILE_RESPONSE));
51
        /**
52
         * @var \OAuth\Common\Service\ServiceInterface $service
53
         */
54
        $this->extractor->setService($service);
55
    }
56
57
    /**
58
     * Tears down the fixture, for example, closes a network connection.
59
     * This method is called after a test is executed.
60
     */
61
    protected function tearDown()
62
    {
63
    }
64
65
    public function testDoesNotSupportEmail()
66
    {
67
        $this->assertFalse($this->extractor->supportsEmail());
68
        $this->assertNull($this->extractor->getEmail());
69
    }
70
71
    public function testDoesNotSupportVerifiedEmail()
72
    {
73
        $this->assertFalse($this->extractor->supportsVerifiedEmail());
74
        $this->assertNull($this->extractor->isEmailVerified());
75
    }
76
77
    public function testDoesNotSupportLocation()
78
    {
79
        $this->assertFalse($this->extractor->supportsLocation());
80
        $this->assertNull($this->extractor->getLocation());
81
    }
82
83
    public function testGetUniqueId()
84
    {
85
        $this->assertEquals('1111222333', $this->extractor->getUniqueId());
86
    }
87
88
    public function testUsername()
89
    {
90
        $this->assertEquals('johnnydonny', $this->extractor->getUsername());
91
    }
92
93
    public function testGetFirstName()
94
    {
95
        $this->assertEquals('John', $this->extractor->getFirstName());
96
    }
97
98
    public function testGetLastName()
99
    {
100
        $this->assertEquals('Doe', $this->extractor->getLastName());
101
    }
102
103
    public function testGetFullName()
104
    {
105
        $this->assertEquals('John Doe', $this->extractor->getFullName());
106
    }
107
108
    public function testGetDescription()
109
    {
110
        $this->assertEquals('A life on the edge', $this->extractor->getDescription());
111
    }
112
113
    public function testGetImageUrl()
114
    {
115
        $this->assertEquals('http://images.ak.instagram.com/profiles/profile_weird_numbers.jpg', $this->extractor->getImageUrl());
116
    }
117
118
    public function testGetProfileUrl()
119
    {
120
        $this->assertEquals('http://instagram.com/johnnydonny', $this->extractor->getProfileUrl());
121
    }
122
123
    public function testGetWebsites()
124
    {
125
        $expected = array(
126
            'http://blog.johnnydonny.com'
127
        );
128
        $this->assertEquals($expected, $this->extractor->getWebsites());
129
    }
130
131
    public function testGetExtras()
132
    {
133
        $extras = $this->extractor->getExtras();
134
        $this->assertArrayHasKey('counts', $extras);
135
136
        $this->assertArrayNotHasKey('id', $extras);
137
        $this->assertArrayNotHasKey('bio', $extras);
138
        $this->assertArrayNotHasKey('website', $extras);
139
    }
140
}
141