Skip to content

Commit 36e4d63

Browse files
committed
fix tests - remove useless override
1 parent b36d182 commit 36e4d63

5 files changed

Lines changed: 16 additions & 53 deletions

File tree

.phpstan-baseline.missingType.iterableValue.php

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14863,18 +14863,6 @@
1486314863
'count' => 1,
1486414864
'path' => __DIR__ . '/src/Glpi/Form/Destination/CommonITILField/RequesterFieldConfig.php',
1486514865
];
14866-
$ignoreErrors[] = [
14867-
'message' => '#^Method Glpi\\\\Form\\\\Destination\\\\CommonITILField\\\\SLAField\\:\\:applyConfiguratedValueToInputUsingAnswers\\(\\) has parameter \\$input with no value type specified in iterable type array\\.$#',
14868-
'identifier' => 'missingType.iterableValue',
14869-
'count' => 1,
14870-
'path' => __DIR__ . '/src/Glpi/Form/Destination/CommonITILField/SLAField.php',
14871-
];
14872-
$ignoreErrors[] = [
14873-
'message' => '#^Method Glpi\\\\Form\\\\Destination\\\\CommonITILField\\\\SLAField\\:\\:applyConfiguratedValueToInputUsingAnswers\\(\\) return type has no value type specified in iterable type array\\.$#',
14874-
'identifier' => 'missingType.iterableValue',
14875-
'count' => 1,
14876-
'path' => __DIR__ . '/src/Glpi/Form/Destination/CommonITILField/SLAField.php',
14877-
];
1487814866
$ignoreErrors[] = [
1487914867
'message' => '#^Method Glpi\\\\Form\\\\Destination\\\\CommonITILField\\\\SLATTOFieldConfig\\:\\:jsonDeserialize\\(\\) has parameter \\$data with no value type specified in iterable type array\\.$#',
1488014868
'identifier' => 'missingType.iterableValue',

.phpstan-baseline.php

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16741,6 +16741,12 @@
1674116741
'count' => 1,
1674216742
'path' => __DIR__ . '/src/NotificationTargetTicket.php',
1674316743
];
16744+
$ignoreErrors[] = [
16745+
'message' => '#^Parameter \\#2 \\$id of static method Dropdown\\:\\:getDropdownName\\(\\) expects int, float\\|int\\|string given\\.$#',
16746+
'identifier' => 'argument.type',
16747+
'count' => 2,
16748+
'path' => __DIR__ . '/src/NotificationTargetTicket.php',
16749+
];
1674416750
$ignoreErrors[] = [
1674516751
'message' => '#^Argument of an invalid type array\\<array\\|string\\>\\|string supplied for foreach, only iterables are supported\\.$#',
1674616752
'identifier' => 'foreach.nonIterable',

src/Glpi/Form/Destination/CommonITILField/SLAField.php

Lines changed: 1 addition & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -34,40 +34,4 @@
3434

3535
namespace Glpi\Form\Destination\CommonITILField;
3636

37-
use Glpi\DBAL\JsonFieldInterface;
38-
use Glpi\Form\AnswersSet;
39-
use InvalidArgumentException;
40-
use Override;
41-
42-
abstract class SLAField extends SLMField
43-
{
44-
#[Override]
45-
public function applyConfiguratedValueToInputUsingAnswers(
46-
JsonFieldInterface $config,
47-
array $input,
48-
AnswersSet $answers_set
49-
): array {
50-
if (!$config instanceof SLMFieldConfig) {
51-
throw new InvalidArgumentException("Unexpected config class");
52-
}
53-
54-
// Only one strategy is allowed
55-
$strategy = current($config->getStrategies());
56-
if ($strategy === false) {
57-
return $input;
58-
}
59-
60-
// Compute value according to strategy
61-
$slm_id = $strategy->getSLMID($config);
62-
63-
// Do not edit input if invalid value was found
64-
$slm = $this->getSLM();
65-
if (!$slm::getById($slm_id)) {
66-
return $input;
67-
}
68-
69-
$input[$slm::getFieldNames($this->getType())[1]] = $slm_id;
70-
71-
return $input;
72-
}
73-
}
37+
abstract class SLAField extends SLMField {}

tests/functional/Glpi/Form/Destination/CommonITILField/OLATTOFieldTest.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,11 @@ private function checkOLATTOFieldConfiguration(
239239
// Insert config
240240
$destinations = $form->getDestinations();
241241
$this->assertCount(1, $destinations);
242+
if ($expected_olas_tto_id !== 0 && countElementsInTable(OLA::getTable(), ['id' => $expected_olas_tto_id]) !== 1) {
243+
throw new \Exception("Expected OLA TTO with ID $expected_olas_tto_id not found in database. Wrong data preparation.");
244+
}
242245
$destination = current($destinations);
246+
243247
$this->updateItem(
244248
$destination::getType(),
245249
$destination->getId(),
@@ -262,8 +266,11 @@ private function checkOLATTOFieldConfiguration(
262266
$ticket = current($created_items);
263267

264268
// Check ola_id_tto field
265-
$ticket_tto_data = $ticket->getOlasTTOData()[0] ?? throw new \Exception('Ola TTO not found');
266-
$this->assertEquals($expected_olas_tto_id, $ticket_tto_data['olas_id']);
269+
$ticket_tto_id = $expected_olas_tto_id
270+
? ($ticket->getOlasTTOData()[0])['olas_id'] ?? throw new \Exception('Ola TTO not found')
271+
: 0
272+
;
273+
$this->assertEquals($expected_olas_tto_id, $ticket_tto_id, "The created ticket should have the expected OLA TTO ID");
267274

268275
// Return the created ticket to be able to check other fields
269276
return $ticket;

tests/functional/RuleTicketTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1638,8 +1638,6 @@ public function testTaskTemplateDoesNotReopenAClosedTicketWithRule()
16381638
*/
16391639
#[TestWith(['field' => 'time_to_resolve'])] // $field is both the rule action field and the ticket field.
16401640
#[TestWith(['field' => 'time_to_own'])]
1641-
#[TestWith(['field' => 'internal_time_to_resolve'])] // to remove when PR is merged - https://github.com/glpi-project/glpi/pull/19593
1642-
#[TestWith(['field' => 'internal_time_to_own'])] // to remove when PR is merged - https://github.com/glpi-project/glpi/pull/19593
16431641
public function testDeleteLevelAgreementValuesAction(string $field): void
16441642
{
16451643
$this->login();

0 commit comments

Comments
 (0)