ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
UpdateCommandTest.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 UpdateCommandTest 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\UpdateCommand(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_reader
34 ->expects($this->once())
35 ->method("readConfigFile")
36 ->with($config_file)
37 ->willReturn($config_file_content);
38
39 $agent
40 ->expects($this->once())
41 ->method("hasConfig")
42 ->willReturn(true);
43
44 $agent
45 ->expects($this->once())
46 ->method("getArrayToConfigTransformation")
47 ->with()
48 ->willReturn($refinery->custom()->transformation(function ($v) use ($config_file_content, $config) {
49 $this->assertEquals($v, $config_file_content);
50 return $config;
51 }));
52
53 $agent
54 ->expects($this->never())
55 ->method("getInstallObjective")
56 ->with($config)
57 ->willReturn(new Setup\NullObjective());
58
59 $agent
60 ->expects($this->never())
61 ->method("getBuildArtifactObjective")
62 ->with()
63 ->willReturn(new Setup\NullObjective());
64
65 $agent
66 ->expects($this->once())
67 ->method("getUpdateObjective")
68 ->with($config)
69 ->willReturn($objective);
70
71 $objective
72 ->expects($this->once())
73 ->method("getPreconditions")
74 ->willReturn([]);
75
76 $objective
77 ->expects($this->once())
78 ->method("achieve")
79 ->willReturn($env);
80
81 $tester->execute([
82 "config" => $config_file
83 ]);
84 }
85}
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