ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
CallableObjectiveTest.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
7require_once(__DIR__ . "/Helper.php");
8
10
11class CallableObjectiveTest extends \PHPUnit\Framework\TestCase
12{
13 use Helper;
14
15 public function myMethod(Setup\Environment $environment)
16 {
17 $this->env = $environment;
18 return $environment;
19 }
20
21 const NAME = "CALL MY METHOD!";
22
23 public function setUp() : void
24 {
25 $this->p = $this->newObjective();
26
27 $this->o = new Setup\CallableObjective(
28 [$this, "myMethod"],
29 self::NAME,
30 false,
31 $this->p
32 );
33 }
34
35 public function testGetHash()
36 {
37 $this->assertIsString($this->o->getHash());
38 }
39
40 public function testGetLabel()
41 {
42 $this->assertEquals(self::NAME, $this->o->getLabel());
43 }
44
45 public function testIsNotable()
46 {
47 $this->assertFalse($this->o->isNotable());
48 }
49
50 public function testGetPreconditions()
51 {
52 $env = $this->createMock(Setup\Environment::class);
53
54 $pre = $this->o->getPreconditions($env);
55 $this->assertEquals([$this->p], $pre);
56 }
57
58
59 public function testAchieve()
60 {
61 $this->env = null;
62
63 $env = $this->createMock(Setup\Environment::class);
64
65 $res = $this->o->achieve($env);
66 $this->assertSame($env, $res);
67 $this->assertSame($this->env, $env);
68 }
69}
An exception for terminatinating execution or to throw for unit testing.
A callable objective wraps a callable into an objective.
myMethod(Setup\Environment $environment)
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
foreach($_POST as $key=> $value) $res