ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CallableObjectiveTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
23require_once(__DIR__ . "/../Helper.php");
24
25use ILIAS\Setup;
28use PHPUnit\Framework\TestCase;
29
30class CallableObjectiveTest extends TestCase
31{
32 use Test\Helper;
33
37
38 public function myMethod(Setup\Environment $environment): Setup\Environment
39 {
40 $this->env = $environment;
41 return $environment;
42 }
43
44 public const NAME = "CALL MY METHOD!";
45
46 public function setUp(): void
47 {
48 $this->p = $this->newObjective();
49
50 $this->o = new Objective\CallableObjective(
51 [$this, "myMethod"],
52 self::NAME,
53 false,
54 $this->p
55 );
56 }
57
58 public function testGetHash(): void
59 {
60 $this->assertIsString($this->o->getHash());
61 }
62
63 public function testGetLabel(): void
64 {
65 $this->assertEquals(self::NAME, $this->o->getLabel());
66 }
67
68 public function testIsNotable(): void
69 {
70 $this->assertFalse($this->o->isNotable());
71 }
72
73 public function testGetPreconditions(): void
74 {
75 $env = $this->createMock(Setup\Environment::class);
76
77 $pre = $this->o->getPreconditions($env);
78 $this->assertEquals([$this->p], $pre);
79 }
80
81
82 public function testAchieve(): void
83 {
84 $this->env = null;
85
86 $env = $this->createMock(Setup\Environment::class);
87
88 $res = $this->o->achieve($env);
89 $this->assertSame($env, $res);
90 $this->assertSame($this->env, $env);
91 }
92}
A callable objective wraps a callable into an objective.
An environment holds resources to be used in the setup process.
Definition: Environment.php:28
An objective is a desired state of the system that is supposed to be created by the setup.
Definition: Objective.php:31
$res
Definition: ltiservices.php:69
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...