ILIAS  release_7 Revision v7.30-3-g800a261c036
ExternalConditionObjectiveTest.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
9use PHPUnit\Framework\TestCase;
10
11class ExternalConditionObjectiveTest extends TestCase
12{
16 protected $label_t;
17
21 protected $t;
22
26 protected $label_f;
27
31 protected $f;
32
33 public function setUp() : void
34 {
35 $this->label_t = "condition_true";
37 $this->label_t,
38 function (Setup\Environment $e) {
39 return true;
40 }
41 );
42 $this->label_f = "condition_false";
44 $this->label_f,
45 function (Setup\Environment $e) {
46 return false;
47 }
48 );
49 }
50
51 public function testGetHash() : void
52 {
53 $this->assertIsString($this->t->getHash());
54 }
55
57 {
58 $this->assertNotEquals($this->t->getHash(), $this->f->getHash());
59 }
60
61 public function testGetLabel() : void
62 {
63 $this->assertIsString($this->f->getLabel());
64 $this->assertEquals($this->label_f, $this->f->getLabel());
65 $this->assertEquals($this->label_t, $this->t->getLabel());
66 }
67
68 public function testIsNotable() : void
69 {
70 $this->assertTrue($this->f->isNotable());
71 }
72
73 public function testGetPreconditions() : void
74 {
75 $env = $this->createMock(Setup\Environment::class);
76
77 $pre = $this->f->getPreconditions($env);
78 $this->assertEquals([], $pre);
79 }
80
81 public function testAchieveFalse() : void
82 {
83 $this->expectException(Setup\UnachievableException::class);
84 $env = $this->createMock(Setup\Environment::class);
85 $this->f->achieve($env);
86 }
87
88
89 public function testAchieveTrue() : void
90 {
91 $env = $this->createMock(Setup\Environment::class);
92 $res = $this->t->achieve($env);
93 $this->assertEquals($env, $res);
94 }
95}
An exception for terminatinating execution or to throw for unit testing.
A condition that can't be met by ILIAS itself needs to be met by some external means.
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach($_POST as $key=> $value) $res