Skip to content

Commit b44bf7f

Browse files
test: expand status propagation data provider coverage
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent fa19a70 commit b44bf7f

1 file changed

Lines changed: 20 additions & 4 deletions

File tree

tests/php/Unit/Controller/RequestSignatureControllerTest.php

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -62,16 +62,24 @@ protected function setUp(): void {
6262
);
6363
}
6464

65-
public function testRequestOmitsStatusWhenNull(): void {
65+
#[DataProvider('statusPayloadScenarios')]
66+
public function testRequestStatusPropagation(?int $status, bool $expectStatusKey): void {
6667
$file = new FileEntity();
6768
$file->setId(10);
6869
$file->setParentFileId(99);
6970

7071
$this->requestSignatureService
7172
->expects($this->once())
7273
->method('validateNewRequestToFile')
73-
->with($this->callback(static function (array $payload): bool {
74-
return !array_key_exists('status', $payload);
74+
->with($this->callback(static function (array $payload) use ($expectStatusKey, $status): bool {
75+
$hasStatus = array_key_exists('status', $payload);
76+
if ($expectStatusKey !== $hasStatus) {
77+
return false;
78+
}
79+
if ($expectStatusKey) {
80+
return $payload['status'] === $status;
81+
}
82+
return true;
7583
}));
7684

7785
$this->requestSignatureService
@@ -98,7 +106,7 @@ public function testRequestOmitsStatusWhenNull(): void {
98106
file: ['nodeId' => 12],
99107
files: [],
100108
callback: null,
101-
status: null,
109+
status: $status,
102110
signatureFlow: null,
103111
);
104112

@@ -171,6 +179,14 @@ public static function statusPayloadScenarios(): array {
171179
'status' => null,
172180
'expectStatusKey' => false,
173181
],
182+
'draft status is preserved' => [
183+
'status' => 0,
184+
'expectStatusKey' => true,
185+
],
186+
'able to sign status is preserved' => [
187+
'status' => 1,
188+
'expectStatusKey' => true,
189+
],
174190
'explicit status is preserved' => [
175191
'status' => 4,
176192
'expectStatusKey' => true,

0 commit comments

Comments
 (0)