22use PHPUnit\Framework\TestCase;
45 $refinery =
new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
52 $this->assertInstanceOf(\ilGlobalCacheSetupAgent::class, $this->obj);
57 $this->assertTrue($this->obj->hasConfig());
60 public function testGetArrayToConfigTransformationWithNullData(): void
63 $fnc = $this->obj->getArrayToConfigTransformation();
64 $settings = $fnc(
null);
65 $config = $settings->toConfig();
67 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
68 $this->assertFalse($config->isActivated());
71 public function testGetArrayToConfigTransformationWithEmptyDataArray(): void
74 $fnc = $this->obj->getArrayToConfigTransformation();
75 $settings = $fnc(
null);
76 $config = $settings->toConfig();
78 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
79 $this->assertFalse($config->isActivated());
82 public function testGetArrayToConfigTransformationWithNullComponents(): void
85 $fnc = $this->obj->getArrayToConfigTransformation();
86 $settings = $fnc([
"components" =>
null]);
87 $config = $settings->toConfig();
89 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
90 $this->assertFalse($config->isActivated());
93 public function testGetArrayToConfigTransformationWithNullMemcachedData(): void
96 $fnc = $this->obj->getArrayToConfigTransformation();
97 $settings = $fnc([
"service" =>
"memcached"]);
98 $config = $settings->toConfig();
100 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
101 $this->assertFalse($config->isActivated());
104 public function testGetArrayToConfigTransformationWithNullMemcachedDataArray(): void
107 $fnc = $this->obj->getArrayToConfigTransformation();
108 $settings = $fnc([
"service" =>
"memcached",
"memcached_nodes" =>
null]);
109 $config = $settings->toConfig();
111 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
112 $this->assertFalse($config->isActivated());
115 public function testGetArrayToConfigTransformationWithEmptyMemcachedDataArray(): void
118 $fnc = $this->obj->getArrayToConfigTransformation();
119 $settings = $fnc([
"service" =>
"memcached",
"memcached_nodes" => []]);
120 $config = $settings->toConfig();
122 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
123 $this->assertFalse($config->isActivated());
126 public function testGetArrayToConfigTransformationWithDataServices(): void
141 foreach ($services as $key =>
$service) {
143 $fnc = $this->obj->getArrayToConfigTransformation();
148 "memcached_nodes" => [$node],
149 "components" => [
"dummy" =>
true]
152 $config = $settings->toConfig();
153 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
154 $this->assertEquals($key, $config->getAdaptorName());
160 $fnc = $this->obj->getArrayToConfigTransformation();
169 $this->expectException(\InvalidArgumentException::class);
170 $this->expectExceptionMessage(
"Unknown caching service: 'non_existing_service'");
174 "service" =>
"non_existing_service",
175 "memcached_nodes" => [$node],
176 "components" => [
"dummy"]
183 $fnc = $this->obj->getArrayToConfigTransformation();
194 "service" =>
"memcached",
195 "memcached_nodes" => [$node],
196 "components" => [
"dummy" =>
true]
200 $this->assertInstanceOf(\ilGlobalCacheSettingsAdapter::class, $settings);
201 $this->assertIsArray($settings->getMemcachedNodes());
203 $settings = $settings->getMemcachedNodes();
204 $node = array_shift($settings);
206 $this->assertEquals(
"test.de", $node->getHost());
207 $this->assertEquals(
"9874", $node->getPort());
208 $this->assertEquals(
"10", $node->getWeight());
215 "host" =>
"my.test.de",
220 $result = $this->obj->getMServer($node);
222 $this->assertEquals(
"my.test.de", $result->getHost());
223 $this->assertEquals(
"1111", $result->getPort());
224 $this->assertEquals(
"20", $result->getWeight());
231 "host" =>
"my.test.de",
236 $result = $this->obj->getMServer($node);
238 $this->assertEquals(
"my.test.de", $result->getHost());
239 $this->assertEquals(
"1111", $result->getPort());
240 $this->assertEquals(
"20", $result->getWeight());
245 $setup_conf_mock = $this->createMock(\ilGlobalCacheSettingsAdapter::class);
246 $objective_collection = $this->obj->getInstallObjective($setup_conf_mock);
248 $this->assertEquals(
'Store configuration of components/ILIAS/GlobalCache_', $objective_collection->getLabel());
249 $this->assertFalse($objective_collection->isNotable());
254 $setup_conf_mock = $this->createMock(\ilGlobalCacheSettingsAdapter::class);
255 $objective_collection = $this->obj->getUpdateObjective($setup_conf_mock);
257 $this->assertEquals(
'Store configuration of components/ILIAS/GlobalCache_', $objective_collection->getLabel());
258 $this->assertFalse($objective_collection->isNotable());
263 $objective_collection = $this->obj->getUpdateObjective();
265 $this->assertInstanceOf(NullObjective::class, $objective_collection);
271 $objective_collection = $this->obj->getBuildObjective();
273 $this->assertInstanceOf(NullObjective::class, $objective_collection);
A non-objective, nothing to do to achieve it...
testGetInstallObjectives()
testGetArrayToConfigTransformationWithMemcachedNode()
testGetBuildArtifactObjective()
testGetMemcachedServerActive()
testGetArrayToConfigTransformationWithServiceException()
testGetMemcachedServerInactive()
testGetUpdateObjectiveWithoutConfig()
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...