ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ObjectiveWithPreconditionsTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23require_once(__DIR__ . "/../Helper.php");
24
25use ILIAS\Setup;
28use PHPUnit\Framework\TestCase;
29
30class ObjectiveWithPreconditionsTest extends TestCase
31{
32 use \ILIAS\Tests\Setup\Helper;
33
37
38 public function setUp(): void
39 {
40 $this->objective = $this->newObjective();
41 $this->precondition = $this->newObjective();
42
43 $this->with_precondition = new Objective\ObjectiveWithPreconditions(
44 $this->objective,
45 $this->precondition
46 );
47 }
48
49 public function testGetHash(): void
50 {
51 $hash = $this->with_precondition->getHash();
52 $this->assertNotEquals($this->objective->getHash(), $hash);
53 $this->assertNotEquals($this->precondition->getHash(), $hash);
54 }
55
56 public function testGetLabel(): void
57 {
58 $label = "some_label";
59
60 $this->objective
61 ->expects($this->once())
62 ->method("getLabel")
63 ->willReturn($label);
64
65 $this->assertEquals($label, $this->with_precondition->getLabel());
66 }
67
68 public function testIsNotable(): void
69 {
70 $notable = true;
71
72 $this->objective
73 ->expects($this->once())
74 ->method("isNotable")
75 ->willReturn($notable);
76
77 $this->assertEquals($notable, $this->with_precondition->isNotable());
78 }
79
80 public function testGetPreconditions(): void
81 {
82 $another = $this->newObjective();
83
84 $env = $this->createMock(Setup\Environment::class);
85
86 $this->objective
87 ->expects($this->once())
88 ->method("getPreconditions")
89 ->with($env)
90 ->willReturn([$another]);
91
92 $pre = $this->with_precondition->getPreconditions($env);
93 $this->assertEquals([$this->precondition, $another], $pre);
94 }
95
96
97 public function testAchieve(): void
98 {
99 $env = $this->createMock(Setup\Environment::class);
100
101 $this->objective
102 ->expects($this->once())
103 ->method("achieve")
104 ->with($env)
105 ->willReturn($env);
106
107 $res = $this->with_precondition->achieve($env);
108 $this->assertSame($env, $res);
109 }
110}
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...