ILIAS  release_7 Revision v7.30-3-g800a261c036
ilLanguageSetupAgentTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2020 Daniel Weise <daniel.weise@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
7use PHPUnit\Framework\TestCase;
8use ILIAS\Refinery\Factory as Refinery;
9use ILIAS\Data\Factory as DataFactory;
11
12class ilLanguageSetupAgentTest extends TestCase
13{
17 protected $obj;
18
19 public function setUp() : void
20 {
21 $this->refinery = new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
22 $setup_language = $this->createMock(\ilSetupLanguage::class);
23
24 $this->obj = new \ilLanguageSetupAgent($this->refinery, null, $setup_language);
25 }
26
27 public function testCreate() : void
28 {
29 $this->assertInstanceOf(\ilLanguageSetupAgent::class, $this->obj);
30 }
31
32 public function testHasConfig() : void
33 {
34 $this->assertTrue($this->obj->hasConfig());
35 }
36
38 {
39 $fnc = $this->obj->getArrayToConfigTransformation();
40
41 $lng_setup_conf = $fnc([]);
42
43 $this->assertEquals('en', $lng_setup_conf->getDefaultLanguage());
44 $this->assertEquals(['en'], $lng_setup_conf->getInstallLanguages());
45 $this->assertEquals([], $lng_setup_conf->getInstallLocalLanguages());
46 }
47
49 {
50 $fnc = $this->obj->getArrayToConfigTransformation();
51
52 $lng_setup_conf = $fnc([
53 'install_languages' => ['en', 'de'],
54 'install_local_languages' => ['de']
55 ]);
56
57 $this->assertEquals('en', $lng_setup_conf->getDefaultLanguage());
58 $this->assertEquals(['en', 'de'], $lng_setup_conf->getInstallLanguages());
59 $this->assertEquals(['de'], $lng_setup_conf->getInstallLocalLanguages());
60 }
61
62 public function testGetInstallObjectives() : void
63 {
64 $setup_conf_mock = $this->createMock(\ilLanguageSetupConfig::class);
65 $objective_collection = $this->obj->getInstallObjective($setup_conf_mock);
66
67 $this->assertEquals('Complete objectives from Services/Language', $objective_collection->getLabel());
68 $this->assertFalse($objective_collection->isNotable());
69 $this->assertEquals(3, count($objective_collection->getObjectives()));
70 }
71
72 public function testGetUpdateObjectiveWithConfig() : void
73 {
74 $setup_conf_mock = $this->createMock(\ilLanguageSetupConfig::class);
75 $objective_collection = $this->obj->getUpdateObjective($setup_conf_mock);
76
77 $this->assertEquals('Complete objectives from Services/Language', $objective_collection->getLabel());
78 $this->assertFalse($objective_collection->isNotable());
79 $this->assertEquals(3, count($objective_collection->getObjectives()));
80 }
81
82 public function testGetUpdateObjectiveWithoutConfig() : void
83 {
84 $objective_collection = $this->obj->getUpdateObjective();
85
86 $this->assertEquals('Complete objectives from Services/Language', $objective_collection->getLabel());
87 $this->assertFalse($objective_collection->isNotable());
88 $this->assertEquals(1, count($objective_collection->getObjectives()));
89 }
90
91
92 public function testGetBuildArtifactObjective() : void
93 {
94 $result = $this->obj->getBuildArtifactObjective();
95
96 $this->assertInstanceOf(NullObjective::class, $result);
97 }
98}
$result
An exception for terminatinating execution or to throw for unit testing.
Builds data types.
Definition: Factory.php:20
A non-objective, nothing to do to achieve it...