ILIAS  release_7 Revision v7.30-3-g800a261c036
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
6
10use PHPUnit\Framework\TestCase;
11
12class CallableObjectiveTest extends TestCase
13{
14 use Test\Helper;
15
19 protected $env;
20
24 protected $p;
25
29 protected $o;
30
31 public function myMethod(Setup\Environment $environment) : Setup\Environment
32 {
33 $this->env = $environment;
34 return $environment;
35 }
36
37 const NAME = "CALL MY METHOD!";
38
39 public function setUp() : void
40 {
41 $this->p = $this->newObjective();
42
43 $this->o = new Objective\CallableObjective(
44 [$this, "myMethod"],
45 self::NAME,
46 false,
47 $this->p
48 );
49 }
50
51 public function testGetHash() : void
52 {
53 $this->assertIsString($this->o->getHash());
54 }
55
56 public function testGetLabel() : void
57 {
58 $this->assertEquals(self::NAME, $this->o->getLabel());
59 }
60
61 public function testIsNotable() : void
62 {
63 $this->assertFalse($this->o->isNotable());
64 }
65
66 public function testGetPreconditions() : void
67 {
68 $env = $this->createMock(Setup\Environment::class);
69
70 $pre = $this->o->getPreconditions($env);
71 $this->assertEquals([$this->p], $pre);
72 }
73
74
75 public function testAchieve() : void
76 {
77 $this->env = null;
78
79 $env = $this->createMock(Setup\Environment::class);
80
81 $res = $this->o->achieve($env);
82 $this->assertSame($env, $res);
83 $this->assertSame($this->env, $env);
84 }
85}
An exception for terminatinating execution or to throw for unit testing.
A callable objective wraps a callable into an objective.
An environment holds resources to be used in the setup process.
Definition: Environment.php:12
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
foreach($_POST as $key=> $value) $res