19 declare(strict_types=1);
33 $assertIsString =
static function ($actual):
void {
34 self::assertIsString($actual,
'The actual return value is not a type of "string"');
37 $assertIsInteger =
static function ($actual):
void {
38 self::assertIsInt($actual,
'The actual return value is not a type of "int"');
41 $assertIsBool =
static function ($actual):
void {
42 self::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'],
65 #[DataProvider('setterAndGettersProvider')] 68 $setter =
'set' . ucfirst($property);
69 $getter =
'get' . ucfirst(($property));
71 $this->assertTrue(method_exists($this->
settings, $setter), sprintf(
'The Setter "%s" does not exist', $setter));
72 $this->assertTrue(method_exists($this->
settings, $getter), sprintf(
'The Getter "%s" does not exist', $setter));
75 $actual = $this->
settings->$getter();
77 $this->assertSame($value, $actual, sprintf(
'The expected value "%s" is not equals to "%s"', $value, $actual));
79 $assertionCallback($actual);
84 $protocol =
'http://';
85 $domain =
'127.0.0.1';
87 $expected = sprintf(
'%s%s:%s', $protocol, $domain, $port);
89 $this->
settings->setProtocol($protocol);
93 $this->assertSame($expected, $this->
settings->getBaseURL());
98 $protocol =
'http://';
99 $domain =
'127.0.0.1';
100 $clientDomain =
'proxy.localhost';
102 $expected = sprintf(
'%s%s:%s', $protocol, $clientDomain, $port);
104 $this->
settings->setClientUrlEnabled(
true);
105 $this->
settings->setProtocol($protocol);
106 $this->
settings->setDomain($domain);
108 $this->
settings->setClientUrl(sprintf(
'%s:%s', $clientDomain, $port));
110 $this->assertSame($expected, $this->
settings->generateClientUrl());
115 $protocol =
'http://';
116 $domain =
'127.0.0.1';
117 $clientDomain =
'proxy.localhost';
119 $expected = sprintf(
'%s%s:%s', $protocol, $domain, $port);
121 $this->
settings->setClientUrlEnabled(
false);
122 $this->
settings->setDomain($domain);
124 $this->
settings->setProtocol($protocol);
125 $this->
settings->setClientUrl(sprintf(
'%s:%s', $clientDomain, $port));
127 $this->assertSame($expected, $this->
settings->generateClientUrl());
132 $protocol =
'http://';
133 $domain =
'127.0.0.1';
134 $iliasDomain =
'proxy.localhost';
136 $expected = sprintf(
'%s%s:%s', $protocol, $iliasDomain, $port);
138 $this->
settings->setIliasUrlEnabled(
true);
139 $this->
settings->setProtocol($protocol);
140 $this->
settings->setDomain($domain);
142 $this->
settings->setIliasUrl(sprintf(
'%s:%s', $iliasDomain, $port));
144 $this->assertSame($expected, $this->
settings->generateIliasUrl());
149 $protocol =
'http://';
150 $domain =
'127.0.0.1';
151 $iliasDomain =
'proxy.localhost';
153 $expected = sprintf(
'%s%s:%s', $protocol, $domain, $port);
155 $this->
settings->setIliasUrlEnabled(
false);
156 $this->
settings->setDomain($domain);
158 $this->
settings->setProtocol($protocol);
159 $this->
settings->setIliasUrl(sprintf(
'%s:%s', $iliasDomain, $port));
161 $this->assertSame($expected, $this->
settings->generateIliasUrl());
166 $protocol =
'http://';
167 $domain =
'127.0.0.1';
168 $iliasDomain =
'proxy.localhost:8080';
170 $action =
'Heartbeat';
171 $instance =
'master';
174 $this->
settings->setProtocol($protocol);
175 $this->
settings->setDomain($domain);
177 $this->
settings->setIliasUrl($iliasDomain);
178 $this->
settings->setInstance($instance);
180 $this->
settings->setIliasUrlEnabled(
false);
190 $this->assertSame($expected, $this->
settings->getURL($action));
192 $this->
settings->setIliasUrlEnabled(
false);
194 '%s%s:%s%s/%s/%s/%s',
203 $this->assertSame($expected, $this->
settings->getURL($action,
$scope));
205 $this->
settings->setIliasUrlEnabled(
true);
214 $this->assertSame($expected, $this->
settings->getURL($action));
216 $this->
settings->setIliasUrlEnabled(
true);
226 $this->assertSame($expected, $this->
settings->getURL($action,
$scope));
testGenerateClientUrlIfEnabled()
final const string PREFIX
ilChatroomServerSettings $settings
testGenerateIliasUrlIfEnabled()
testGenerateIliasUrlIfDisabled()
testGenerateClientUrlIfDisabled()
static setterAndGettersProvider()
testSettersAndGetters(string $property, callable $assertionCallback, $value)