GmapsUrlSignerTest::testSign()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

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