ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
ilDatabaseUpdateStepTest.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 
9 
11 {
12  public function step_1(\ilDBInterface $db)
13  {
14  }
15 }
16 
18 {
19  protected function setUp() : void
20  {
21  $this->parent = $this->createMock(Test_ilDatabaseUpdateStep::class);
22  $this->precondition = $this->createMock(Objective::class);
23 
24  $this->step = new \ilDatabaseUpdateStep(
25  $this->parent,
26  1,
27  $this->precondition,
28  $this->precondition
29  );
30  }
31 
32  public function testGetPreconditions()
33  {
34  $env = $this->createMock(Environment::class);
35 
36  $this->assertEquals(
37  [$this->precondition, $this->precondition],
38  $this->step->getPreconditions($env)
39  );
40  }
41 
42  public function testCallsExecutionLog()
43  {
44  $env = $this->createMock(Environment::class);
45  $log = $this->createMock(\ilDatabaseUpdateStepExecutionLog::class);
46  $db = $this->createMock(\ilDBInterface::class);
47 
48  $env
49  ->method("getResource")
50  ->will($this->returnValueMap([
51  [Environment::RESOURCE_DATABASE, $db],
52  [\ilDatabaseUpdateStepExecutionLog::class, $log]
53  ]));
54 
55  $log
56  ->expects($this->once(), $this->at(0))
57  ->method("started")
58  ->with(get_class($this->parent), 1);
59 
60  $log
61  ->expects($this->once(), $this->at(1))
62  ->method("finished")
63  ->with(get_class($this->parent), 1);
64 
65  $this->step->achieve($env);
66  }
67 
68  public function testCallsMethod()
69  {
70  $env = $this->createMock(Environment::class);
71  $db = $this->createMock(\ilDBInterface::class);
72 
73  $env
74  ->method("getResource")
75  ->will($this->returnValueMap([
76  [Environment::RESOURCE_DATABASE, $db],
77  [\ilDatabaseUpdateStepExecutionLog::class, null]
78  ]));
79 
80  $this->parent
81  ->expects($this->once())
82  ->method("step_1")
83  ->with($db)
84  ->willReturn($null);
85 
86  $this->step->achieve($env);
87  }
88 }
Interface ilDBInterface.
$log
Definition: result.php:15
This base-class simplifies the creation of (consecutive) database updates.