ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
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
5namespace ILIAS\Tests\Setup;
6
8
9class ObjectiveWithPreconditionsTest extends \PHPUnit\Framework\TestCase
10{
11 use Helper;
12
13 public function setUp() : void
14 {
15 $this->objective = $this->newObjective();
16 $this->precondition = $this->newObjective();
17
18 $this->with_precondition = new Setup\ObjectiveWithPreconditions(
19 $this->objective,
20 $this->precondition
21 );
22 }
23
24 public function testGetHash()
25 {
26 $this->assertEquals($this->objective->getHash(), $this->with_precondition->getHash());
27 }
28
29 public function testGetLabel()
30 {
31 $label = "some_label";
32
33 $this->objective
34 ->expects($this->once())
35 ->method("getLabel")
36 ->willReturn($label);
37
38 $this->assertEquals($label, $this->with_precondition->getLabel());
39 }
40
41 public function testIsNotable()
42 {
43 $notable = true;
44
45 $this->objective
46 ->expects($this->once())
47 ->method("isNotable")
48 ->willReturn($notable);
49
50 $this->assertEquals($notable, $this->with_precondition->isNotable());
51 }
52
53 public function testGetPreconditions()
54 {
55 $another = $this->newObjective();
56
57 $env = $this->createMock(Setup\Environment::class);
58
59 $this->objective
60 ->expects($this->once())
61 ->method("getPreconditions")
62 ->with($env)
63 ->willReturn([$another]);
64
65 $pre = $this->with_precondition->getPreconditions($env);
66 $this->assertEquals([$this->precondition, $another], $pre);
67 }
68
69
70 public function testAchieve()
71 {
72 $env = $this->createMock(Setup\Environment::class);
73
74 $this->objective
75 ->expects($this->once())
76 ->method("achieve")
77 ->with($env)
78 ->willReturn($env);
79
80 $res = $this->with_precondition->achieve($env);
81 $this->assertSame($env, $res);
82 }
83}
An exception for terminatinating execution or to throw for unit testing.
A wrapper around an objective that adds some preconditions.
foreach($_POST as $key=> $value) $res