ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
InstallCommandTest.php
Go to the documentation of this file.
1<?php
2
3/* Copyright (c) 2019 Richard Klees <richard.klees@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4
6
8use Symfony\Component\Console\Tester\CommandTester;
9use ILIAS\Refinery\Factory as Refinery;
10use ILIAS\Data\Factory as DataFactory;
11
12class InstallCommandTest extends \PHPUnit\Framework\TestCase
13{
14 public function testBasicFunctionality()
15 {
16 $refinery = new Refinery($this->createMock(DataFactory::class), $this->createMock(\ilLanguage::class));
17
18 $agent = $this->createMock(Setup\Agent::class);
19 $config_reader = $this->createMock(Setup\CLI\ConfigReader::class);
20 $command = new Setup\CLI\InstallCommand(function () use ($agent) {
21 return $agent;
22 }, $config_reader, []);
23
24 $tester = new CommandTester($command);
25
26 $config = $this->createMock(Setup\Config::class);
27 $config_file = "config_file";
28 $config_file_content = ["config_file"];
29
30 $objective = $this->createMock(Setup\Objective::class);
31 $env = $this->createMock(Setup\Environment::class);
32
33 $config_overwrites = [
34 "a.b.c" => "foo",
35 "d.e" => "bar",
36 ];
37
38 $config_reader
39 ->expects($this->once())
40 ->method("readConfigFile")
41 ->with($config_file, $config_overwrites)
42 ->willReturn($config_file_content);
43
44 $agent
45 ->expects($this->once())
46 ->method("hasConfig")
47 ->willReturn(true);
48
49 $agent
50 ->expects($this->once())
51 ->method("getArrayToConfigTransformation")
52 ->with()
53 ->willReturn($refinery->custom()->transformation(function ($v) use ($config_file_content, $config) {
54 $this->assertEquals($v, $config_file_content);
55 return $config;
56 }));
57
58 $agent
59 ->expects($this->once())
60 ->method("getInstallObjective")
61 ->with($config)
62 ->willReturn($objective);
63
64 $agent
65 ->expects($this->never())
66 ->method("getBuildArtifactObjective")
67 ->with()
68 ->willReturn(new Setup\NullObjective());
69
70 $agent
71 ->expects($this->once())
72 ->method("getUpdateObjective")
73 ->with($config)
74 ->willReturn(new Setup\NullObjective());
75
76 $objective
77 ->expects($this->once())
78 ->method("getPreconditions")
79 ->willReturn([]);
80
81 $objective
82 ->expects($this->once())
83 ->method("achieve")
84 ->willReturn($env);
85
86 $tester->execute([
87 "config" => $config_file,
88 "--config" => ["a.b.c=foo", "d.e=bar"]
89 ]);
90 }
91}
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...
if(!array_key_exists('PATH_INFO', $_SERVER)) $config
Definition: metadata.php:68