ILIAS  release_7 Revision v7.30-3-g800a261c036
ilDatabaseUpdateStepTest.php
Go to the documentation of this file.
1<?php
2
19use PHPUnit\Framework\TestCase;
20
23
25{
26 public function step_1(\ilDBInterface $db)
27 {
28 }
29}
30
31class ilDatabaseUpdateStepTest extends TestCase
32{
33 protected function setUp() : void
34 {
35 $this->parent = $this->createMock(Test_ilDatabaseUpdateStep::class);
36 $this->precondition = $this->createMock(Objective::class);
37
38 $this->step = new \ilDatabaseUpdateStep(
39 $this->parent,
40 1,
41 $this->precondition,
42 $this->precondition
43 );
44 }
45
46 public function testGetPreconditions()
47 {
48 $env = $this->createMock(Environment::class);
49
50 $this->assertEquals(
51 [$this->precondition, $this->precondition],
52 $this->step->getPreconditions($env)
53 );
54 }
55
56 public function testCallsExecutionLog()
57 {
58 $env = $this->createMock(Environment::class);
59 $log = $this->createMock(\ilDatabaseUpdateStepExecutionLog::class);
60 $db = $this->createMock(\ilDBInterface::class);
61
62 $env
63 ->method("getResource")
64 ->will($this->returnValueMap([
65 [Environment::RESOURCE_DATABASE, $db],
66 [\ilDatabaseUpdateStepExecutionLog::class, $log]
67 ]));
68
69 $log
70 ->expects($this->once(), $this->at(0))
71 ->method("started")
72 ->with(get_class($this->parent), 1);
73
74 $log
75 ->expects($this->once(), $this->at(1))
76 ->method("finished")
77 ->with(get_class($this->parent), 1);
78
79 $this->step->achieve($env);
80 }
81
82 public function testCallsMethod()
83 {
84 $env = $this->createMock(Environment::class);
85 $db = $this->createMock(\ilDBInterface::class);
86
87 $env
88 ->method("getResource")
89 ->will($this->returnValueMap([
90 [Environment::RESOURCE_DATABASE, $db],
91 [\ilDatabaseUpdateStepExecutionLog::class, null]
92 ]));
93
94 $this->parent
95 ->expects($this->once())
96 ->method("step_1")
97 ->with($db)
98 ->willReturn(null);
99
100 $this->step->achieve($env);
101 }
102}
An exception for terminatinating execution or to throw for unit testing.
This base-class simplifies the creation of (consecutive) database updates.
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$log
Definition: result.php:15