GmapsUrlSignerTest   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testSign() 0 8 1
A testAsCallable() 0 8 1
1
<?php
2
3
namespace BenTools\GmapsApiSigner\Tests;
4
5
use BenTools\GmapsApiSigner\GmapsUrlSigner;
6
use PHPUnit\Framework\TestCase;
7
8
class GmapsUrlSignerTest extends TestCase
9
{
10
11
    public function testSign()
12
    {
13
        $secretKey = 'nSlpOGNt10hB_FU1-RGfs3tvh0o=';
14
        $signer = new GmapsUrlSigner($secretKey);
15
        $url = 'https://maps.googleapis.com/maps/api/js?key=foo_bar';
16
        $expected = 'https://maps.googleapis.com/maps/api/js?key=foo_bar&signature=Sc3meb0HXImPjMMUiICRtekp3mk=';
17
        $this->assertEquals($expected, $signer->sign($url));
18
    }
19
20
    public function testAsCallable()
21
    {
22
        $secretKey = 'nSlpOGNt10hB_FU1-RGfs3tvh0o=';
23
        $sign = new GmapsUrlSigner($secretKey);
24
        $url = 'https://maps.googleapis.com/maps/api/js?key=foo_bar';
25
        $expected = 'https://maps.googleapis.com/maps/api/js?key=foo_bar&signature=Sc3meb0HXImPjMMUiICRtekp3mk=';
26
        $this->assertEquals($expected, $sign($url));
27
    }
28
}
29