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