ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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 32 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 223 of file ilCtrlTest.php.

224 {
225 return new ilCtrl(
226 $this->createMock(ilCtrlStructureInterface::class),
227 $this->createMock(ilCtrlTokenRepositoryInterface::class),
228 $this->createMock(ilCtrlPathFactoryInterface::class),
229 $this->createMock(ilCtrlContextInterface::class),
230 $this->createMock(ResponseSenderStrategy::class),
231 $this->createMock(ServerRequestInterface::class),
232 $this->createMock(RequestWrapper::class),
233 $this->createMock(RequestWrapper::class),
234 $this->createMock(Refinery::class),
235 $this->createMock(ilComponentFactory::class),
236 new ilCtrlSubject(),
237 $this->createMock(ilCtrlQueryParserInterface::class),
238 );
239 }
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 43 of file ilCtrlTest.php.

43 : void
44 {
45 $structure = $this->createMock(ilCtrlStructureInterface::class);
47 ->method('isBaseClass')
48 ->willReturn(false)
49 ;
50
51 $ctrl = new ilCtrl(
53 $this->createMock(ilCtrlTokenRepositoryInterface::class),
54 $this->createMock(ilCtrlPathFactoryInterface::class),
55 $this->createMock(ilCtrlContextInterface::class),
56 $this->createMock(ResponseSenderStrategy::class),
57 $this->createMock(ServerRequestInterface::class),
58 $this->createMock(RequestWrapper::class),
59 $this->createMock(RequestWrapper::class),
60 $this->createMock(Refinery::class),
61 $this->createMock(ilComponentFactory::class),
62 new ilCtrlSubject(),
63 $this->createMock(ilCtrlQueryParserInterface::class),
64 );
65
66 $invalid_baseclass = ilCtrlInvalidGuiClass::class;
67
68 $this->expectException(ilCtrlException::class);
69 $this->expectExceptionMessage("Provided class '$invalid_baseclass' is not a baseclass");
70 $ctrl->callBaseClass($invalid_baseclass);
71 }
$structure
TOTAL STRUCTURE.

References $structure.

◆ testCallBaseClassWithoutBaseClass()

ilCtrlTest::testCallBaseClassWithoutBaseClass ( )

Definition at line 34 of file ilCtrlTest.php.

34 : void
35 {
36 $ctrl = $this->getMockedCtrl();
37
38 $this->expectException(ilCtrlException::class);
39 $this->expectExceptionMessage(ilCtrl::class . "::callBaseClass was not given a baseclass and the request doesn't include one either.");
40 $ctrl->callBaseClass();
41 }
getMockedCtrl()
Helper function that returns an ilCtrl instance with mocked dependencies.
Definition: ilCtrlTest.php:223

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testForwardCommandWithInvalidObject()

ilCtrlTest::testForwardCommandWithInvalidObject ( )

Definition at line 73 of file ilCtrlTest.php.

73 : void
74 {
75 $ctrl = $this->getMockedCtrl();
76
77 require_once __DIR__ . '/Data/GUI/class.ilCtrlInvalidGuiClass.php';
78
79 $this->expectException(ilCtrlException::class);
80 $this->expectExceptionMessage(ilCtrlInvalidGuiClass::class . " doesn't implement executeCommand().");
81 $ctrl->forwardCommand(new ilCtrlInvalidGuiClass());
82 }
Class ilCtrlInvalidGuiClass.

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testForwardCommandWithValidObject()

ilCtrlTest::testForwardCommandWithValidObject ( )

Definition at line 84 of file ilCtrlTest.php.

84 : void
85 {
86 $ctrl = $this->getMockedCtrl();
87
88 require_once __DIR__ . '/Data/GUI/class.ilCtrlCommandClass1TestGUI.php';
89
90 $this->assertEquals(
91 ilCtrlCommandClass1TestGUI::class,
92 $ctrl->forwardCommand(new ilCtrlCommandClass1TestGUI())
93 );
94 }
Class ilCtrlCommandClass1TestGUI.

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetCmdWithoutProvidedCmd()

ilCtrlTest::testGetCmdWithoutProvidedCmd ( )

Definition at line 125 of file ilCtrlTest.php.

125 : void
126 {
127 $ctrl = $this->getMockedCtrl();
128
129 // @TODO: change this to assertNull() once null coalescing operators are removed.
130 $this->assertEmpty($ctrl->getCmd());
131 }

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetCmdWithoutProvidedCmdAndFallback()

ilCtrlTest::testGetCmdWithoutProvidedCmdAndFallback ( )

Definition at line 133 of file ilCtrlTest.php.

133 : void
134 {
135 $ctrl = new ilCtrl(
136 $this->createMock(ilCtrlStructureInterface::class),
137 $this->createMock(ilCtrlTokenRepositoryInterface::class),
138 $this->createMock(ilCtrlPathFactoryInterface::class),
139 $this->createMock(ilCtrlContextInterface::class),
140 $this->createMock(ResponseSenderStrategy::class),
141 $this->createMock(ServerRequestInterface::class),
142 $this->createMock(RequestWrapper::class),
143 $this->createMock(RequestWrapper::class),
144 $this->createMock(Refinery::class),
145 $this->createMock(ilComponentFactory::class),
146 new ilCtrlSubject(),
147 $this->createMock(ilCtrlQueryParserInterface::class),
148 );
149
150 $fallback_cmd = 'fallback_cmd_test';
151
152 $this->assertEquals(
153 $fallback_cmd,
154 $ctrl->getCmd($fallback_cmd)
155 );
156 }

◆ testGetHtmlWithInvalidObject()

ilCtrlTest::testGetHtmlWithInvalidObject ( )

Definition at line 96 of file ilCtrlTest.php.

96 : void
97 {
98 $ctrl = $this->getMockedCtrl();
99
100 require_once __DIR__ . '/Data/GUI/class.ilCtrlInvalidGuiClass.php';
101
102 $this->expectException(ilCtrlException::class);
103 $this->expectExceptionMessage(ilCtrlInvalidGuiClass::class . " doesn't implement getHTML().");
104 $ctrl->getHTML(new ilCtrlInvalidGuiClass());
105 }

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetHtmlWithValidObject()

ilCtrlTest::testGetHtmlWithValidObject ( )

Definition at line 107 of file ilCtrlTest.php.

107 : void
108 {
109 $ctrl = $this->getMockedCtrl();
110
111 require_once __DIR__ . '/Data/GUI/class.ilCtrlCommandClass2TestGUI.php';
112
113 $this->assertEquals('foo', $ctrl->getHTML(new ilCtrlCommandClass2TestGUI()));
114 }
Class ilCtrlCommandClass2TestGUI.

References getMockedCtrl().

+ Here is the call graph for this function:

◆ testGetHtmlWithValidObjectAndParameters()

ilCtrlTest::testGetHtmlWithValidObjectAndParameters ( )

Definition at line 116 of file ilCtrlTest.php.

116 : void
117 {
118 $ctrl = $this->getMockedCtrl();
119
120 require_once __DIR__ . '/Data/GUI/class.ilCtrlCommandClass2TestGUI.php';
121
122 $this->assertEquals('bar', $ctrl->getHTML(new ilCtrlCommandClass2TestGUI(), ['bar']));
123 }

References getMockedCtrl().

+ Here is the call graph for this function:

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