Passed
Branch develop (84afed)
by Paulius
04:34 queued 02:36
created

SignTest   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
eloc 18
dl 0
loc 37
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A testPrepare() 0 19 1
A testSign() 0 10 1
1
<?php
2
namespace Dokobit\Gateway\Tests\Integration\Signing;
3
4
use Dokobit\Gateway\Query\Signing\Prepare;
5
use Dokobit\Gateway\Query\Signing\Sign;
6
use Dokobit\Gateway\Result\Signing\PrepareResult;
7
use Dokobit\Gateway\Result\Signing\SignResult;
8
use Dokobit\Gateway\Tests\Integration\TestCase;
9
10
class SignTest extends TestCase
11
{
12
    public function testPrepare()
13
    {
14
        $this->createSigning();
15
16
        /** @var PrepareResult $result */
17
        $result = $this->client->get(new Prepare(
18
            $this->signingToken,
19
            self::SIGNER1_ID,
20
            base64_encode(CERTIFICATE_SIGN)
0 ignored issues
show
Bug introduced by
The constant Dokobit\Gateway\Tests\In...igning\CERTIFICATE_SIGN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
21
        ));
22
23
        $this->assertSame('ok', $result->getStatus());
24
        $this->assertSame('sha256', $result->getAlgorithm());
25
        $this->assertNotEmpty($result->getDtbs());
26
        $this->assertNotEmpty($result->getDtbsHash());
27
28
        return [
29
            'dtbs' => $result->getDtbs(),
30
            'signingToken' => $this->signingToken,
31
        ];
32
    }
33
34
    /**
35
     * @depends testPrepare
36
     */
37
    public function testSign(array $data)
38
    {
39
        /** @var SignResult $result */
40
        $result = $this->client->get(new Sign(
41
            $data['signingToken'],
42
            self::SIGNER1_ID,
43
            $this->sign($data['dtbs'], PRIVATE_KEY_SIGN)
0 ignored issues
show
Bug introduced by
The constant Dokobit\Gateway\Tests\In...igning\PRIVATE_KEY_SIGN was not found. Maybe you did not declare it correctly or list all dependencies?
Loading history...
44
        ));
45
46
        $this->assertSame('ok', $result->getStatus());
47
    }
48
}
49