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