ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
CallableObjectiveTest.php
Go to the documentation of this file.
1 <?php
2 
3 declare(strict_types=1);
4 
22 
23 use ILIAS\Setup;
25 use ILIAS\Tests\Setup as Test;
27 
28 class CallableObjectiveTest extends TestCase
29 {
30  use Test\Helper;
31 
32  protected ?Setup\Environment $env;
33  protected Setup\Objective $p;
34  protected Objective\CallableObjective $o;
35 
36  public function myMethod(Setup\Environment $environment): Setup\Environment
37  {
38  $this->env = $environment;
39  return $environment;
40  }
41 
42  public const NAME = "CALL MY METHOD!";
43 
44  public function setUp(): void
45  {
46  $this->p = $this->newObjective();
47 
48  $this->o = new Objective\CallableObjective(
49  [$this, "myMethod"],
50  self::NAME,
51  false,
52  $this->p
53  );
54  }
55 
56  public function testGetHash(): void
57  {
58  $this->assertIsString($this->o->getHash());
59  }
60 
61  public function testGetLabel(): void
62  {
63  $this->assertEquals(self::NAME, $this->o->getLabel());
64  }
65 
66  public function testIsNotable(): void
67  {
68  $this->assertFalse($this->o->isNotable());
69  }
70 
71  public function testGetPreconditions(): void
72  {
73  $env = $this->createMock(Setup\Environment::class);
74 
75  $pre = $this->o->getPreconditions($env);
76  $this->assertEquals([$this->p], $pre);
77  }
78 
79 
80  public function testAchieve(): void
81  {
82  $this->env = null;
83 
84  $env = $this->createMock(Setup\Environment::class);
85 
86  $res = $this->o->achieve($env);
87  $this->assertSame($env, $res);
88  $this->assertSame($this->env, $env);
89  }
90 }
$res
Definition: ltiservices.php:69
An objective is a desired state of the system that is supposed to be created by the setup...
Definition: Objective.php:30
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...
An environment holds resources to be used in the setup process.
Definition: Environment.php:27
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...