ILIAS  release_7 Revision v7.30-3-g800a261c036
ObjectiveCollectionTest.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
8use PHPUnit\Framework\TestCase;
9
10class ObjectiveCollectionTest extends TestCase
11{
12 use Helper;
13
14 public function testGetObjectives() : void
15 {
16 $g1 = $this->newObjective();
17 $g2 = $this->newObjective();
18 $g3 = $this->newObjective();
19
20 $c = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
21
22 $this->assertEquals([$g1, $g2, $g3], $c->getObjectives());
23 }
24
25 public function testGetHash() : void
26 {
27 $g1 = $this->newObjective();
28 $g2 = $this->newObjective();
29 $g3 = $this->newObjective();
30
31 $c1 = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
32 $c2 = new Setup\ObjectiveCollection("", false, $g1, $g2);
33 $c3 = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
34
35 $this->assertIsString($c1->getHash());
36 $this->assertIsString($c2->getHash());
37 $this->assertIsString($c3->getHash());
38
39 $this->assertEquals($c1->getHash(), $c1->getHash());
40 $this->assertNotEquals($c1->getHash(), $c2->getHash());
41 $this->assertEquals($c1->getHash(), $c3->getHash());
42 }
43
44 public function testGetLabel() : void
45 {
46 $c = new Setup\ObjectiveCollection("LABEL", false);
47 $this->assertEquals("LABEL", $c->getLabel());
48 }
49
50 public function testIsNotable() : void
51 {
52 $c1 = new Setup\ObjectiveCollection("", false);
53 $c2 = new Setup\ObjectiveCollection("", true);
54 $this->assertFalse($c1->isNotable());
55 $this->assertTrue($c2->isNotable());
56 }
57
58 public function testGetPreconditions() : void
59 {
60 $g1 = $this->newObjective();
61 $g2 = $this->newObjective();
62 $g3 = $this->newObjective();
63
64 $c = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
65
66 $env = $this->createMock(Setup\Environment::class);
67
68 $pre = $c->getPreconditions($env);
69 $this->assertEquals([$g1,$g2, $g3], $pre);
70 }
71
72
73 public function testAchieve() : void
74 {
75 $g1 = $this->newObjective();
76 $g2 = $this->newObjective();
77 $g3 = $this->newObjective();
78
79 $c = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
80
81 $env = $this->createMock(Setup\Environment::class);
82
83 foreach ([$g1,$g2,$g3] as $g) {
84 $g
85 ->expects($this->never())
86 ->method("achieve");
87 }
88
89 $res = $c->achieve($env);
90 $this->assertSame($env, $res);
91 }
92}
An exception for terminatinating execution or to throw for unit testing.
A objective collection is a objective that is achieved once all subobjectives are achieved.
$c
Definition: cli.php:37
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach($_POST as $key=> $value) $res