Skip to content

Commit 8babae9

Browse files
committed
Add units tests
1 parent 7178b11 commit 8babae9

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

tests/units/UserEscalationTest.php

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
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+
35+
final class UserEscalationTest extends EscaladeTestCase
36+
{
37+
public function testTaskGroupEscalation()
38+
{
39+
$user1 = $user2 = $user3 = new \User();
40+
$user1->getFromDBbyName('glpi');
41+
$user2->getFromDBbyName('tech');
42+
$user3->getFromDBbyName('normal');
43+
44+
$ticket = new \Ticket();
45+
$ticket->add([
46+
'name' => 'Task User change Escalation Test',
47+
'content' => '',
48+
'_actors' => [
49+
'assign' => [
50+
[
51+
'items_id' => $user3->getID(),
52+
'itemtype' => 'User'
53+
]
54+
],
55+
]
56+
]);
57+
58+
$ticket_user = new \Ticket_User();
59+
$this->assertEquals(1, count($ticket_user->find(['tickets_id' => $ticket->getID()])));
60+
61+
// Update ticket with just one group
62+
$this->assertTrue($ticket->update(
63+
[
64+
'id' => $ticket->getID(),
65+
'_actors' => [
66+
'assign' => [
67+
[
68+
'items_id' => $user1->getID(),
69+
'itemtype' => 'User'
70+
],
71+
[
72+
'items_id' => $user2->getID(),
73+
'itemtype' => 'User'
74+
],
75+
],
76+
],
77+
]
78+
));
79+
80+
$this->assertEquals(2, count($ticket_user->find(['tickets_id' => $ticket->getID()])));
81+
}
82+
}

0 commit comments

Comments
 (0)