ILIAS  release_8 Revision v8.24
ObjectiveCollectionTest.php
Go to the documentation of this file.
1<?php
2
3declare(strict_types=1);
4
21namespace ILIAS\Tests\Setup;
22
23use ILIAS\Setup;
24use PHPUnit\Framework\TestCase;
25
26class ObjectiveCollectionTest extends TestCase
27{
28 use Helper;
29
30 public function testGetObjectives(): void
31 {
32 $g1 = $this->newObjective();
33 $g2 = $this->newObjective();
34 $g3 = $this->newObjective();
35
36 $c = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
37
38 $this->assertEquals([$g1, $g2, $g3], $c->getObjectives());
39 }
40
41 public function testGetHash(): void
42 {
43 $g1 = $this->newObjective();
44 $g2 = $this->newObjective();
45 $g3 = $this->newObjective();
46
47 $c1 = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
48 $c2 = new Setup\ObjectiveCollection("", false, $g1, $g2);
49 $c3 = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
50
51 $this->assertIsString($c1->getHash());
52 $this->assertIsString($c2->getHash());
53 $this->assertIsString($c3->getHash());
54
55 $this->assertEquals($c1->getHash(), $c1->getHash());
56 $this->assertNotEquals($c1->getHash(), $c2->getHash());
57 $this->assertEquals($c1->getHash(), $c3->getHash());
58 }
59
60 public function testGetLabel(): void
61 {
62 $c = new Setup\ObjectiveCollection("LABEL", false);
63 $this->assertEquals("LABEL", $c->getLabel());
64 }
65
66 public function testIsNotable(): void
67 {
68 $c1 = new Setup\ObjectiveCollection("", false);
69 $c2 = new Setup\ObjectiveCollection("", true);
70 $this->assertFalse($c1->isNotable());
71 $this->assertTrue($c2->isNotable());
72 }
73
74 public function testGetPreconditions(): void
75 {
76 $g1 = $this->newObjective();
77 $g2 = $this->newObjective();
78 $g3 = $this->newObjective();
79
80 $c = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
81
82 $env = $this->createMock(Setup\Environment::class);
83
84 $pre = $c->getPreconditions($env);
85 $this->assertEquals([$g1,$g2, $g3], $pre);
86 }
87
88
89 public function testAchieve(): void
90 {
91 $g1 = $this->newObjective();
92 $g2 = $this->newObjective();
93 $g3 = $this->newObjective();
94
95 $c = new Setup\ObjectiveCollection("", false, $g1, $g2, $g3);
96
97 $env = $this->createMock(Setup\Environment::class);
98
99 foreach ([$g1,$g2,$g3] as $g) {
100 $g
101 ->expects($this->never())
102 ->method("achieve");
103 }
104
105 $res = $c->achieve($env);
106 $this->assertSame($env, $res);
107 }
108}
A objective collection is a objective that is achieved once all subobjectives are achieved.
$c
Definition: cli.php:38
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...