Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions src/Glpi/Form/QuestionType/QuestionTypeItemDropdown.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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;
}

Expand Down
31 changes: 31 additions & 0 deletions tests/functional/Glpi/Form/Migration/FormMigrationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Copy link
Copy Markdown
Contributor

@SebSept SebSept Apr 17, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a small explanation in LogicException message can be usefull to spot the issue when it happen.

}
$this->assertEquals('SLA', $config->getItemtype());
}
}
Loading