PublicApiAccessAuthTest::shouldAddParameterToUrl()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 18

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 0
dl 0
loc 18
rs 9.6666
c 0
b 0
f 0
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