ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ilServicesAuthShibbolethTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
5 /******************************************************************************
6  *
7  * This file is part of ILIAS, a powerful learning management system.
8  *
9  * ILIAS is licensed with the GPL-3.0, you should have received a copy
10  * of said license along with the source code.
11  *
12  * If this is not the case or you just want to try ILIAS, you'll find
13  * us at:
14  * https://www.ilias.de
15  * https://github.com/ILIAS-eLearning
16  *
17  *****************************************************************************/
18 
21 
22 class ilServicesAuthShibbolethTest extends TestCase
23 {
25 
26  protected function setUp(): void
27  {
28  global $DIC;
29  $this->dic_backup = is_object($DIC) ? clone $DIC : $DIC;
30 
31  $DIC = new Container();
32  $DIC['ilDB'] = $this->createMock(ilDBInterface::class);
33  }
34 
35  protected function tearDown(): void
36  {
37  global $DIC;
38  $DIC = $this->dic_backup;
39  }
40 
41  public function testRuleAssignement(): void
42  {
43  $rule = new ilShibbolethRoleAssignmentRule();
44  $rule->setName('attribute_1');
45  $rule->setValue('value_1');
46 
47  $this->assertTrue($rule->matches(['attribute_1' => 'value_1']));
48  $this->assertFalse($rule->matches(['attribute_2' => 'value_2']));
49  }
50 
51  public function testWildcardRuleAssignement(): void
52  {
53  $rule = new ilShibbolethRoleAssignmentRule();
54  $rule->setName('attribute_1');
55  $rule->setValue('value_*');
56 
57  $this->assertTrue($rule->matches(['attribute_1' => 'value_1']));
58  $this->assertTrue($rule->matches(['attribute_1' => 'value_2']));
59  $this->assertFalse($rule->matches(['attribute_2' => 'value_2']));
60  }
61 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:31
global $DIC
Definition: feed.php:28