ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
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 
5 namespace ILIAS\Tests\Setup;
6 
7 use ILIAS\Setup;
8 
9 class ExternalConditionObjectiveTest extends \PHPUnit\Framework\TestCase
10 {
11  public function setUp() : void
12  {
13  $this->label_t = "condition_true";
14  $this->t = new Setup\ExternalConditionObjective(
15  $this->label_t,
16  function (Setup\Environment $e) {
17  return true;
18  }
19  );
20  $this->label_f = "condition_false";
21  $this->f = new Setup\ExternalConditionObjective(
22  $this->label_f,
23  function (Setup\Environment $e) {
24  return false;
25  }
26  );
27  }
28 
29  public function testGetHash()
30  {
31  $this->assertIsString($this->t->getHash());
32  }
33 
35  {
36  $this->assertNotEquals($this->t->getHash(), $this->f->getHash());
37  }
38 
39  public function testGetLabel()
40  {
41  $this->assertIsString($this->f->getLabel());
42  $this->assertEquals($this->label_f, $this->f->getLabel());
43  $this->assertEquals($this->label_t, $this->t->getLabel());
44  }
45 
46  public function testIsNotable()
47  {
48  $this->assertTrue($this->f->isNotable());
49  }
50 
51  public function testGetPreconditions()
52  {
53  $env = $this->createMock(Setup\Environment::class);
54 
55  $pre = $this->f->getPreconditions($env);
56  $this->assertEquals([], $pre);
57  }
58 
59  public function testAchieveFalse()
60  {
61  $this->expectException(Setup\UnachievableException::class);
62  $env = $this->createMock(Setup\Environment::class);
63  $res = $this->f->achieve($env);
64  }
65 
66 
67  public function testAchieveTrue()
68  {
69  $env = $this->createMock(Setup\Environment::class);
70  $res = $this->t->achieve($env);
71  $this->assertEquals($env, $res);
72  }
73 }
A condition that can&#39;t be met by ILIAS itself needs to be met by some external means.
foreach($_POST as $key=> $value) $res
An environment holds resources to be used in the setup process.
Definition: Environment.php:11