Completed
Pull Request — master (#478)
by
unknown
02:35
created

testConstructCorrectInstanceWithCustomUri()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 8
nc 1
nop 0
1
<?php
2
3
namespace OAuthTest\Unit\OAuth1\Service;
4
5
use OAuth\OAuth1\Service\Etsy;
6
7
class EtsyTest extends AbstractTokenParserTest
8
{
9
    
10
    protected function getClassName()
11
    {
12
        return '\OAuth\OAuth1\Service\Etsy';
13
    }
14
    
15
    /**
16
     * @covers OAuth\OAuth1\Service\Etsy::__construct
17
     */
18
    public function testConstructCorrectInterfaceWithoutCustomUri()
19
    {
20
        $service = new Etsy(
21
            $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
22
            $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
23
            $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
24
            $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
25
        );
26
27
        $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\ServiceInterface', $service);
28
    }
29
30
    /**
31
     * @covers OAuth\OAuth1\Service\Etsy::__construct
32
     */
33
    public function testConstructCorrectInstanceWithoutCustomUri()
34
    {
35
        $service = new Etsy(
36
            $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
37
            $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
38
            $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
39
            $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
40
        );
41
42
        $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service);
43
    }
44
45
    /**
46
     * @covers OAuth\OAuth1\Service\Etsy::__construct
47
     */
48
    public function testConstructCorrectInstanceWithCustomUri()
49
    {
50
        $service = new Etsy(
51
            $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
52
            $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
53
            $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
54
            $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface'),
55
            $this->getMock('\\OAuth\\Common\\Http\\Uri\\UriInterface')
56
        );
57
58
        $this->assertInstanceOf('\\OAuth\\OAuth1\\Service\\AbstractService', $service);
59
    }
60
61
    /**
62
     * @covers OAuth\OAuth1\Service\Etsy::__construct
63
     * @covers OAuth\OAuth1\Service\Etsy::getRequestTokenEndpoint
64
     */
65
    public function testGetRequestTokenEndpoint()
66
    {
67
        $service = new Etsy(
68
            $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
69
            $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
70
            $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
71
            $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
72
        );
73
74
        $this->assertSame(
75
            'https://openapi.etsy.com/v2/oauth/request_token',
76
            $service->getRequestTokenEndpoint()->getAbsoluteUri()
77
        );
78
79
		$service->setScopes(array('email_r', 'cart_rw'));
80
81
        $this->assertSame(
82
            'https://openapi.etsy.com/v2/oauth/request_token?scope=email_r%20cart_rw',
83
            $service->getRequestTokenEndpoint()->getAbsoluteUri()
84
        );
85
86
    }
87
88
    /**
89
     * @covers OAuth\OAuth1\Service\Etsy::__construct
90
     * @covers OAuth\OAuth1\Service\Etsy::getAuthorizationEndpoint
91
     */
92
    public function testGetAuthorizationEndpoint()
93
    {
94
        $service = new Etsy(
95
            $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
96
            $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
97
            $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
98
            $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
99
        );
100
101
        $this->assertSame(
102
            'https://openapi.etsy.com/v2/',
103
            $service->getAuthorizationEndpoint()->getAbsoluteUri()
104
        );
105
    }
106
107
    /**
108
     * @covers OAuth\OAuth1\Service\Etsy::__construct
109
     * @covers OAuth\OAuth1\Service\Etsy::getAccessTokenEndpoint
110
     */
111
    public function testGetAccessTokenEndpoint()
112
    {
113
        $service = new Etsy(
114
            $this->getMock('\\OAuth\\Common\\Consumer\\CredentialsInterface'),
115
            $this->getMock('\\OAuth\\Common\\Http\\Client\\ClientInterface'),
116
            $this->getMock('\\OAuth\\Common\\Storage\\TokenStorageInterface'),
117
            $this->getMock('\\OAuth\\OAuth1\\Signature\\SignatureInterface')
118
        );
119
120
        $this->assertSame(
121
            'https://openapi.etsy.com/v2/oauth/access_token',
122
            $service->getAccessTokenEndpoint()->getAbsoluteUri()
123
        );
124
    }
125
126
}
127