ILIAS  release_8 Revision v8.24
ilCASSettingsTest.php
Go to the documentation of this file.
1<?php
2
3declare(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
21use PHPUnit\Framework\MockObject\MockObject;
22use PHPUnit\Framework\TestCase;
23
24class ilCASSettingsTest extends TestCase
25{
26 protected function setUp(): void
27 {
28 $this->dic = new Container();
29 $GLOBALS['DIC'] = $this->dic;
30 $this->setGlobalVariable(
31 'ilSetting',
32 $this->getMockBuilder(ilSetting::class)->disableOriginalConstructor()->getMock()
33 );
34 parent::setUp();
35 }
36
41 protected function setGlobalVariable(string $name, $value): void
42 {
43 global $DIC;
44
45 $GLOBALS[$name] = $value;
46
47 unset($DIC[$name]);
48 $DIC[$name] = static function ($c) use ($name) {
49 return $GLOBALS[$name];
50 };
51 }
52
53 public function testBasicSessionBehaviour(): void
54 {
55 global $DIC;
56
57 //setup some method calls
59 $setting = $DIC['ilSetting'];
60 $setting->method("get")->withConsecutive(
61 ['cas_server'],
62 ['cas_port'],
63 ['cas_uri'],
64 ['cas_active'],
65 ['cas_user_default_role'],
66 ['cas_login_instructions'],
67 ['cas_allow_local'],
68 ['cas_create_users']
69 )->
70 willReturnOnConsecutiveCalls(
71 'casserver',
72 "1",
73 'cas',
74 'true',
75 '0',
76 'casInstruction',
77 'false',
78 'true'
79 );
80
81 $casSettings = ilCASSettings::getInstance();
82 $this->assertEquals("casserver", $casSettings->getServer());
83 $this->assertTrue($casSettings->isActive());
84 }
85}
if(!defined('PATH_SEPARATOR')) $GLOBALS['_PEAR_default_error_mode']
Definition: PEAR.php:64
Customizing of pimple-DIC for ILIAS.
Definition: Container.php:32
setGlobalVariable(string $name, $value)
static getInstance()
Get singleton instance.
$c
Definition: cli.php:38
global $DIC
Definition: feed.php:28
if($format !==null) $name
Definition: metadata.php:247
$dic
Definition: result.php:32