1
|
|
|
<?php |
2
|
|
|
namespace Dokobit\Gateway\Tests\Query\Signing; |
3
|
|
|
|
4
|
|
|
use Dokobit\Gateway\Query\Signing\Seal; |
5
|
|
|
use Dokobit\Gateway\Query\QueryInterface; |
6
|
|
|
use Dokobit\Gateway\Tests\TestCase; |
7
|
|
|
|
8
|
|
|
class SealTest extends TestCase |
9
|
|
|
{ |
10
|
|
|
const TOKEN = 'SigningToken'; |
11
|
|
|
const SIGNING_NAME = 'E-Seal'; |
12
|
|
|
const SIGNING_PURPOSE = 'signature'; |
13
|
|
|
const PDF_PAGE = 1; |
14
|
|
|
const PDF_TOP = 456; |
15
|
|
|
const PDF_LEFT = 123; |
16
|
|
|
const PDF_WIDTH = 120; |
17
|
|
|
const PDF_HEIGHT = 50; |
18
|
|
|
|
19
|
|
|
|
20
|
|
|
/** @var Seal */ |
21
|
|
|
private $queryMinimal; |
22
|
|
|
|
23
|
|
|
/** @var Seal */ |
24
|
|
|
private $queryFull; |
25
|
|
|
|
26
|
|
|
protected function setUp(): void |
27
|
|
|
{ |
28
|
|
|
$this->queryMinimal = new Seal( |
29
|
|
|
self::TOKEN, |
30
|
|
|
self::SIGNING_NAME |
31
|
|
|
); |
32
|
|
|
|
33
|
|
|
$this->queryFull = new Seal( |
34
|
|
|
self::TOKEN, |
35
|
|
|
self::SIGNING_NAME, |
36
|
|
|
self::SIGNING_PURPOSE, |
37
|
|
|
[ |
38
|
|
|
'annotation' => [ |
39
|
|
|
'page' => self::PDF_PAGE, |
40
|
|
|
'top' => self::PDF_TOP, |
41
|
|
|
'left' => self::PDF_LEFT, |
42
|
|
|
'width' => self::PDF_WIDTH, |
43
|
|
|
'height' => self::PDF_HEIGHT, |
44
|
|
|
], |
45
|
|
|
] |
46
|
|
|
); |
47
|
|
|
} |
48
|
|
|
|
49
|
|
|
public function testGetFieldsMinimal() |
50
|
|
|
{ |
51
|
|
|
$fields = $this->queryMinimal->getFields(); |
52
|
|
|
|
53
|
|
|
$this->assertArrayHasKey('token', $fields); |
54
|
|
|
$this->assertArrayHasKey('name', $fields); |
55
|
|
|
|
56
|
|
|
$this->assertSame(self::TOKEN, $fields['token']); |
57
|
|
|
$this->assertSame(self::SIGNING_NAME, $fields['name']); |
58
|
|
|
} |
59
|
|
|
|
60
|
|
|
public function testGetFieldsFull() |
61
|
|
|
{ |
62
|
|
|
$fields = $this->queryFull->getFields(); |
63
|
|
|
|
64
|
|
|
$this->assertArrayHasKey('token', $fields); |
65
|
|
|
$this->assertArrayHasKey('name', $fields); |
66
|
|
|
$this->assertArrayHasKey('signing_purpose', $fields); |
67
|
|
|
$this->assertArrayHasKey('pdf', $fields); |
68
|
|
|
$this->assertArrayHasKey('annotation', $fields['pdf']); |
69
|
|
|
$this->assertArrayHasKey('page', $fields['pdf']['annotation']); |
70
|
|
|
$this->assertArrayHasKey('top', $fields['pdf']['annotation']); |
71
|
|
|
$this->assertArrayHasKey('left', $fields['pdf']['annotation']); |
72
|
|
|
$this->assertArrayHasKey('width', $fields['pdf']['annotation']); |
73
|
|
|
$this->assertArrayHasKey('height', $fields['pdf']['annotation']); |
74
|
|
|
|
75
|
|
|
$this->assertSame(self::TOKEN, $fields['token']); |
76
|
|
|
$this->assertSame(self::SIGNING_NAME, $fields['name']); |
77
|
|
|
$this->assertSame(self::SIGNING_PURPOSE, $fields['signing_purpose']); |
78
|
|
|
$this->assertSame(self::PDF_PAGE, $fields['pdf']['annotation']['page']); |
79
|
|
|
$this->assertSame(self::PDF_TOP, $fields['pdf']['annotation']['top']); |
80
|
|
|
$this->assertSame(self::PDF_LEFT, $fields['pdf']['annotation']['left']); |
81
|
|
|
$this->assertSame(self::PDF_WIDTH, $fields['pdf']['annotation']['width']); |
82
|
|
|
$this->assertSame(self::PDF_HEIGHT, $fields['pdf']['annotation']['height']); |
83
|
|
|
} |
84
|
|
|
|
85
|
|
|
public function testGetAction() |
86
|
|
|
{ |
87
|
|
|
$this->assertSame('signing/'.self::TOKEN.'/seal', $this->queryMinimal->getAction()); |
88
|
|
|
} |
89
|
|
|
|
90
|
|
|
public function testGetMethod() |
91
|
|
|
{ |
92
|
|
|
$this->assertSame(QueryInterface::POST, $this->queryMinimal->getMethod()); |
93
|
|
|
} |
94
|
|
|
|
95
|
|
|
public function testCreateResult() |
96
|
|
|
{ |
97
|
|
|
$this->assertInstanceOf('Dokobit\Gateway\Result\Signing\SealResult', $this->queryMinimal->createResult()); |
98
|
|
|
} |
99
|
|
|
|
100
|
|
|
public function testHasValidationConstraints() |
101
|
|
|
{ |
102
|
|
|
$collection = $this->queryMinimal->getValidationConstraints(); |
103
|
|
|
|
104
|
|
|
$this->assertInstanceOf( |
105
|
|
|
'Symfony\Component\Validator\Constraints\Collection', |
106
|
|
|
$collection |
107
|
|
|
); |
108
|
|
|
} |
109
|
|
|
} |
110
|
|
|
|