ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ILIAS\Tests\Setup\CLI\InstallCommandTest Class Reference
+ Inheritance diagram for ILIAS\Tests\Setup\CLI\InstallCommandTest:
+ Collaboration diagram for ILIAS\Tests\Setup\CLI\InstallCommandTest:

Public Member Functions

 testBasicFunctionality ()
 
 testBasicFunctionalityAlreadyAchieved ()
 
 basicFunctionality (bool $is_applicable)
 
 testPluginInstallation ()
 

Detailed Description

Definition at line 29 of file InstallCommandTest.php.

Member Function Documentation

◆ basicFunctionality()

ILIAS\Tests\Setup\CLI\InstallCommandTest::basicFunctionality ( bool  $is_applicable)

Definition at line 41 of file InstallCommandTest.php.

41 : void
42 {
43 $refinery = new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
44
45 $agent = $this->createMock(Setup\AgentCollection::class);
46 $config_reader = $this->createMock(Setup\CLI\ConfigReader::class);
47 $agent_finder = $this->createMock(Setup\AgentFinder::class);
48 $command = new Setup\CLI\InstallCommand($agent_finder, $config_reader, []);
49
50 $tester = new CommandTester($command);
51
52 $config = $this->createMock(Setup\ConfigCollection::class);
53 $config_file = "config_file";
54 $config_file_content = ["config_file"];
55
56 $objective = $this->createMock(Setup\Objective::class);
57 $env = $this->createMock(Setup\Environment::class);
58
59 $config_overwrites = [
60 "a.b.c" => "foo",
61 "d.e" => "bar",
62 ];
63
64 $agent
65 ->expects($this->once())
66 ->method("hasConfig")
67 ->willReturn(true);
68
69 $config_reader
70 ->expects($this->once())
71 ->method("readConfigFile")
72 ->with($config_file, $config_overwrites)
73 ->willReturn($config_file_content);
74
75 $config
76 ->expects($this->once())
77 ->method("getConfig")
78 ->with("common")
79 ->willReturn(new class () implements Setup\Config {
80 public function getClientId(): string
81 {
82 return "client_id";
83 }
84 });
85
86 $agent_finder
87 ->expects($this->once())
88 ->method("getAgents")
89 ->with()
90 ->willReturn($agent);
91
92 $agent
93 ->expects($this->once())
94 ->method("getArrayToConfigTransformation")
95 ->with()
96 ->willReturn($refinery->custom()->transformation(function ($v) use ($config_file_content, $config) {
97 $this->assertEquals($v, $config_file_content);
98 return $config;
99 }));
100
101 $agent
102 ->expects($this->once())
103 ->method("getInstallObjective")
104 ->with($config)
105 ->willReturn($objective);
106
107 $agent
108 ->expects($this->never())
109 ->method("getBuildObjective")
110 ->with()
111 ->willReturn(new Setup\Objective\NullObjective());
112
113 $agent
114 ->expects($this->once())
115 ->method("getUpdateObjective")
116 ->with()
117 ->willReturn(new Setup\Objective\NullObjective());
118
119 $objective
120 ->expects($this->once())
121 ->method("getPreconditions")
122 ->willReturn([]);
123
124 $expects = $this->never();
125 $return = false;
126
127 if ($is_applicable) {
128 $expects = $this->once();
129 $return = true;
130 }
131
132 $objective
133 ->expects($expects)
134 ->method("achieve")
135 ->willReturn($env);
136
137 $objective
138 ->expects($this->once())
139 ->method("isApplicable")
140 ->willReturn($return);
141
142 $tester->execute([
143 "config" => $config_file,
144 "--config" => ["a.b.c=foo", "d.e=bar"]
145 ]);
146 }
getClientId()

References ILIAS\UI\examples\Layout\Page\Standard\$refinery, and ILIAS\getClientId().

Referenced by ILIAS\Tests\Setup\CLI\InstallCommandTest\testBasicFunctionality(), and ILIAS\Tests\Setup\CLI\InstallCommandTest\testBasicFunctionalityAlreadyAchieved().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ testBasicFunctionality()

ILIAS\Tests\Setup\CLI\InstallCommandTest::testBasicFunctionality ( )

Definition at line 31 of file InstallCommandTest.php.

31 : void
32 {
33 $this->basicFunctionality(false);
34 }

References ILIAS\Tests\Setup\CLI\InstallCommandTest\basicFunctionality().

+ Here is the call graph for this function:

◆ testBasicFunctionalityAlreadyAchieved()

ILIAS\Tests\Setup\CLI\InstallCommandTest::testBasicFunctionalityAlreadyAchieved ( )

Definition at line 36 of file InstallCommandTest.php.

36 : void
37 {
38 $this->basicFunctionality(true);
39 }

References ILIAS\Tests\Setup\CLI\InstallCommandTest\basicFunctionality().

+ Here is the call graph for this function:

◆ testPluginInstallation()

ILIAS\Tests\Setup\CLI\InstallCommandTest::testPluginInstallation ( )

Definition at line 148 of file InstallCommandTest.php.

148 : void
149 {
150 $agent = $this->createMock(Setup\AgentCollection::class);
151 $config_reader = $this->createMock(Setup\CLI\ConfigReader::class);
152 $agent_finder = $this->createMock(Setup\AgentFinder::class);
153 $command = new Setup\CLI\InstallCommand($agent_finder, $config_reader, []);
154
155 $tester = new CommandTester($command);
156
157 $objective = $this->createMock(Setup\Objective::class);
158 $env = $this->createMock(Setup\Environment::class);
159
160 $agent
161 ->expects($this->once())
162 ->method("hasConfig")
163 ->willReturn(false);
164
165 $agent_finder
166 ->expects($this->once())
167 ->method("getPluginAgent")
168 ->with("test")
169 ->willReturn($agent);
170
171 $agent
172 ->expects($this->once())
173 ->method("getInstallObjective")
174 ->with(null)
175 ->willReturn($objective);
176
177 $agent
178 ->expects($this->once())
179 ->method("getUpdateObjective")
180 ->with()
181 ->willReturn(new Setup\Objective\NullObjective());
182
183 $objective
184 ->expects($this->once())
185 ->method("getPreconditions")
186 ->willReturn([]);
187
188 $objective
189 ->expects($this->once())
190 ->method("achieve")
191 ->willReturn($env);
192
193 $objective
194 ->expects($this->once())
195 ->method("isApplicable")
196 ->willReturn(true);
197
198 $tester->execute([
199 "--legacy-plugin" => "test"
200 ]);
201 }

The documentation for this class was generated from the following file: