Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(forms): Add export and import functionality for destinations #18358

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,9 @@
use CommonITILActor;
use DbTestCase;
use Glpi\Form\AnswersHandler\AnswersHandler;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldConfig;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldStrategy;
use Glpi\Form\Destination\CommonITILField\AssigneeField;
use Glpi\Form\Destination\CommonITILField\AssigneeFieldConfig;
use Glpi\Form\Destination\FormDestinationTicket;
use Glpi\Form\Form;
use Glpi\Form\QuestionType\QuestionTypeActorsExtraDataConfig;
Expand All @@ -61,7 +61,7 @@ final class AssigneeFieldTest extends DbTestCase
public function testAssigneeFromTemplate(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$from_template_config = new ITILActorFieldConfig(
$from_template_config = new AssigneeFieldConfig(
ITILActorFieldStrategy::FROM_TEMPLATE
);

Expand Down Expand Up @@ -123,7 +123,7 @@ public function testAssigneeFromTemplate(): void
public function testAssigneeFormFiller(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$form_filler_config = new ITILActorFieldConfig(
$form_filler_config = new AssigneeFieldConfig(
ITILActorFieldStrategy::FORM_FILLER
);

Expand Down Expand Up @@ -160,7 +160,7 @@ public function testSpecificActors(): void
// Specific value: User
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new AssigneeFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_VALUES,
specific_itilactors_ids: [
User::getForeignKeyField() . '-' . $user->getID()
Expand All @@ -173,7 +173,7 @@ public function testSpecificActors(): void
// Specific value: User and Group
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new AssigneeFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_VALUES,
specific_itilactors_ids: [
User::getForeignKeyField() . '-' . $user->getID(),
Expand All @@ -187,7 +187,7 @@ public function testSpecificActors(): void
// Specific value: User, Group and Supplier
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new AssigneeFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_VALUES,
specific_itilactors_ids: [
User::getForeignKeyField() . '-' . $user->getID(),
Expand Down Expand Up @@ -224,7 +224,7 @@ public function testActorsFromSpecificQuestions(): void
// Using answer from first question
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new AssigneeFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_ANSWERS,
specific_question_ids: [$this->getQuestionId($form, "Assignee 1")]
),
Expand All @@ -244,7 +244,7 @@ public function testActorsFromSpecificQuestions(): void
// Using answer from first and second question
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new AssigneeFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_ANSWERS,
specific_question_ids: [
$this->getQuestionId($form, "Assignee 1"),
Expand All @@ -271,7 +271,7 @@ public function testActorsFromLastValidQuestion(): void
$this->login();

$form = $this->createAndGetFormWithMultipleActorsQuestions();
$last_valid_answer_config = new ITILActorFieldConfig(
$last_valid_answer_config = new AssigneeFieldConfig(
ITILActorFieldStrategy::LAST_VALID_ANSWER
);

Expand Down Expand Up @@ -356,7 +356,7 @@ public function testActorsFromLastValidQuestion(): void

private function sendFormAndAssertTicketActors(
Form $form,
ITILActorFieldConfig $config,
AssigneeFieldConfig $config,
array $answers,
array $expected_actors_ids,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use DbTestCase;
use Glpi\Form\AnswersHandler\AnswersHandler;
use Glpi\Form\Destination\CommonITILField\OLATTOField;
use Glpi\Form\Destination\CommonITILField\SLMFieldConfig;
use Glpi\Form\Destination\CommonITILField\OLATTOFieldConfig;
use Glpi\Form\Destination\CommonITILField\SLMFieldStrategy;
use Glpi\Form\Destination\FormDestinationTicket;
use Glpi\Form\Form;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function testDefaultTemplateWithPredefinedField(): void

$this->checkOLATTOFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new OLATTOFieldConfig(
strategy: SLMFieldStrategy::FROM_TEMPLATE,
),
expected_olas_tto_id: $created_ola_tto->getID()
Expand All @@ -102,7 +102,7 @@ public function testSpecificOLATTO(): void

$this->checkOLATTOFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new OLATTOFieldConfig(
strategy: SLMFieldStrategy::SPECIFIC_VALUE,
specific_slm_id: $created_ola_tto->getID()
),
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testSpecificOLATTOWithDefaultTemplateWithPredefinedField(): void

$this->checkOLATTOFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new OLATTOFieldConfig(
strategy: SLMFieldStrategy::SPECIFIC_VALUE,
specific_slm_id: $created_ola_tto->getID()
),
Expand All @@ -156,7 +156,7 @@ public function testSpecificOLATTOWithDefaultTemplateWithPredefinedField(): void

private function checkOLATTOFieldConfiguration(
Form $form,
SLMFieldConfig $config,
OLATTOFieldConfig $config,
int $expected_olas_tto_id
): Ticket {
// Insert config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use DbTestCase;
use Glpi\Form\AnswersHandler\AnswersHandler;
use Glpi\Form\Destination\CommonITILField\OLATTRField;
use Glpi\Form\Destination\CommonITILField\SLMFieldConfig;
use Glpi\Form\Destination\CommonITILField\OLATTRFieldConfig;
use Glpi\Form\Destination\CommonITILField\SLMFieldStrategy;
use Glpi\Form\Destination\FormDestinationTicket;
use Glpi\Form\Form;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function testDefaultTemplateWithPredefinedField(): void

$this->checkOLATTRFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new OLATTRFieldConfig(
strategy: SLMFieldStrategy::FROM_TEMPLATE,
),
expected_olas_ttr_id: $created_ola_ttr->getID()
Expand All @@ -102,7 +102,7 @@ public function testSpecificOLATTR(): void

$this->checkOLATTRFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new OLATTRFieldConfig(
strategy: SLMFieldStrategy::SPECIFIC_VALUE,
specific_slm_id: $created_ola_ttr->getID()
),
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testSpecificOLATTRWithDefaultTemplateWithPredefinedField(): void

$this->checkOLATTRFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new OLATTRFieldConfig(
strategy: SLMFieldStrategy::SPECIFIC_VALUE,
specific_slm_id: $created_ola_ttr->getID()
),
Expand All @@ -156,7 +156,7 @@ public function testSpecificOLATTRWithDefaultTemplateWithPredefinedField(): void

private function checkOLATTRFieldConfiguration(
Form $form,
SLMFieldConfig $config,
OLATTRFieldConfig $config,
int $expected_olas_ttr_id
): Ticket {
// Insert config
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use CommonITILActor;
use DbTestCase;
use Glpi\Form\AnswersHandler\AnswersHandler;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldConfig;
use Glpi\Form\Destination\CommonITILField\ObserverFieldConfig;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldStrategy;
use Glpi\Form\Destination\CommonITILField\ObserverField;
use Glpi\Form\Destination\FormDestinationTicket;
Expand All @@ -60,7 +60,7 @@ final class ObserverFieldTest extends DbTestCase
public function testObserverFromTemplate(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$from_template_config = new ITILActorFieldConfig(
$from_template_config = new ObserverFieldConfig(
ITILActorFieldStrategy::FROM_TEMPLATE
);

Expand Down Expand Up @@ -105,7 +105,7 @@ public function testObserverFromTemplate(): void
public function testObserverFormFiller(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$form_filler_config = new ITILActorFieldConfig(
$form_filler_config = new ObserverFieldConfig(
ITILActorFieldStrategy::FORM_FILLER
);

Expand Down Expand Up @@ -139,7 +139,7 @@ public function testSpecificActors(): void
// Specific value: User
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new ObserverFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_VALUES,
specific_itilactors_ids: [
User::getForeignKeyField() . '-' . $user->getID()
Expand All @@ -152,7 +152,7 @@ public function testSpecificActors(): void
// Specific value: User and Group
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new ObserverFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_VALUES,
specific_itilactors_ids: [
User::getForeignKeyField() . '-' . $user->getID(),
Expand All @@ -175,7 +175,7 @@ public function testActorsFromSpecificQuestions(): void
// Using answer from first question
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new ObserverFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_ANSWERS,
specific_question_ids: [$this->getQuestionId($form, "Observer 1")]
),
Expand All @@ -194,7 +194,7 @@ public function testActorsFromSpecificQuestions(): void
// Using answer from first and second question
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new ObserverFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_ANSWERS,
specific_question_ids: [
$this->getQuestionId($form, "Observer 1"),
Expand All @@ -217,7 +217,7 @@ public function testActorsFromSpecificQuestions(): void
public function testActorsFromLastValidQuestion(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$last_valid_answer_config = new ITILActorFieldConfig(
$last_valid_answer_config = new ObserverFieldConfig(
ITILActorFieldStrategy::LAST_VALID_ANSWER
);

Expand Down Expand Up @@ -290,7 +290,7 @@ public function testActorsFromLastValidQuestion(): void

private function sendFormAndAssertTicketActors(
Form $form,
ITILActorFieldConfig $config,
ObserverFieldConfig $config,
array $answers,
array $expected_actors_ids,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use CommonITILActor;
use DbTestCase;
use Glpi\Form\AnswersHandler\AnswersHandler;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldConfig;
use Glpi\Form\Destination\CommonITILField\RequesterFieldConfig;
use Glpi\Form\Destination\CommonITILField\ITILActorFieldStrategy;
use Glpi\Form\Destination\CommonITILField\RequesterField;
use Glpi\Form\Destination\FormDestinationTicket;
Expand All @@ -60,7 +60,7 @@ final class RequesterFieldTest extends DbTestCase
public function testRequesterFromTemplate(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$from_template_config = new ITILActorFieldConfig(
$from_template_config = new RequesterFieldConfig(
ITILActorFieldStrategy::FROM_TEMPLATE
);

Expand Down Expand Up @@ -105,7 +105,7 @@ public function testRequesterFromTemplate(): void
public function testRequesterFormFiller(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$form_filler_config = new ITILActorFieldConfig(
$form_filler_config = new RequesterFieldConfig(
ITILActorFieldStrategy::FORM_FILLER
);

Expand Down Expand Up @@ -139,7 +139,7 @@ public function testSpecificActors(): void
// Specific value: User
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new RequesterFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_VALUES,
specific_itilactors_ids: [
User::getForeignKeyField() . '-' . $user->getID()
Expand All @@ -152,7 +152,7 @@ public function testSpecificActors(): void
// Specific value: User and Group
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new RequesterFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_VALUES,
specific_itilactors_ids: [
User::getForeignKeyField() . '-' . $user->getID(),
Expand All @@ -175,7 +175,7 @@ public function testActorsFromSpecificQuestions(): void
// Using answer from first question
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new RequesterFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_ANSWERS,
specific_question_ids: [$this->getQuestionId($form, "Requester 1")]
),
Expand All @@ -194,7 +194,7 @@ public function testActorsFromSpecificQuestions(): void
// Using answer from first and second question
$this->sendFormAndAssertTicketActors(
form: $form,
config: new ITILActorFieldConfig(
config: new RequesterFieldConfig(
strategy: ITILActorFieldStrategy::SPECIFIC_ANSWERS,
specific_question_ids: [
$this->getQuestionId($form, "Requester 1"),
Expand All @@ -217,7 +217,7 @@ public function testActorsFromSpecificQuestions(): void
public function testActorsFromLastValidQuestion(): void
{
$form = $this->createAndGetFormWithMultipleActorsQuestions();
$last_valid_answer_config = new ITILActorFieldConfig(
$last_valid_answer_config = new RequesterFieldConfig(
ITILActorFieldStrategy::LAST_VALID_ANSWER
);

Expand Down Expand Up @@ -290,7 +290,7 @@ public function testActorsFromLastValidQuestion(): void

private function sendFormAndAssertTicketActors(
Form $form,
ITILActorFieldConfig $config,
RequesterFieldConfig $config,
array $answers,
array $expected_actors_ids,
): void {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
use DbTestCase;
use Glpi\Form\AnswersHandler\AnswersHandler;
use Glpi\Form\Destination\CommonITILField\SLATTOField;
use Glpi\Form\Destination\CommonITILField\SLMFieldConfig;
use Glpi\Form\Destination\CommonITILField\SLATTOFieldConfig;
use Glpi\Form\Destination\CommonITILField\SLMFieldStrategy;
use Glpi\Form\Destination\FormDestinationTicket;
use Glpi\Form\Form;
Expand Down Expand Up @@ -80,7 +80,7 @@ public function testDefaultTemplateWithPredefinedField(): void

$this->checkSLATTOFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new SLATTOFieldConfig(
strategy: SLMFieldStrategy::FROM_TEMPLATE,
),
expected_slas_tto_id: $created_sla_tto->getID()
Expand All @@ -102,7 +102,7 @@ public function testSpecificSLATTO(): void

$this->checkSLATTOFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new SLATTOFieldConfig(
strategy: SLMFieldStrategy::SPECIFIC_VALUE,
specific_slm_id: $created_sla_tto->getID()
),
Expand Down Expand Up @@ -146,7 +146,7 @@ public function testSpecificSLATTOWithDefaultTemplateWithPredefinedField(): void

$this->checkSLATTOFieldConfiguration(
form: $this->createAndGetFormWithTicketDestination(),
config: new SLMFieldConfig(
config: new SLATTOFieldConfig(
strategy: SLMFieldStrategy::SPECIFIC_VALUE,
specific_slm_id: $created_sla_tto->getID()
),
Expand All @@ -156,7 +156,7 @@ public function testSpecificSLATTOWithDefaultTemplateWithPredefinedField(): void

private function checkSLATTOFieldConfiguration(
Form $form,
SLMFieldConfig $config,
SLATTOFieldConfig $config,
int $expected_slas_tto_id
): Ticket {
// Insert config
Expand Down
Loading
Loading