|
32 | 32 | namespace tests\units; |
33 | 33 | use GlpiPlugin\Formcreator\Tests\CommonTestCase; |
34 | 34 | use PluginFormcreatorFormAnswer; |
| 35 | +use PluginFormcreatorTargetTicket; |
| 36 | +use PluginFormcreatorTarget_Actor; |
| 37 | +use CommonITILActor; |
35 | 38 | use RuleAction; |
36 | 39 | use User; |
37 | 40 | use Rule; |
@@ -153,7 +156,7 @@ public function providerGetsyncIssuesRequest_simpleFormanswers() { |
153 | 156 | public function providerGetSyncIssuesRequest_formAnswerWithOneTicket() { |
154 | 157 | // case 1 |
155 | 158 | $form = $this->getForm(); |
156 | | - $targetTicket1 = new \PluginFormcreatorTargetTicket(); |
| 159 | + $targetTicket1 = new PluginFormcreatorTargetTicket(); |
157 | 160 | $targetTicket1->add([ |
158 | 161 | 'plugin_formcreator_forms_id' => $form->getID(), |
159 | 162 | 'name' => 'foo', |
@@ -207,7 +210,7 @@ public function providerGetSyncIssuesRequest_formAnswerWithOneTicket() { |
207 | 210 | $this->boolean($formAnswer->isNewItem())->isFalse(); |
208 | 211 | $formAnswer->getFromDB($formAnswer->getID()); |
209 | 212 | $ticket2 = array_shift($formAnswer->targetList); |
210 | | - $this->object($ticket)->isInstanceOf(Ticket::getType()); |
| 213 | + $this->object($ticket2)->isInstanceOf(Ticket::getType()); |
211 | 214 |
|
212 | 215 | return [ |
213 | 216 | 'formAnswerWithOneTicket' => [ |
@@ -241,13 +244,13 @@ public function providerGetSyncIssuesRequest_formAnswerWithOneTicket() { |
241 | 244 |
|
242 | 245 | public function providerGetSyncIssuesRequest_formAnswerWithSeveralTickets() { |
243 | 246 | $form = $this->getForm(); |
244 | | - $targetTicket1 = new \PluginFormcreatorTargetTicket(); |
| 247 | + $targetTicket1 = new PluginFormcreatorTargetTicket(); |
245 | 248 | $targetTicket1->add([ |
246 | 249 | 'plugin_formcreator_forms_id' => $form->getID(), |
247 | 250 | 'name' => 'foo', |
248 | 251 | ]); |
249 | 252 | $this->boolean($targetTicket1->isNewItem())->isFalse(); |
250 | | - $targetTicket2 = new \PluginFormcreatorTargetTicket(); |
| 253 | + $targetTicket2 = new PluginFormcreatorTargetTicket(); |
251 | 254 | $targetTicket2->add([ |
252 | 255 | 'plugin_formcreator_forms_id' => $form->getID(), |
253 | 256 | 'name' => 'bar', |
@@ -277,42 +280,6 @@ public function providerGetSyncIssuesRequest_formAnswerWithSeveralTickets() { |
277 | 280 | ]; |
278 | 281 | } |
279 | 282 |
|
280 | | - public function providerGetSyncIssuesRequest_formAnswerWithOneTickets() { |
281 | | - $form = $this->getForm(); |
282 | | - $targetTicket1 = new \PluginFormcreatorTargetTicket(); |
283 | | - $targetTicket1->add([ |
284 | | - 'plugin_formcreator_forms_id' => $form->getID(), |
285 | | - 'name' => 'foo', |
286 | | - ]); |
287 | | - $this->boolean($targetTicket1->isNewItem())->isFalse(); |
288 | | - |
289 | | - $formAnswer = new PluginFormcreatorFormAnswer(); |
290 | | - $formAnswer->add([ |
291 | | - 'plugin_formcreator_forms_id' => $form->getID(), |
292 | | - ]); |
293 | | - $this->boolean($formAnswer->isNewItem())->isFalse(); |
294 | | - $formAnswer->getFromDB($formAnswer->getID()); |
295 | | - |
296 | | - /** @var Ticket */ |
297 | | - $ticket = array_pop($formAnswer->targetList); |
298 | | - $this->object($ticket)->isInstanceOf(Ticket::class); |
299 | | - return [ |
300 | | - 'formAnswerWithOneTickets' => [ |
301 | | - 'item' => $formAnswer, |
302 | | - 'expected' => [ |
303 | | - 'itemtype' => PluginFormcreatorFormAnswer::getType(), |
304 | | - 'items_id' => $ticket->getID(), |
305 | | - 'display_id' => 't_' . $ticket->getID(), |
306 | | - 'name' => $formAnswer->fields['name'], |
307 | | - 'status' => $formAnswer->fields['status'], |
308 | | - 'requester_id' => $formAnswer->fields['requester_id'], |
309 | | - 'date_creation' => $formAnswer->fields['request_date'], |
310 | | - 'date_mod' => $formAnswer->fields['request_date'], |
311 | | - ], |
312 | | - ], |
313 | | - ]; |
314 | | - } |
315 | | - |
316 | 283 | public function providerGetSyncIssuesRequest_formanswerUnderValidation() { |
317 | 284 | $form = $this->getForm([ |
318 | 285 | 'validation_required' => PluginFormcreatorForm::VALIDATION_USER, |
@@ -466,29 +433,29 @@ public function providerGetsyncIssuesRequest_validatedTicket() { |
466 | 433 |
|
467 | 434 | public function providerGetSyncIssuesRequest_FormAnswerWithSeveralRequesters() { |
468 | 435 | $form = $this->getForm(); |
469 | | - $targetTicket1 = new \PluginFormcreatorTargetTicket(); |
| 436 | + $targetTicket1 = new PluginFormcreatorTargetTicket(); |
470 | 437 | $targetTicket1->add([ |
471 | 438 | 'plugin_formcreator_forms_id' => $form->getID(), |
472 | 439 | 'name' => 'foo', |
473 | 440 | ]); |
474 | 441 | $this->boolean($targetTicket1->isNewItem())->isFalse(); |
475 | 442 |
|
476 | | - $actor1 = new \PluginFormcreatorTarget_Actor(); |
| 443 | + $actor1 = new PluginFormcreatorTarget_Actor(); |
477 | 444 | $actor1->add([ |
478 | 445 | 'itemtype' => $targetTicket1->getType(), |
479 | 446 | 'items_id' => $targetTicket1->getID(), |
480 | | - 'actor_role' => \PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON, |
481 | | - 'actor_type' => \CommonITILActor::REQUESTER, |
| 447 | + 'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON, |
| 448 | + 'actor_type' => CommonITILActor::REQUESTER, |
482 | 449 | 'actor_value' => 3, |
483 | 450 | 'use_notification' => '1', |
484 | 451 | ]); |
485 | 452 | $this->boolean($actor1->isNewItem())->isFalse(); |
486 | | - $actor2 = new \PluginFormcreatorTarget_Actor(); |
| 453 | + $actor2 = new PluginFormcreatorTarget_Actor(); |
487 | 454 | $actor2->add([ |
488 | 455 | 'itemtype' => $targetTicket1->getType(), |
489 | 456 | 'items_id' => $targetTicket1->getID(), |
490 | | - 'actor_role' => \PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON, |
491 | | - 'actor_type' => \CommonITILActor::REQUESTER, |
| 457 | + 'actor_role' => PluginFormcreatorTarget_Actor::ACTOR_TYPE_PERSON, |
| 458 | + 'actor_type' => CommonITILActor::REQUESTER, |
492 | 459 | 'actor_value' => 5, |
493 | 460 | 'use_notification' => '1', |
494 | 461 | ]); |
|
0 commit comments