ILIAS  release_8 Revision v8.24
ObjectiveWithPreconditionsTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Setup;
26use PHPUnit\Framework\TestCase;
27
28class ObjectiveWithPreconditionsTest extends TestCase
29{
30 use Test\Helper;
31
35
36 public function setUp(): void
37 {
38 $this->objective = $this->newObjective();
39 $this->precondition = $this->newObjective();
40
41 $this->with_precondition = new Objective\ObjectiveWithPreconditions(
42 $this->objective,
43 $this->precondition
44 );
45 }
46
47 public function testGetHash(): void
48 {
49 $hash = $this->with_precondition->getHash();
50 $this->assertNotEquals($this->objective->getHash(), $hash);
51 $this->assertNotEquals($this->precondition->getHash(), $hash);
52 }
53
54 public function testGetLabel(): void
55 {
56 $label = "some_label";
57
58 $this->objective
59 ->expects($this->once())
60 ->method("getLabel")
61 ->willReturn($label);
62
63 $this->assertEquals($label, $this->with_precondition->getLabel());
64 }
65
66 public function testIsNotable(): void
67 {
68 $notable = true;
69
70 $this->objective
71 ->expects($this->once())
72 ->method("isNotable")
73 ->willReturn($notable);
74
75 $this->assertEquals($notable, $this->with_precondition->isNotable());
76 }
77
78 public function testGetPreconditions(): void
79 {
80 $another = $this->newObjective();
81
82 $env = $this->createMock(Setup\Environment::class);
83
84 $this->objective
85 ->expects($this->once())
86 ->method("getPreconditions")
87 ->with($env)
88 ->willReturn([$another]);
89
90 $pre = $this->with_precondition->getPreconditions($env);
91 $this->assertEquals([$this->precondition, $another], $pre);
92 }
93
94
95 public function testAchieve(): void
96 {
97 $env = $this->createMock(Setup\Environment::class);
98
99 $this->objective
100 ->expects($this->once())
101 ->method("achieve")
102 ->with($env)
103 ->willReturn($env);
104
105 $res = $this->with_precondition->achieve($env);
106 $this->assertSame($env, $res);
107 }
108}
A wrapper around an objective that adds some preconditions.
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...