ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
AdminConfirmedObjectiveTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23use ILIAS\Setup;
25use PHPUnit\Framework\TestCase;
26
27class AdminConfirmedObjectiveTest extends TestCase
28{
29 protected string $message;
31
32 public function setUp(): void
33 {
34 $this->message = "This needs to be confirmed...";
35 $this->o = new Objective\AdminConfirmedObjective($this->message);
36 }
37
38 public function testGetHash(): void
39 {
40 $this->assertIsString($this->o->getHash());
41 }
42
44 {
45 $other = new Objective\AdminConfirmedObjective("");
46 $this->assertNotEquals($this->o->getHash(), $other->getHash());
47 }
48
49 public function testGetLabel(): void
50 {
51 $this->assertIsString($this->o->getLabel());
52 }
53
54 public function testIsNotable(): void
55 {
56 $this->assertFalse($this->o->isNotable());
57 }
58
59 public function testGetPreconditions(): void
60 {
61 $env = $this->createMock(Setup\Environment::class);
62
63 $pre = $this->o->getPreconditions($env);
64 $this->assertEquals([], $pre);
65 }
66
67 public function testAchieveWithConfirmation(): void
68 {
69 $env = $this->createMock(Setup\Environment::class);
70 $admin_interaction = $this->createMock(Setup\AdminInteraction::class);
71
72 $env
73 ->method("getResource")
74 ->will($this->returnValueMap([
76 ]));
77
78 $admin_interaction
79 ->expects($this->once())
80 ->method("confirmOrDeny")
81 ->with($this->message)
82 ->willReturn(true);
83
84 $res = $this->o->achieve($env);
85 $this->assertSame($env, $res);
86 }
87
88 public function testAchieveWithDenial(): void
89 {
90 $this->expectException(Setup\NoConfirmationException::class);
91
92 $env = $this->createMock(Setup\Environment::class);
93 $admin_interaction = $this->createMock(Setup\AdminInteraction::class);
94
95 $env
96 ->method("getResource")
97 ->will($this->returnValueMap([
99 ]));
100
101 $admin_interaction
102 ->expects($this->once())
103 ->method("confirmOrDeny")
104 ->with($this->message)
105 ->willReturn(false);
106
107 $this->o->achieve($env);
108 }
109}
An admin needs to confirm something to achieve this objective.
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...