ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilCASSettingsTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
24 
26 {
27  protected Container $dic;
28 
29  protected function setUp(): void
30  {
31  $this->dic = new Container();
32  $GLOBALS['DIC'] = $this->dic;
33  $this->setGlobalVariable(
34  'ilSetting',
35  $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->getMock()
36  );
37  parent::setUp();
38  }
39 
44  protected function setGlobalVariable(string $name, $value): void
45  {
46  global $DIC;
47 
48  $GLOBALS[$name] = $value;
49 
50  unset($DIC[$name]);
51  $DIC[$name] = static function ($c) use ($name) {
52  return $GLOBALS[$name];
53  };
54  }
55 
56  public function testBasicSessionBehaviour(): void
57  {
58  global $DIC;
59 
60  //setup some method calls
62  $setting = $DIC['ilSetting'];
63  $consecutive_returns = [
64  'cas_server' => 'casserver',
65  'cas_port' => '1',
66  'cas_uri' => 'cas',
67  'cas_active' => 'true',
68  'cas_user_default_role' => '0',
69  'cas_login_instructions' => 'casInstruction',
70  'cas_allow_local' => 'false',
71  'cas_create_users' => 'true',
72  ];
73  $setting->method("get")
74  ->willReturnCallback(fn($k) => $consecutive_returns[$k]);
75 
76  $casSettings = ilCASSettings::getInstance();
77  $this->assertEquals("casserver", $casSettings->getServer());
78  $this->assertTrue($casSettings->isActive());
79  }
80 }
$c
Definition: deliver.php:25
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:35
setGlobalVariable(string $name, $value)
$GLOBALS["DIC"]
Definition: wac.php:53
global $DIC
Definition: shib_login.php:22
static getInstance()
Get singleton instance.