ILIAS  release_8 Revision v8.24
ilCtrlTest Class Reference

Class ilCtrlTest. More...

+ Inheritance diagram for ilCtrlTest:
+ Collaboration diagram for ilCtrlTest:

Public Member Functions

 testCallBaseClassWithoutBaseClass ()
 
 testCallBaseClassWithInvalidProvidedBaseClass ()
 
 testForwardCommandWithInvalidObject ()
 
 testForwardCommandWithValidObject ()
 
 testGetHtmlWithInvalidObject ()
 
 testGetHtmlWithValidObject ()
 
 testGetHtmlWithValidObjectAndParameters ()
 
 testGetCmdWithoutProvidedCmd ()
 
 testGetCmdWithoutProvidedCmdAndFallback ()
 

Private Member Functions

 getMockedCtrl ()
 Helper function that returns an ilCtrl instance with mocked dependencies. More...
 

Detailed Description

Class ilCtrlTest.

Author
Thibeau Fuhrer thf@s.nosp@m.tude.nosp@m.r-rai.nosp@m.mann.nosp@m..ch

Definition at line 18 of file ilCtrlTest.php.

Member Function Documentation

◆ getMockedCtrl()

ilCtrlTest::getMockedCtrl ( )
private

Helper function that returns an ilCtrl instance with mocked dependencies.

Returns
ilCtrlInterface

Definition at line 207 of file ilCtrlTest.php.

208 {
209 return new ilCtrl(
210 $this->createMock(ilCtrlStructureInterface::class),
211 $this->createMock(ilCtrlTokenRepositoryInterface::class),
212 $this->createMock(ilCtrlPathFactoryInterface::class),
213 $this->createMock(ilCtrlContextInterface::class),
214 $this->createMock(ResponseSenderStrategy::class),
215 $this->createMock(ServerRequestInterface::class),
216 $this->createMock(RequestWrapper::class),
217 $this->createMock(RequestWrapper::class),
218 $this->createMock(Refinery::class),
219 $this->createMock(ilComponentFactory::class),
220 $this->createMock(ilCtrlQueryParserInterface::class)
221 );
222 }
Class ilCtrl provides processing control methods.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

Referenced by testCallBaseClassWithoutBaseClass(), testForwardCommandWithInvalidObject(), testForwardCommandWithValidObject(), testGetCmdWithoutProvidedCmd(), testGetHtmlWithInvalidObject(), testGetHtmlWithValidObject(), and testGetHtmlWithValidObjectAndParameters().

+ Here is the caller graph for this function:

◆ testCallBaseClassWithInvalidProvidedBaseClass()

ilCtrlTest::testCallBaseClassWithInvalidProvidedBaseClass ( )

Definition at line 29 of file ilCtrlTest.php.

29 : void
30 {
31 $structure = $this->createMock(ilCtrlStructureInterface::class);
32 $structure
33 ->method('isBaseClass')
34 ->willReturn(false)
35 ;
36
37 $ctrl = new ilCtrl(
38 $structure,
39 $this->createMock(ilCtrlTokenRepositoryInterface::class),
40 $this->createMock(ilCtrlPathFactoryInterface::class),
41 $this->createMock(ilCtrlContextInterface::class),
42 $this->createMock(ResponseSenderStrategy::class),
43 $this->createMock(ServerRequestInterface::class),
44 $this->createMock(RequestWrapper::class),
45 $this->createMock(RequestWrapper::class),
46 $this->createMock(Refinery::class),
47 $this->createMock(ilComponentFactory::class),
48 $this->createMock(ilCtrlQueryParserInterface::class)
49 );
50
51 $invalid_baseclass = ilCtrlInvalidGuiClass::class;
52
53 $this->expectException(ilCtrlException::class);
54 $this->expectExceptionMessage("Provided class '$invalid_baseclass' is not a baseclass");
55 $ctrl->callBaseClass($invalid_baseclass);
56 }

◆ testCallBaseClassWithoutBaseClass()

ilCtrlTest::testCallBaseClassWithoutBaseClass ( )

Definition at line 20 of file ilCtrlTest.php.

20 : void
21 {
22 $ctrl = $this->getMockedCtrl();
23
24 $this->expectException(ilCtrlException::class);
25 $this->expectExceptionMessage(ilCtrl::class . "::callBaseClass was not given a baseclass and the request doesn't include one either.");
26 $ctrl->callBaseClass();
27 }
getMockedCtrl()
Helper function that returns an ilCtrl instance with mocked dependencies.
Definition: ilCtrlTest.php:207

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testForwardCommandWithInvalidObject()

