Completed
Push — master ( d86ec6...c1c96a )
by sabaku
01:38
created

SignatureTest   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 28
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
dl 0
loc 28
rs 10
c 1
b 0
f 0
wmc 3
lcom 1
cbo 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
A setUp() 0 3 1
A testGetSignature() 0 4 1
A testGetFormSignature() 0 11 1
1
<?php
2
namespace Upyun\Tests;
3
use Upyun\Signature;
4
use Upyun\Config;
5
6
class SignatureTest extends \PHPUnit_Framework_TestCase{
7
8
    /**
9
     * @var Config;
10
     */
11
    public $config;
12
13
    public function setUp() {
14
        $this->config = new Config('bucket', 'operator', 'password');
15
    }
16
17
    public function testGetSignature() {
18
        $sign = Signature::getSignature($this->config, array('a' => 'a', 'b' => 'b'), Signature::SIGN_MULTIPART, '123');
19
        $this->assertEquals($sign , '2aa0afd612df8fab4b3fded36c396234');
0 ignored issues
show
Coding Style introduced by
Space found before comma in function call
Loading history...
20
    }
21
22
    public function testGetFormSignature() {
23
        $config = new Config('upyun-temp', 'upyun', 'upyun520');
24
        $sign = Signature::getFormSignature($config, array(
25
            'save-key' => '/demo.jpg',
26
            'expiration' => '1478674618',
27
            'date' => 'Wed, 9 Nov 2016 14:26:58 GMT',
28
            'content-md5' => '7ac66c0f148de9519b8bd264312c4d64'
29
        ));
30
        $this->assertEquals($sign['policy'], 'eyJzYXZlLWtleSI6Ii9kZW1vLmpwZyIsImV4cGlyYXRpb24iOiIxNDc4Njc0NjE4IiwiZGF0ZSI6IldlZCwgOSBOb3YgMjAxNiAxNDoyNjo1OCBHTVQiLCJjb250ZW50LW1kNSI6IjdhYzY2YzBmMTQ4ZGU5NTE5YjhiZDI2NDMxMmM0ZDY0IiwiYnVja2V0IjoidXB5dW4tdGVtcCJ9');
31
        $this->assertEquals($sign['signature'], 'aWqUna7XpJ3mJ6Clz6AMeay++Qk=');
32
    }
33
}
34