|
1
|
|
|
<?php |
|
2
|
|
|
namespace Dokobit\Gateway\Tests\Query\Signing; |
|
3
|
|
|
|
|
4
|
|
|
use Dokobit\Gateway\Query\Signing\Create; |
|
5
|
|
|
use Dokobit\Gateway\Query\QueryInterface; |
|
6
|
|
|
use Dokobit\Gateway\Tests\TestCase; |
|
7
|
|
|
|
|
8
|
|
|
class CreateTest extends TestCase |
|
9
|
|
|
{ |
|
10
|
|
|
const TYPE = 'pdf'; |
|
11
|
|
|
const NAME = 'Agreement'; |
|
12
|
|
|
const SIGNER_ID = 'FirstSignerId'; |
|
13
|
|
|
const SIGNER_NAME = 'Kraft'; |
|
14
|
|
|
const SIGNER_SURNAME = 'Lawrence'; |
|
15
|
|
|
const SIGNER_CODE = '51001091072'; |
|
16
|
|
|
const SIGNER_PHONE = '+37060000007'; |
|
17
|
|
|
const FILE_TOKEN = 'UploadedFileToken'; |
|
18
|
|
|
const POSTBACK_URL = 'https://www.example.org/postback.php'; |
|
19
|
|
|
const LANGUAGE = 'lt'; |
|
20
|
|
|
const PDF_LEVEL = 1; |
|
21
|
|
|
|
|
22
|
|
|
/** @var Create */ |
|
23
|
|
|
private $query; |
|
24
|
|
|
|
|
25
|
|
|
/** @var Create */ |
|
26
|
|
|
private $queryMinimal; |
|
27
|
|
|
|
|
28
|
|
|
protected function setUp(): void |
|
29
|
|
|
{ |
|
30
|
|
|
$this->query = new Create( |
|
31
|
|
|
self::TYPE, |
|
32
|
|
|
self::NAME, |
|
33
|
|
|
[ |
|
34
|
|
|
[ |
|
35
|
|
|
'token' => self::FILE_TOKEN, |
|
36
|
|
|
], |
|
37
|
|
|
], |
|
38
|
|
|
[ |
|
39
|
|
|
[ |
|
40
|
|
|
'id' => self::SIGNER_ID, |
|
41
|
|
|
'name' => self::SIGNER_NAME, |
|
42
|
|
|
'surname' => self::SIGNER_SURNAME, |
|
43
|
|
|
'code' => self::SIGNER_CODE, |
|
44
|
|
|
'phone' => self::SIGNER_PHONE, |
|
45
|
|
|
], |
|
46
|
|
|
], |
|
47
|
|
|
self::POSTBACK_URL, |
|
48
|
|
|
self::LANGUAGE, |
|
49
|
|
|
[ |
|
50
|
|
|
'level' => self::PDF_LEVEL, |
|
51
|
|
|
] |
|
52
|
|
|
); |
|
53
|
|
|
|
|
54
|
|
|
$this->queryMinimal = new Create( |
|
55
|
|
|
self::TYPE, |
|
56
|
|
|
self::NAME, |
|
57
|
|
|
[ |
|
58
|
|
|
[ |
|
59
|
|
|
'token' => self::FILE_TOKEN, |
|
60
|
|
|
], |
|
61
|
|
|
] |
|
62
|
|
|
); |
|
63
|
|
|
} |
|
64
|
|
|
|
|
65
|
|
|
public function testGetFields() |
|
66
|
|
|
{ |
|
67
|
|
|
$fields = $this->query->getFields(); |
|
68
|
|
|
|
|
69
|
|
|
$this->assertArrayHasKey('type', $fields); |
|
70
|
|
|
$this->assertArrayHasKey('name', $fields); |
|
71
|
|
|
$this->assertArrayHasKey('files', $fields); |
|
72
|
|
|
$this->assertArrayHasKey('signers', $fields); |
|
73
|
|
|
$this->assertArrayHasKey('postback_url', $fields); |
|
74
|
|
|
$this->assertArrayHasKey('language', $fields); |
|
75
|
|
|
$this->assertArrayHasKey(self::TYPE, $fields); |
|
76
|
|
|
|
|
77
|
|
|
$this->assertSame(self::TYPE, $fields['type']); |
|
78
|
|
|
$this->assertSame(self::NAME, $fields['name']); |
|
79
|
|
|
$this->assertSame(self::POSTBACK_URL, $fields['postback_url']); |
|
80
|
|
|
$this->assertSame(self::LANGUAGE, $fields['language']); |
|
81
|
|
|
|
|
82
|
|
|
|
|
83
|
|
|
$this->assertArrayHasKey(0, $fields['files']); |
|
84
|
|
|
$this->assertArrayHasKey('token', $fields['files'][0]); |
|
85
|
|
|
|
|
86
|
|
|
$this->assertSame(self::FILE_TOKEN, $fields['files'][0]['token']); |
|
87
|
|
|
|
|
88
|
|
|
|
|
89
|
|
|
$this->assertArrayHasKey(0, $fields['signers']); |
|
90
|
|
|
$this->assertArrayHasKey('id', $fields['signers'][0]); |
|
91
|
|
|
$this->assertArrayHasKey('name', $fields['signers'][0]); |
|
92
|
|
|
$this->assertArrayHasKey('surname', $fields['signers'][0]); |
|
93
|
|
|
$this->assertArrayHasKey('code', $fields['signers'][0]); |
|
94
|
|
|
$this->assertArrayHasKey('phone', $fields['signers'][0]); |
|
95
|
|
|
|
|
96
|
|
|
$this->assertSame(self::SIGNER_ID, $fields['signers'][0]['id']); |
|
97
|
|
|
$this->assertSame(self::SIGNER_NAME, $fields['signers'][0]['name']); |
|
98
|
|
|
$this->assertSame(self::SIGNER_SURNAME, $fields['signers'][0]['surname']); |
|
99
|
|
|
$this->assertSame(self::SIGNER_CODE, $fields['signers'][0]['code']); |
|
100
|
|
|
$this->assertSame(self::SIGNER_PHONE, $fields['signers'][0]['phone']); |
|
101
|
|
|
|
|
102
|
|
|
|
|
103
|
|
|
$this->assertArrayHasKey('level', $fields[self::TYPE]); |
|
104
|
|
|
|
|
105
|
|
|
$this->assertSame(self::PDF_LEVEL, $fields[self::TYPE]['level']); |
|
106
|
|
|
} |
|
107
|
|
|
|
|
108
|
|
|
public function testGetFieldsMinimal() |
|
109
|
|
|
{ |
|
110
|
|
|
$fields = $this->queryMinimal->getFields(); |
|
111
|
|
|
|
|
112
|
|
|
$this->assertArrayHasKey('type', $fields); |
|
113
|
|
|
$this->assertArrayHasKey('name', $fields); |
|
114
|
|
|
$this->assertArrayHasKey('files', $fields); |
|
115
|
|
|
$this->assertArrayNotHasKey('signers', $fields); |
|
116
|
|
|
|
|
117
|
|
|
$this->assertSame(self::TYPE, $fields['type']); |
|
118
|
|
|
$this->assertSame(self::NAME, $fields['name']); |
|
119
|
|
|
|
|
120
|
|
|
|
|
121
|
|
|
$this->assertArrayHasKey(0, $fields['files']); |
|
122
|
|
|
$this->assertArrayHasKey('token', $fields['files'][0]); |
|
123
|
|
|
|
|
124
|
|
|
$this->assertSame(self::FILE_TOKEN, $fields['files'][0]['token']); |
|
125
|
|
|
} |
|
126
|
|
|
|
|
127
|
|
|
public function testGetAction() |
|
128
|
|
|
{ |
|
129
|
|
|
$this->assertSame('signing/create', $this->query->getAction()); |
|
130
|
|
|
} |
|
131
|
|
|
|
|
132
|
|
|
public function testGetMethod() |
|
133
|
|
|
{ |
|
134
|
|
|
$this->assertSame(QueryInterface::POST, $this->query->getMethod()); |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
public function testCreateResult() |
|
138
|
|
|
{ |
|
139
|
|
|
$this->assertInstanceOf('Dokobit\Gateway\Result\Signing\CreateResult', $this->query->createResult()); |
|
140
|
|
|
} |
|
141
|
|
|
|
|
142
|
|
|
public function testHasValidationConstraints() |
|
143
|
|
|
{ |
|
144
|
|
|
$collection = $this->query->getValidationConstraints(); |
|
145
|
|
|
|
|
146
|
|
|
$this->assertInstanceOf( |
|
147
|
|
|
'Symfony\Component\Validator\Constraints\Collection', |
|
148
|
|
|
$collection |
|
149
|
|
|
); |
|
150
|
|
|
} |
|
151
|
|
|
} |
|
152
|
|
|
|