Skip to content

Commit d645e67

Browse files
committed
fix: PHPUnit test
1 parent 0c42be7 commit d645e67

File tree

4 files changed

+17
-16
lines changed

4 files changed

+17
-16
lines changed

phpunit/functional/Glpi/Form/AnswersSetTest.php

+11-10
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
use Glpi\Form\Answer;
4141
use Glpi\Form\AnswersHandler\AnswersHandler;
4242
use Glpi\Form\AnswersSet;
43+
use Glpi\Form\DelegationData;
4344
use Glpi\Form\Destination\FormDestinationProblem;
4445
use Glpi\Form\Form;
4546
use Glpi\Form\Question;
@@ -150,11 +151,11 @@ public function testGetDelegationWihoutRights()
150151
[],
151152
\Session::getLoginUserID(),
152153
[],
153-
[
154-
'users_id' => getitemByTypeName(User::class, 'glpi')->getID(),
155-
'use_notification' => true,
156-
'alternative_email' => ''
157-
]
154+
new DelegationData(
155+
getitemByTypeName(User::class, 'glpi')->getID(),
156+
true,
157+
''
158+
)
158159
);
159160

160161
/** @var Ticket $ticket */
@@ -217,11 +218,11 @@ public function testGetDelegation()
217218
[],
218219
\Session::getLoginUserID(),
219220
[],
220-
[
221-
'users_id' => getitemByTypeName(User::class, 'glpi')->getID(),
222-
'use_notification' => true,
223-
'alternative_email' => ''
224-
]
221+
new DelegationData(
222+
getitemByTypeName(User::class, 'glpi')->getID(),
223+
true,
224+
''
225+
),
225226
);
226227

227228
/** @var Ticket $ticket */

src/Glpi/Controller/Form/SubmitAnswerController.php

+2-2
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ private function saveSubmittedAnswers(
113113
$form,
114114
$answers,
115115
Session::getLoginUserID(),
116-
$delegation,
117-
$files
116+
$files,
117+
$delegation
118118
);
119119

120120
return $answers;

src/Glpi/Form/AnswersHandler/AnswersHandler.php

+1-1
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,8 @@ public function saveAnswers(
9393
Form $form,
9494
array $answers,
9595
int $users_id,
96-
DelegationData $delegation,
9796
array $files = [],
97+
DelegationData $delegation = new DelegationData(),
9898
): AnswersSet {
9999
/** @var \DBmysql $DB */
100100
global $DB;

src/Glpi/Form/DelegationData.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@
3737
final class DelegationData
3838
{
3939
public function __construct(
40-
public readonly ?int $users_id,
41-
public readonly ?bool $use_notification,
42-
public readonly ?string $alternative_email
40+
public readonly ?int $users_id = null,
41+
public readonly ?bool $use_notification = null,
42+
public readonly ?string $alternative_email = null
4343
) {
4444
}
4545
}

0 commit comments

Comments
 (0)