ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
StartUpStepTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22
24use ilCtrl;
26use PHPUnit\Framework\TestCase;
28
29require_once __DIR__ . '/ContainerMock.php';
30
31class StartUpStepTest extends TestCase
32{
33 use ContainerMock;
34
35 public function testConstruct(): void
36 {
37 $this->assertInstanceOf(StartUpStep::class, new StartUpStep($this->mock(ilCtrl::class), $this->mock(Conductor::class)));
38 }
39
40 public function testShouldStoreRequestTarget(): void
41 {
42 $instance = new StartUpStep($this->mock(ilCtrl::class), $this->mock(Conductor::class));
43 $this->assertTrue($instance->shouldStoreRequestTarget());
44 }
45
46 public function testShouldInterceptRequest(): void
47 {
48 $instance = new StartUpStep($this->mock(ilCtrl::class), $this->mockTree(Conductor::class, ['intercepting' => [
49 $this->mockTree(Intercept::class, ['intercept' => false]),
50 $this->mockTree(Intercept::class, ['intercept' => true]),
51 ]]));
52
53 $this->assertTrue($instance->shouldInterceptRequest());
54 }
55
56 public function testExecute(): void
57 {
58 $ctrl = $this->mock(ilCtrl::class);
59 $ctrl->expects(self::once())->method('setParameterByClass')->with('foo', 'id', 'baz');
60 $ctrl->expects(self::once())->method('getLinkTargetByClass')->with(['foo'], 'bar')->willReturn('link');
61 $ctrl->expects(self::once())->method('redirectToURL')->with('link');
62
63 $instance = new StartUpStep($ctrl, $this->mockTree(Conductor::class, ['intercepting' => [
64 $this->mockTree(Intercept::class, ['intercept' => false, 'id' => 'ho', 'target' => ['guiName' => 'dummy', 'guiPath' => ['dummy'], 'command' => 'hej']]),
65 $this->mockTree(Intercept::class, ['intercept' => true, 'id' => 'baz', 'target' => ['guiName' => 'foo', 'guiPath' => ['foo'], 'command' => 'bar']]),
66 ]]));
67
68 $instance->execute();
69 }
70
71 public function testIsInFulfillment(): void
72 {
73 $ctrl = $this->mockTree(ilCtrl::class, ['getCmdClass' => 'foo']);
74
75 $instance = new StartUpStep($ctrl, $this->mockTree(Conductor::class, ['intercepting' => [
76 $this->mockTree(Intercept::class, ['intercept' => true, 'target' => ['guiName' => 'HEJ']]),
77 $this->mockTree(Intercept::class, ['intercept' => true, 'target' => ['guiName' => 'FOO']]),
78 ]]));
79
80 $this->assertTrue($instance->isInFulfillment());
81 }
82}
Class ilCtrl provides processing control methods.