Completed
Pull Request — master (#479)
by Andrey
02:39
created

AbstractClientTest   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 63
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 63
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A testConstructCorrectInterface() 0 6 1
A testSetMaxRedirects() 0 7 1
A testSetTimeout() 0 7 1
A testNormalizeHeaders() 0 22 1
1
<?php
2
3
namespace OAuthTest\Unit\Common\Http;
4
5
class AbstractClientTest extends \PHPUnit_Framework_TestCase
6
{
7
    /**
8
     * @covers OAuth\Common\Http\Client\AbstractClient::__construct
9
     */
10
    public function testConstructCorrectInterface()
11
    {
12
        $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient');
13
14
        $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client);
15
    }
16
17
    /**
18
     * @covers OAuth\Common\Http\Client\AbstractClient::__construct
19
     * @covers OAuth\Common\Http\Client\AbstractClient::setMaxRedirects
20
     */
21
    public function testSetMaxRedirects()
22
    {
23
        $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient');
24
25
        $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client->setMaxRedirects(10));
26
        $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client->setMaxRedirects(10));
27
    }
28
29
    /**
30
     * @covers OAuth\Common\Http\Client\AbstractClient::__construct
31
     * @covers OAuth\Common\Http\Client\AbstractClient::setTimeout
32
     */
33
    public function testSetTimeout()
34
    {
35
        $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient');
36
37
        $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\AbstractClient', $client->setTimeout(25));
38
        $this->assertInstanceOf('\\OAuth\\Common\\Http\\Client\\ClientInterface', $client->setTimeout(25));
39
    }
40
41
    /**
42
     * @covers OAuth\Common\Http\Client\AbstractClient::__construct
43
     * @covers OAuth\Common\Http\Client\AbstractClient::normalizeHeaders
44
     */
45
    public function testNormalizeHeaders()
46
    {
47
        $client = $this->getMockForAbstractClass('\\OAuth\\Common\\Http\\Client\\AbstractClient');
48
49
        $original = array(
50
            'lowercasekey' => 'lowercasevalue',
51
            'UPPERCASEKEY' => 'UPPERCASEVALUE',
52
            'mIxEdCaSeKey' => 'MiXeDcAsEvAlUe',
53
            '31i71casekey' => '31i71casevalue',
54
        );
55
56
        $goal = array(
57
            'lowercasekey' => 'Lowercasekey: lowercasevalue',
58
            'UPPERCASEKEY' => 'Uppercasekey: UPPERCASEVALUE',
59
            'mIxEdCaSeKey' => 'Mixedcasekey: MiXeDcAsEvAlUe',
60
            '31i71casekey' => '31i71casekey: 31i71casevalue',
61
        );
62
63
        $client->normalizeHeaders($original);
64
65
        $this->assertSame($goal, $original);
66
    }
67
}
68