SignerTest::setUp()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * Copyright (c) 2014 Ryan Parman.
4
 *
5
 * http://opensource.org/licenses/Apache2.0
6
 */
7
8
namespace Skyzyx\Test\Signer;
9
10
use \PHPUnit_Framework_TestCase;
11
use Skyzyx\Signer\Signer;
12
13
class SignerTest extends PHPUnit_Framework_TestCase
14
{
15
    /** @var string */
16
    const DEFAULT_SELF_KEY = 'Skyzyx';
17
18
    /** @var string */
19
    const DEFAULT_CLIENT_ID = 'k3qDQy0Tr56v1ceo';
20
21
    /** @var string */
22
    const DEFAULT_CLIENT_SECRET = 'O5j@pG@Jt%AzyiJTEfo!£LSz8yqSj)JX)S6FvW%58KjlS9bc%Fi7&&C4KSCT8hxd';
23
24
    /** @var string */
25
    const DEFAULT_SIGNATURE = 'dfbffab5b6f7156402da8147886bba3eba67bd5baf2e780ba9d39e8437db7c4735e9a0b834aa21ac76f98da8c52a2a0cd1b0192d0f0df5c98e3848b1b2e1a037';
0 ignored issues
show
Coding Style introduced by
This line exceeds maximum limit of 120 characters; contains 161 characters

Overly long lines are hard to read on any screen. Most code styles therefor impose a maximum limit on the number of characters in a line.

Loading history...
26
27
    /** @var \Skyzyx\Signer\Signer */
28
    public $signer;
29
30
    public function setUp()
31
    {
32
        $this->signer = new Signer(self::DEFAULT_SELF_KEY, self::DEFAULT_CLIENT_ID, self::DEFAULT_CLIENT_SECRET);
33
    }
34
35
    public function testAttributes()
36
    {
37
        $this->assertEquals(self::DEFAULT_SELF_KEY, $this->readAttribute($this->signer, 'self_key'));
38
        $this->assertEquals(self::DEFAULT_CLIENT_ID, $this->readAttribute($this->signer, 'client_id'));
39
        $this->assertEquals(self::DEFAULT_CLIENT_SECRET, $this->readAttribute($this->signer, 'client_secret'));
40
    }
41
42
    public function testGetSelfKey()
43
    {
44
        $this->assertEquals(self::DEFAULT_SELF_KEY, $this->signer->getSelfKey());
45
    }
46
47
    public function testGetClientKey()
48
    {
49
        $this->assertEquals(self::DEFAULT_CLIENT_ID, $this->signer->getClientId());
50
    }
51
52
    public function testGetClientSecret()
53
    {
54
        $this->assertEquals(self::DEFAULT_CLIENT_SECRET, $this->signer->getClientSecret());
55
    }
56
57
    public function testSign()
58
    {
59
        $signature = $this->signer->sign([
60
            'ClientID' => self::DEFAULT_CLIENT_ID,
61
            'Domain' => 'foo.com',
62
            'Path' => '/',
63
            'Expires' => 'Wed, 13 Jan 2021 22:23:01 GMT',
64
            'Secure' => null,
65
            'HttpOnly' => null,
66
        ]);
67
68
        $this->assertEquals(self::DEFAULT_SIGNATURE, $signature);
69
    }
70
}
71