ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
AdminConfirmedObjectiveTest.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 
7 use ILIAS\Setup;
10 
12 {
16  protected $message;
17 
21  protected $o;
22 
23  public function setUp() : void
24  {
25  $this->message = "This needs to be confirmed...";
26  $this->o = new Objective\AdminConfirmedObjective($this->message);
27  }
28 
29  public function testGetHash() : void
30  {
31  $this->assertIsString($this->o->getHash());
32  }
33 
34  public function testHashIsDifferentForDifferentMessages() : void
35  {
36  $other = new Objective\AdminConfirmedObjective("");
37  $this->assertNotEquals($this->o->getHash(), $other->getHash());
38  }
39 
40  public function testGetLabel() : void
41  {
42  $this->assertIsString($this->o->getLabel());
43  }
44 
45  public function testIsNotable() : void
46  {
47  $this->assertFalse($this->o->isNotable());
48  }
49 
50  public function testGetPreconditions() : void
51  {
52  $env = $this->createMock(Setup\Environment::class);
53 
54  $pre = $this->o->getPreconditions($env);
55  $this->assertEquals([], $pre);
56  }
57 
58  public function testAchieveWithConfirmation() : void
59  {
60  $env = $this->createMock(Setup\Environment::class);
61  $admin_interaction = $this->createMock(Setup\AdminInteraction::class);
62 
63  $env
64  ->method("getResource")
65  ->will($this->returnValueMap([
66  [Setup\Environment::RESOURCE_ADMIN_INTERACTION, $admin_interaction]
67  ]));
68 
69  $admin_interaction
70  ->expects($this->once())
71  ->method("confirmOrDeny")
72  ->with($this->message)
73  ->willReturn(true);
74 
75  $res = $this->o->achieve($env);
76  $this->assertSame($env, $res);
77  }
78 
79  public function testAchieveWithDenial() : void
80  {
81  $this->expectException(Setup\NoConfirmationException::class);
82 
83  $env = $this->createMock(Setup\Environment::class);
84  $admin_interaction = $this->createMock(Setup\AdminInteraction::class);
85 
86  $env
87  ->method("getResource")
88  ->will($this->returnValueMap([
89  [Setup\Environment::RESOURCE_ADMIN_INTERACTION, $admin_interaction]
90  ]));
91 
92  $admin_interaction
93  ->expects($this->once())
94  ->method("confirmOrDeny")
95  ->with($this->message)
96  ->willReturn(false);
97 
98  $this->o->achieve($env);
99  }
100 }
foreach($_POST as $key=> $value) $res
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...