PublicApiAccessAuthTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 0
Metric Value
dl 0
loc 33
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A shouldBeConstructWithoutAnyParameter() 0 5 1
A shouldAddParameterToUrl() 0 18 1
1
<?php
2
3
/**
4
 * This file is a part of nekland youtube api package
5
 *
6
 * (c) Nekland <[email protected]>
7
 *
8
 * For the full license, take a look to the LICENSE file
9
 * on the root directory of this project
10
 */
11
12
namespace Nekland\Tests\Http\Auth;
13
14
use Nekland\YoutubeApi\Http\Auth\PublicApiAccessAuth;
15
16
class PublicApiAccessAuthTest extends \PHPUnit_Framework_TestCase
17
{
18
    /**
19
     * @test
20
     */
21
    public function shouldBeConstructWithoutAnyParameter()
22
    {
23
        $auth = new PublicApiAccessAuth();
24
        $this->assertInstanceOf('Nekland\\YoutubeApi\\Http\\Auth\\PublicApiAccessAuth', $auth);
25
    }
26
27
    /**
28
     * @test
29
     */
30
    public function shouldAddParameterToUrl()
31
    {
32
        $auth = new PublicApiAccessAuth();
33
        $auth->setOptions(['key' => 'SOME_YOUTUBE_API_KEY']);
34
35
        $request = $this->getMockBuilder('Guzzle\Http\Message\Request')->disableOriginalConstructor()->getMock();
36
        $request
37
            ->expects($this->once())
38
            ->method('getUrl')
39
            ->willReturn('http://fake.com')
40
        ;
41
        $request
42
            ->expects($this->once())
43
            ->method('setUrl')
44
            ->with($this->equalTo('http://fake.com?key=SOME_YOUTUBE_API_KEY'))
45
        ;
46
        $auth->auth($request);
47
    }
48
}
49