19 declare(strict_types=1);
33 $assertIsString =
function ($actual):
void {
34 $this->assertIsString($actual,
'The actual return value is not a type of "string"');
37 $assertIsInteger =
function ($actual):
void {
38 $this->assertIsInt($actual,
'The actual return value is not a type of "int"');
41 $assertIsBool =
function ($actual):
void {
42 $this->assertIsBool($actual,
'The actual return value is not a type of "bool"');
46 [
'port', $assertIsInteger, 7373],
47 [
'protocol', $assertIsString,
'http://'],
48 [
'domain', $assertIsString,
'127.0.0.1'],
50 [
'authKey', $assertIsString,
'cfdf79fc-4133-4f3b-882f-5162a87dc465'],
51 [
'authSecret', $assertIsString,
'f8072a49-0488-411f-be0a-723a762700ba'],
52 [
'clientUrlEnabled', $assertIsBool,
true],
53 [
'clientUrl', $assertIsString,
'http://proxy.localhost'],
54 [
'iliasUrlEnabled', $assertIsBool,
true],
55 [
'iliasUrl', $assertIsString,
'http://proxy.localhost'],
57 [
'instance', $assertIsString,
'123456'],
67 $setter =
'set' . ucfirst($property);
68 $getter =
'get' . ucfirst(($property));
70 $this->assertTrue(method_exists($this->
settings, $setter), sprintf(
'The Setter "%s" does not exist', $setter));
71 $this->assertTrue(method_exists($this->
settings, $getter), sprintf(
'The Getter "%s" does not exist', $setter));
74 $actual = $this->
settings->$getter();
76 $this->assertSame($value, $actual, sprintf(
'The expected value "%s" is not equals to "%s"', $value, $actual));
78 $assertionCallback($actual);
83 $protocol =
'http://';
84 $domain =
'127.0.0.1';
86 $expected = sprintf(
'%s%s:%s', $protocol, $domain, $port);
88 $this->
settings->setProtocol($protocol);
92 $this->assertSame($expected, $this->
settings->getBaseURL());
97 $protocol =
'http://';
98 $domain =
'127.0.0.1';
99 $clientDomain =
'proxy.localhost';
101 $expected = sprintf(
'%s%s:%s', $protocol, $clientDomain, $port);
103 $this->
settings->setClientUrlEnabled(
true);
104 $this->
settings->setProtocol($protocol);
105 $this->
settings->setDomain($domain);
107 $this->
settings->setClientUrl(sprintf(
'%s:%s', $clientDomain, $port));
109 $this->assertSame($expected, $this->
settings->generateClientUrl());
114 $protocol =
'http://';
115 $domain =
'127.0.0.1';
116 $clientDomain =
'proxy.localhost';
118 $expected = sprintf(
'%s%s:%s', $protocol, $domain, $port);
120 $this->
settings->setClientUrlEnabled(
false);
121 $this->
settings->setDomain($domain);
123 $this->
settings->setProtocol($protocol);
124 $this->
settings->setClientUrl(sprintf(
'%s:%s', $clientDomain, $port));
126 $this->assertSame($expected, $this->
settings->generateClientUrl());
131 $protocol =
'http://';
132 $domain =
'127.0.0.1';
133 $iliasDomain =
'proxy.localhost';
135 $expected = sprintf(
'%s%s:%s', $protocol, $iliasDomain, $port);
137 $this->
settings->setIliasUrlEnabled(
true);
138 $this->
settings->setProtocol($protocol);
139 $this->
settings->setDomain($domain);
141 $this->
settings->setIliasUrl(sprintf(
'%s:%s', $iliasDomain, $port));
143 $this->assertSame($expected, $this->
settings->generateIliasUrl());
148 $protocol =
'http://';
149 $domain =
'127.0.0.1';
150 $iliasDomain =
'proxy.localhost';
152 $expected = sprintf(
'%s%s:%s', $protocol, $domain, $port);
154 $this->
settings->setIliasUrlEnabled(
false);
155 $this->
settings->setDomain($domain);
157 $this->
settings->setProtocol($protocol);
158 $this->
settings->setIliasUrl(sprintf(
'%s:%s', $iliasDomain, $port));
160 $this->assertSame($expected, $this->
settings->generateIliasUrl());
165 $protocol =
'http://';
166 $domain =
'127.0.0.1';
167 $iliasDomain =
'proxy.localhost:8080';
169 $action =
'Heartbeat';
170 $instance =
'master';
173 $this->
settings->setProtocol($protocol);
174 $this->
settings->setDomain($domain);
176 $this->
settings->setIliasUrl($iliasDomain);
177 $this->
settings->setInstance($instance);
179 $this->
settings->setIliasUrlEnabled(
false);
189 $this->assertSame($expected, $this->
settings->getURL($action));
191 $this->
settings->setIliasUrlEnabled(
false);
193 '%s%s:%s%s/%s/%s/%s',
202 $this->assertSame($expected, $this->
settings->getURL($action,
$scope));
204 $this->
settings->setIliasUrlEnabled(
true);
213 $this->assertSame($expected, $this->
settings->getURL($action));
215 $this->
settings->setIliasUrlEnabled(
true);
225 $this->assertSame($expected, $this->
settings->getURL($action,
$scope));
testGenerateClientUrlIfEnabled()
setterAndGettersProvider()
ilChatroomServerSettings $settings
testGenerateIliasUrlIfEnabled()
testGenerateIliasUrlIfDisabled()
Class ilChatroomServerSettings.
Class ilChatroomServerSettingsTest.
testGenerateClientUrlIfDisabled()
testSettersAndGetters(string $property, callable $assertionCallback, $value)