4040use Group_User ;
4141use Item_Ticket ;
4242use PluginFormcreatorAnswer ;
43+ use PluginFormcreatorFormanswerValidation ;
4344use PluginFormcreatorCondition ;
4445use PluginFormcreatorForm ;
4546use PluginFormcreatorFields ;
@@ -492,14 +493,19 @@ function() use ($instance) {
492493 public function testPost_UpdateItem () {
493494 global $ DB ;
494495
496+ $ login = $ this ->getUniqueString ();
497+ $ user = $ this ->getUser ($ login , 'p@ssw0rd ' );
498+ $ validatorId = $ user ->getID ();
499+
495500 $ question = $ this ->getQuestion (['fieldtype ' => 'text ' ]);
496501 $ form = new PluginFormcreatorForm ;
497- $ form = \ PluginFormcreatorForm::getByItem ($ question );
502+ $ form = PluginFormcreatorForm::getByItem ($ question );
498503 $ formValidator = new PluginFormcreatorForm_Validator ();
499504 $ formValidator ->add ([
500505 'plugin_formcreator_forms_id ' => $ form ->getID (),
501506 'itemtype ' => User::class,
502- 'items_id ' => Session::getLoginUserID ()
507+ 'items_id ' => $ validatorId ,
508+ 'level ' => 1 ,
503509 ]);
504510 $ this ->boolean ($ formValidator ->isNewItem ())->isFalse ();
505511
@@ -508,10 +514,11 @@ public function testPost_UpdateItem() {
508514 */
509515
510516 // Setup test
517+
511518 $ instance = $ this ->newTestedInstance ();
512519 $ formAnswerId = $ instance ->add ([
513520 'plugin_formcreator_forms_id ' => $ form ->getID (),
514- 'formcreator_validator ' => Session::getLoginUserID (),
521+ 'formcreator_validator ' => User::class . ' _ ' . Session::getLoginUserID (),
515522 'formcreator_field_ ' . $ question ->getID () => 'foo ' ,
516523 ]);
517524 $ this ->boolean ($ instance ->isNewItem ())->isFalse ();
@@ -524,14 +531,15 @@ public function testPost_UpdateItem() {
524531 $ this ->string ($ answer ->fields ['answer ' ])->isEqualTo ('foo ' );
525532
526533 // Check the answer is kept when accepting without edition
534+ $ this ->boolean ($ this ->login ($ login , 'p@ssw0rd ' ))->isTrue ();
527535 $ instance = $ this ->newTestedInstance ();
528536 $ instance ->getFromDB ($ formAnswerId );
529537 $ this ->boolean ($ instance ->isNewItem ())->isFalse ();
530- $ testedClassName = $ this ->getTestedClassName ();
538+ // $testedClassName = $this->getTestedClassName();
531539 $ input = [
532540 'plugin_formcreator_forms_id ' => $ form ->getID (),
533541 'accept_formanswer ' => 'accept ' ,
534- 'status ' => $ testedClassName ::STATUS_ACCEPTED ,
542+ // 'status' => $testedClassName::STATUS_ACCEPTED,
535543 ];
536544 $ input = $ instance ->prepareInputForUpdate ($ input );
537545 $ this ->array ($ input )->size ->isGreaterThan (0 );
@@ -551,7 +559,7 @@ public function testPost_UpdateItem() {
551559
552560 // Reset validation status
553561 $ DB ->update (
554- ' glpi_plugin_formcreator_formanswervalidations ' ,
562+ PluginFormcreatorFormanswerValidation:: getTable () ,
555563 [
556564 'status ' => PluginFormcreatorForm_Validator::VALIDATION_STATUS_WAITING ,
557565 ],
@@ -567,7 +575,7 @@ public function testPost_UpdateItem() {
567575 'id ' => $ instance ->getID (),
568576 'plugin_formcreator_forms_id ' => $ form ->getID (),
569577 'accept_formanswer ' => 'accept ' ,
570- 'status ' => $ testedClassName ::STATUS_ACCEPTED ,
578+ // 'status' => $testedClassName::STATUS_ACCEPTED,
571579 'formcreator_field_ ' . $ question ->getID () => 'bar ' ,
572580 ];
573581 $ input = $ instance ->prepareInputForUpdate ($ input );
0 commit comments