HarvestTest   A
last analyzed

Complexity

Total Complexity 10

Size/Duplication

Total Lines 99
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 99
wmc 10
lcom 1
cbo 3
rs 10

10 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 17 1
A tearDown() 0 3 1
A testGetUniqueId() 0 4 1
A testGetUsername() 0 4 1
A testGetFirstName() 0 4 1
A testGetLastName() 0 4 1
A testGetFullName() 0 4 1
A testGetEmail() 0 4 1
A testGetImageUrl() 0 4 1
A testGetExtra() 0 13 1
1
<?php
2
3
namespace OAuth\Unit\UserData\Extractor;
4
5
use OAuth\UserData\Extractor\Harvest;
6
7
/**
8
 * Generated by PHPUnit_SkeletonGenerator 1.2.1 on 2014-02-07 at 22:32:44.
9
 */
10
class HarvestTest extends \PHPUnit_Framework_TestCase
11
{
12
    const RESPONSE_PROFILE =
13
'{
14
  "user": {
15
    "id": "012345678",
16
    "email": "[email protected]",
17
    "first_name": "John",
18
    "last_name": "Doe",
19
    "avatar_url": "something_n.jpg",
20
    "timezone": "Pacific Time (US &amp; Canada)",
21
    "admin": true
22
  }
23
}';
24
25
    /**
26
     * @var Harvest
27
     */
28
    protected $extractor;
29
30
    /**
31
     * Sets up the fixture, for example, opens a network connection.
32
     * This method is called before a test is executed.
33
     */
34
    protected function setUp()
35
    {
36
        $this->extractor = new Harvest();
37
        $service = $this->getMockBuilder('\\OAuth\\OAuth2\\Service\\Harvest')
38
            ->disableOriginalConstructor()
39
            ->setMethods(array('request'))
40
            ->getMock();
41
        $service->expects($this->any())
42
            ->method('request')
43
            ->with(Harvest::REQUEST_PROFILE)
44
            ->will($this->returnValue(HarvestTest::RESPONSE_PROFILE));
45
46
        /**
47
         * @var \OAuth\Common\Service\ServiceInterface $service
48
         */
49
        $this->extractor->setService($service);
50
    }
51
52
    /**
53
     * Tears down the fixture, for example, closes a network connection.
54
     * This method is called after a test is executed.
55
     */
56
    protected function tearDown()
57
    {
58
    }
59
60
    public function testGetUniqueId()
61
    {
62
        $this->assertEquals('012345678', $this->extractor->getUniqueId());
63
    }
64
65
    public function testGetUsername()
66
    {
67
        $this->assertEquals('[email protected]', $this->extractor->getUsername());
68
    }
69
70
    public function testGetFirstName()
71
    {
72
        $this->assertEquals('John', $this->extractor->getFirstName());
73
    }
74
75
    public function testGetLastName()
76
    {
77
        $this->assertEquals('Doe', $this->extractor->getLastName());
78
    }
79
80
    public function testGetFullName()
81
    {
82
        $this->assertEquals('John Doe', $this->extractor->getFullName());
83
    }
84
85
    public function testGetEmail()
86
    {
87
        $this->assertEquals('[email protected]', $this->extractor->getEmail());
88
    }
89
90
    public function testGetImageUrl()
91
    {
92
        $this->assertEquals('https://api.harvestapp.com/something_n.jpg', $this->extractor->getImageUrl());
93
    }
94
95
    public function testGetExtra()
96
    {
97
        $extras = $this->extractor->getExtras();
98
        $this->assertArrayHasKey('timezone', $extras);
99
        $this->assertArrayHasKey('admin', $extras);
100
101
        $this->assertArrayNotHasKey('id', $extras);
102
        $this->assertArrayNotHasKey('name', $extras);
103
        $this->assertArrayNotHasKey('first_name', $extras);
104
        $this->assertArrayNotHasKey('last_name', $extras);
105
        $this->assertArrayNotHasKey('email', $extras);
106
        $this->assertArrayNotHasKey('avatar_url', $extras);
107
    }
108
}
109