|
| 1 | +<?php |
| 2 | + |
| 3 | +/** |
| 4 | + * ------------------------------------------------------------------------- |
| 5 | + * Escalade plugin for GLPI |
| 6 | + * ------------------------------------------------------------------------- |
| 7 | + * |
| 8 | + * LICENSE |
| 9 | + * |
| 10 | + * This file is part of Escalade. |
| 11 | + * |
| 12 | + * Escalade is free software; you can redistribute it and/or modify |
| 13 | + * it under the terms of the GNU General Public License as published by |
| 14 | + * the Free Software Foundation; either version 2 of the License, or |
| 15 | + * (at your option) any later version. |
| 16 | + * |
| 17 | + * Escalade is distributed in the hope that it will be useful, |
| 18 | + * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 19 | + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 20 | + * GNU General Public License for more details. |
| 21 | + * |
| 22 | + * You should have received a copy of the GNU General Public License |
| 23 | + * along with Escalade. If not, see <http://www.gnu.org/licenses/>. |
| 24 | + * ------------------------------------------------------------------------- |
| 25 | + * @copyright Copyright (C) 2015-2023 by Escalade plugin team. |
| 26 | + * @license GPLv2 https://www.gnu.org/licenses/gpl-2.0.html |
| 27 | + * @link https://github.com/pluginsGLPI/escalade |
| 28 | + * ------------------------------------------------------------------------- |
| 29 | + */ |
| 30 | + |
| 31 | +namespace GlpiPlugin\Escalade\Tests\Units; |
| 32 | + |
| 33 | +use GlpiPlugin\Escalade\Tests\EscaladeTestCase; |
| 34 | +use PluginEscaladeConfig; |
| 35 | + |
| 36 | +final class UserEscalationTest extends EscaladeTestCase |
| 37 | +{ |
| 38 | + public function testTaskGroupEscalation() |
| 39 | + { |
| 40 | + $this->login(); |
| 41 | + |
| 42 | + $config = new PluginEscaladeConfig(); |
| 43 | + $conf = reset($config->find()); |
| 44 | + $config->getFromDB($conf['id']); |
| 45 | + $this->assertGreaterThan(0, $conf['id']); |
| 46 | + $this->assertTrue($config->update([ |
| 47 | + 'remove_tech' => 1 |
| 48 | + ] + $conf)); |
| 49 | + |
| 50 | + $user1 = $user2 = new \User(); |
| 51 | + $user1->getFromDBbyName('glpi'); |
| 52 | + $user2->getFromDBbyName('tech'); |
| 53 | + |
| 54 | + $ticket = new \Ticket(); |
| 55 | + $t_id = $ticket->add([ |
| 56 | + 'name' => 'Task User change Escalation Test', |
| 57 | + 'content' => '', |
| 58 | + '_actors' => [ |
| 59 | + 'assign' => [ |
| 60 | + [ |
| 61 | + 'items_id' => $user1->getID(), |
| 62 | + 'itemtype' => 'User' |
| 63 | + ] |
| 64 | + ], |
| 65 | + ] |
| 66 | + ]); |
| 67 | + |
| 68 | + $ticket_user = new \Ticket_User(); |
| 69 | + $this->assertEquals(1, count($ticket_user->find(['tickets_id' => $t_id]))); |
| 70 | + |
| 71 | + // Update ticket with just one group |
| 72 | + $this->assertTrue($ticket->update( |
| 73 | + [ |
| 74 | + 'id' => $t_id, |
| 75 | + '_actors' => [ |
| 76 | + 'assign' => [ |
| 77 | + [ |
| 78 | + 'items_id' => $user1->getID(), |
| 79 | + 'itemtype' => 'User' |
| 80 | + ], |
| 81 | + [ |
| 82 | + 'items_id' => $user2->getID(), |
| 83 | + 'itemtype' => 'User' |
| 84 | + ] |
| 85 | + ], |
| 86 | + ], |
| 87 | + ] |
| 88 | + )); |
| 89 | + |
| 90 | + $ticket_user = new \Ticket_User(); |
| 91 | + $user_linked = $ticket_user->find(['tickets_id' => $t_id]); |
| 92 | + $this->assertEquals(1, count($user_linked)); |
| 93 | + reset($user_linked); |
| 94 | + $this->assertEquals($user_linked['users_id'], $user1->getID()); |
| 95 | + } |
| 96 | +} |
0 commit comments