ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
ilCASSettingsTest.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 
19 
23 
24 class ilCASSettingsTest extends TestCase
25 {
26  protected Container $dic;
27 
28  protected function setUp(): void
29  {
30  $this->dic = new Container();
31  $GLOBALS['DIC'] = $this->dic;
32  $this->setGlobalVariable(
33  'ilSetting',
34  $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->getMock()
35  );
36  parent::setUp();
37  }
38 
43  protected function setGlobalVariable(string $name, $value): void
44  {
45  global $DIC;
46 
47  $GLOBALS[$name] = $value;
48 
49  unset($DIC[$name]);
50  $DIC[$name] = static function ($c) use ($name) {
51  return $GLOBALS[$name];
52  };
53  }
54 
55  public function testBasicSessionBehaviour(): void
56  {
57  global $DIC;
58 
59  //setup some method calls
61  $setting = $DIC['ilSetting'];
62  $setting->method("get")->withConsecutive(
63  ['cas_server'],
64  ['cas_port'],
65  ['cas_uri'],
66  ['cas_active'],
67  ['cas_user_default_role'],
68  ['cas_login_instructions'],
69  ['cas_allow_local'],
70  ['cas_create_users']
71  )->
72  willReturnOnConsecutiveCalls(
73  'casserver',
74  "1",
75  'cas',
76  'true',
77  '0',
78  'casInstruction',
79  'false',
80  'true'
81  );
82 
83  $casSettings = ilCASSettings::getInstance();
84  $this->assertEquals("casserver", $casSettings->getServer());
85  $this->assertTrue($casSettings->isActive());
86  }
87 }
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
global $DIC
Definition: feed.php:28
setGlobalVariable(string $name, $value)
$GLOBALS["DIC"]
Definition: wac.php:31
static getInstance()
Get singleton instance.