ILIAS  release_7 Revision v7.30-3-g800a261c036
All Data Structures Namespaces Files Functions Variables Modules Pages
ObjectiveWithPreconditionsTest.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;
11 
13 {
14  use Test\Helper;
15 
19  protected $objective;
20 
24  protected $precondition;
25 
29  protected $with_precondition;
30 
31  public function setUp() : void
32  {
33  $this->objective = $this->newObjective();
34  $this->precondition = $this->newObjective();
35 
36  $this->with_precondition = new Objective\ObjectiveWithPreconditions(
37  $this->objective,
38  $this->precondition
39  );
40  }
41 
42  public function testGetHash() : void
43  {
44  $hash = $this->with_precondition->getHash();
45  $this->assertNotEquals($this->objective->getHash(), $hash);
46  $this->assertNotEquals($this->precondition->getHash(), $hash);
47  }
48 
49  public function testGetLabel() : void
50  {
51  $label = "some_label";
52 
53  $this->objective
54  ->expects($this->once())
55  ->method("getLabel")
56  ->willReturn($label);
57 
58  $this->assertEquals($label, $this->with_precondition->getLabel());
59  }
60 
61  public function testIsNotable() : void
62  {
63  $notable = true;
64 
65  $this->objective
66  ->expects($this->once())
67  ->method("isNotable")
68  ->willReturn($notable);
69 
70  $this->assertEquals($notable, $this->with_precondition->isNotable());
71  }
72 
73  public function testGetPreconditions() : void
74  {
75  $another = $this->newObjective();
76 
77  $env = $this->createMock(Setup\Environment::class);
78 
79  $this->objective
80  ->expects($this->once())
81  ->method("getPreconditions")
82  ->with($env)
83  ->willReturn([$another]);
84 
85  $pre = $this->with_precondition->getPreconditions($env);
86  $this->assertEquals([$this->precondition, $another], $pre);
87  }
88 
89 
90  public function testAchieve() : void
91  {
92  $env = $this->createMock(Setup\Environment::class);
93 
94  $this->objective
95  ->expects($this->once())
96  ->method("achieve")
97  ->with($env)
98  ->willReturn($env);
99 
100  $res = $this->with_precondition->achieve($env);
101  $this->assertSame($env, $res);
102  }
103 }
foreach($_POST as $key=> $value) $res
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...