diff --git a/src/Glpi/Form/QuestionType/QuestionTypeItemDropdown.php b/src/Glpi/Form/QuestionType/QuestionTypeItemDropdown.php index 8c10fdb5099..2e1c32b389d 100644 --- a/src/Glpi/Form/QuestionType/QuestionTypeItemDropdown.php +++ b/src/Glpi/Form/QuestionType/QuestionTypeItemDropdown.php @@ -40,8 +40,11 @@ use Glpi\Form\Question; use InvalidArgumentException; use ITILCategory; +use OLA; use Override; use Session; +use SLA; +use SLM; use function Safe\json_decode; @@ -90,6 +93,11 @@ public function getAllowedItemtypes(): array $value = $key; }); + $dropdown_itemtypes[SLM::getTypeName(Session::getPluralNumber())] = [ + SLA::getType() => SLA::getType(), + OLA::getType() => OLA::getType(), + ]; + return $dropdown_itemtypes; } diff --git a/tests/functional/Glpi/Form/Migration/FormMigrationTest.php b/tests/functional/Glpi/Form/Migration/FormMigrationTest.php index 6ebc1e8a52d..ac797ffbaae 100644 --- a/tests/functional/Glpi/Form/Migration/FormMigrationTest.php +++ b/tests/functional/Glpi/Form/Migration/FormMigrationTest.php @@ -3981,4 +3981,35 @@ public function testFormMigrationActorsWithEmptyDefaultValue(): void // Assert: migration should be done without error $this->assertTrue($result->isFullyProcessed()); } + + public function testFormMigrationDropdownQuestionWithSLAItemtype(): void + { + global $DB; + + // Arrange: create a form with a dropdown question with SLA itemtype + $this->createSimpleFormcreatorForm('Dropdown with SLA itemtype', [ + [ + 'name' => 'SLA dropdown', + 'fieldtype' => 'dropdown', + 'itemtype' => 'SLA', + 'values' => json_encode([ + 'show_service_level_types' => '0', + 'entity_restrict' => '2' + ]), + ], + ]); + + // Act: execute migration + $migration = new FormMigration($DB, FormAccessControlManager::getInstance()); + $result = $migration->execute(); + + // Assert: migration should be done without error and the question should be migrated with the correct itemtype + $this->assertTrue($result->isFullyProcessed()); + $question = getItemByTypeName(Question::class, 'SLA dropdown'); + $config = $question->getExtraDataConfig(); + if (!$config instanceof QuestionTypeItemDropdownExtraDataConfig) { + throw new LogicException(); + } + $this->assertEquals('SLA', $config->getItemtype()); + } }