Completed
Push — feature/follow-google-auth ( a90b82 )
by Maxime
04:14
created

JsonFileServiceAuthTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 2
lcom 0
cbo 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testItConstructWithOrWithoutClient() 0 8 1
A testItAddsATokenToTheRequest() 0 13 1
1
<?php
2
/**
3
 * This file is a part of YoutubeApi package.
4
 *
5
 * (c) Nekland <[email protected]>
6
 *
7
 * For the full license, take a look to the LICENSE file
8
 * on the root directory of this project
9
 */
10
11
namespace Nekland\Tests\Http\Auth;
12
13
14
use Guzzle\Http\ClientInterface;
15
use Guzzle\Http\Message\Request;
16
use Nekland\YoutubeApi\Http\Auth\JsonFileServiceAuth;
17
18
class JsonFileServiceAuthTest extends \PHPUnit_Framework_TestCase
19
{
20
    use AuthServiceTrait;
21
22
    public function testItConstructWithOrWithoutClient()
23
    {
24
        $auth = new JsonFileServiceAuth();
25
        $this->assertInstanceOf(JsonFileServiceAuth::class, $auth);
26
27
        $auth = new JsonFileServiceAuth($this->prophesize(ClientInterface::class)->reveal());
28
        $this->assertInstanceOf(JsonFileServiceAuth::class, $auth);
29
    }
30
31
    public function testItAddsATokenToTheRequest()
32
    {
33
        $auth = new JsonFileServiceAuth($this->getClientMock());
34
35
        // This file is a fake, of course.
36
        $file = __DIR__ . '/../../../../test_data/given_by_google.json';
37
38
        $auth->setOptions(['json_file' => $file]);
39
        $request = new Request('POST', 'http://fake.com');
40
        $auth->auth($request);
41
42
        $this->assertContains('ya29.1.AADHN_WnGjqYiAcnONRLFDOfXia5XZLFO4RSyEhWtQPAvYpgPYiQj89c7UsrAs5_',(string)$request->getHeader('Authorization'));
43
    }
44
}
45