ilCtrlTest::testForwardCommandWithInvalidObject ( )

Definition at line 58 of file ilCtrlTest.php.

58 : void
59 {
60 $ctrl = $this->getMockedCtrl();
61
62 require_once __DIR__ . '/Data/GUI/class.ilCtrlInvalidGuiClass.php';
63
64 $this->expectException(ilCtrlException::class);
65 $this->expectExceptionMessage(ilCtrlInvalidGuiClass::class . " doesn't implement executeCommand().");
66 $ctrl->forwardCommand(new ilCtrlInvalidGuiClass());
67 }
Class ilCtrlInvalidGuiClass.

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testForwardCommandWithValidObject()

ilCtrlTest::testForwardCommandWithValidObject ( )

Definition at line 69 of file ilCtrlTest.php.

69 : void
70 {
71 $ctrl = $this->getMockedCtrl();
72
73 require_once __DIR__ . '/Data/GUI/class.ilCtrlCommandClass1TestGUI.php';
74
75 $this->assertEquals(
76 ilCtrlCommandClass1TestGUI::class,
77 $ctrl->forwardCommand(new ilCtrlCommandClass1TestGUI())
78 );
79 }
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetCmdWithoutProvidedCmd()

ilCtrlTest::testGetCmdWithoutProvidedCmd ( )

Definition at line 110 of file ilCtrlTest.php.

110 : void
111 {
112 $ctrl = $this->getMockedCtrl();
113
114 // @TODO: change this to assertNull() once null coalescing operators are removed.
115 $this->assertEmpty($ctrl->getCmd());
116 }

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetCmdWithoutProvidedCmdAndFallback()

ilCtrlTest::testGetCmdWithoutProvidedCmdAndFallback ( )

Definition at line 118 of file ilCtrlTest.php.

118 : void
119 {
120 $ctrl = new ilCtrl(
121 $this->createMock(ilCtrlStructureInterface::class),
122 $this->createMock(ilCtrlTokenRepositoryInterface::class),
123 $this->createMock(ilCtrlPathFactoryInterface::class),
124 $this->createMock(ilCtrlContextInterface::class),
125 $this->createMock(ResponseSenderStrategy::class),
126 $this->createMock(ServerRequestInterface::class),
127 $this->createMock(RequestWrapper::class),
128 $this->createMock(RequestWrapper::class),
129 $this->createMock(Refinery::class),
130 $this->createMock(ilComponentFactory::class),
131 $this->createMock(ilCtrlQueryParserInterface::class)
132 );
133
134 $fallback_cmd = 'fallback_cmd_test';
135
136 $this->assertEquals(
137 $fallback_cmd,
138 $ctrl->getCmd($fallback_cmd)
139 );
140 }

◆ testGetHtmlWithInvalidObject()

ilCtrlTest::testGetHtmlWithInvalidObject ( )

Definition at line 81 of file ilCtrlTest.php.

81 : void
82 {
83 $ctrl = $this->getMockedCtrl();
84
85 require_once __DIR__ . '/Data/GUI/class.ilCtrlInvalidGuiClass.php';
86
87 $this->expectException(ilCtrlException::class);
88 $this->expectExceptionMessage(ilCtrlInvalidGuiClass::class . " doesn't implement getHTML().");
89 $ctrl->getHTML(new ilCtrlInvalidGuiClass());
90 }

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetHtmlWithValidObject()

ilCtrlTest::testGetHtmlWithValidObject ( )

Definition at line 92 of file ilCtrlTest.php.

92 : void
93 {
94 $ctrl = $this->getMockedCtrl();
95
96 require_once __DIR__ . '/Data/GUI/class.ilCtrlCommandClass2TestGUI.php';
97
98 $this->assertEquals('foo', $ctrl->getHTML(new ilCtrlCommandClass2TestGUI()));
99 }
Class ilCtrlCommandClass2TestGUI.

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetHtmlWithValidObjectAndParameters()

ilCtrlTest::testGetHtmlWithValidObjectAndParameters ( )

Definition at line 101 of file ilCtrlTest.php.

101 : void
102 {
103 $ctrl = $this->getMockedCtrl();
104
105 require_once __DIR__ . '/Data/GUI/class.ilCtrlCommandClass2TestGUI.php';
106
107 $this->assertEquals('bar', $ctrl->getHTML(new ilCtrlCommandClass2TestGUI(), ['bar']));
108 }

References getMockedCtrl().

+ Here is the call graph for this function:

The documentation for this class was generated from the following file: