ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
ilSystemStyleMessageStackTest Class Reference
+ Inheritance diagram for ilSystemStyleMessageStackTest:
+ Collaboration diagram for ilSystemStyleMessageStackTest:

Public Member Functions

 testPrependMessage ()
 
 testAddMessage ()
 
 testJoinedMessages ()
 
 testGetUIComponentsMessages ()
 
 testGetAndSetMessages ()
 
 testHasMessages ()
 

Protected Member Functions

 createTestEnvironment ()
 

Protected Attributes

ilSystemStyleMessage $ilSystemStyleMessage
 
string $messageStringOne = 'This is a message'
 
string $messageStringTwo = 'Godzilla has taken over the world.'
 
string $messageStringThree = 'A small, cute cat destroyed Godzilla.'
 
array $messages = []
 
ilSystemStyleMessageStack $ilSystemStyleMessageStack
 

Detailed Description

Definition at line 27 of file ilSystemStyleMessageStackTest.php.

Member Function Documentation

◆ createTestEnvironment()

ilSystemStyleMessageStackTest::createTestEnvironment ( )
protected

Definition at line 222 of file ilSystemStyleMessageStackTest.php.

References ilSystemStyleMessage\TYPE_INFO.

Referenced by testAddMessage(), testGetAndSetMessages(), testGetUIComponentsMessages(), testHasMessages(), testJoinedMessages(), and testPrependMessage().

222  : void
223  {
225  $this->messageStringOne,
227  );
229  $this->getMockBuilder(ilGlobalTemplateInterface::class)->getMock()
230  );
231  }
Used to stack messages to be shown to the user.
+ Here is the caller graph for this function:

◆ testAddMessage()

ilSystemStyleMessageStackTest::testAddMessage ( )

Definition at line 69 of file ilSystemStyleMessageStackTest.php.

References ilSystemStyleMessageStack\addMessage(), createTestEnvironment(), ilSystemStyleMessageStack\getMessages(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleMessage\TYPE_INFO, and ilSystemStyleMessage\TYPE_SUCCESS.

69  : void
70  {
71  $this->createTestEnvironment();
72 
74 
76  $this->messageStringTwo,
78  );
80 
82  $this->messageStringThree,
84  );
86  $this->messages = $this->ilSystemStyleMessageStack->getMessages();
87 
88  $this->assertTrue($this->messages[2]->getMessage() === $this->messageStringThree);
89  $this->assertTrue($this->messages[2]->getTypeId() === ilSystemStyleMessage::TYPE_ERROR);
90 
91  $this->assertTrue($this->messages[1]->getMessage() === $this->messageStringTwo);
92  $this->assertTrue($this->messages[1]->getTypeId() === ilSystemStyleMessage::TYPE_SUCCESS);
93 
94  $this->assertTrue($this->messages[0]->getMessage() === $this->messageStringOne);
95  $this->assertTrue($this->messages[0]->getTypeId() === ilSystemStyleMessage::TYPE_INFO);
96  }
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
Used to stack messages to be shown to the user.
+ Here is the call graph for this function:

◆ testGetAndSetMessages()

ilSystemStyleMessageStackTest::testGetAndSetMessages ( )

Definition at line 194 of file ilSystemStyleMessageStackTest.php.

References $messageStringTwo, ilSystemStyleMessageStack\addMessage(), createTestEnvironment(), ilSystemStyleMessageStack\getMessages(), and ilSystemStyleMessage\TYPE_SUCCESS.

194  : void
195  {
196  $this->createTestEnvironment();
197 
199 
201  $this->messageStringTwo,
203  );
205 
206  $this->assertTrue($this->ilSystemStyleMessageStack->getMessages()[1]->getMessage() === $this->messageStringTwo);
207  $this->ilSystemStyleMessageStack->getMessages()[1]->setMessage('Godzilla has NOT taken over the world.');
208  $this->assertTrue($this->ilSystemStyleMessageStack->getMessages()[1]->getMessage() === 'Godzilla has NOT taken over the world.');
209  }
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
Used to stack messages to be shown to the user.
+ Here is the call graph for this function:

◆ testGetUIComponentsMessages()

ilSystemStyleMessageStackTest::testGetUIComponentsMessages ( )

Definition at line 142 of file ilSystemStyleMessageStackTest.php.

References ilSystemStyleMessageStack\addMessage(), createTestEnvironment(), ILIAS\UI\Implementation\Component\Progress\State\Bar\FAILURE, ilSystemStyleMessageStack\getUIComponentsMessages(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleMessage\TYPE_SUCCESS, and UITestHelper.

142  : void
143  {
144  $this->createTestEnvironment();
145 
147 
149  $this->messageStringTwo,
151  );
153 
155  'Another SUCCESS message',
157  );
159 
161  $this->messageStringThree,
163  );
165 
167  'Another ERROR message',
169  );
171 
173  'YET another ERROR message',
175  );
177 
178  $ui_helper = new UITestHelper();
179 
180  $message_components = $this->ilSystemStyleMessageStack->getUIComponentsMessages($ui_helper->factory());
181 
182  $this->assertCount(3, $message_components);
183  $this->assertInstanceOf(IMessageBox::class, $message_components[0]);
184  $this->assertInstanceOf(IMessageBox::class, $message_components[1]);
185  $this->assertInstanceOf(IMessageBox::class, $message_components[2]);
186 
187  $this->assertEquals(ILIAS\UI\Component\MessageBox\MessageBox::INFO, $message_components[0]->getType());
188  $this->assertEquals(ILIAS\UI\Component\MessageBox\MessageBox::SUCCESS, $message_components[1]->getType());
189  $this->assertEquals(ILIAS\UI\Component\MessageBox\MessageBox::FAILURE, $message_components[2]->getType());
190 
191  $this->assertEquals('This is a message</br>', $message_components[0]->getMessageText());
192  }
Interface Observer Contains several chained tasks and infos about them.
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
The progress of the process/task cannot be calculated (yet), but it has started processing.
Definition: Status.php:42
getUIComponentsMessages(\ILIAS\UI\Factory $f)
Return Messages as UI Component.
Used to stack messages to be shown to the user.
trait UITestHelper
Class UITestHelper can be helpful for test cases outside the UI Components, to inject a working facto...
+ Here is the call graph for this function:

◆ testHasMessages()

ilSystemStyleMessageStackTest::testHasMessages ( )

Definition at line 211 of file ilSystemStyleMessageStackTest.php.

References ilSystemStyleMessageStack\addMessage(), createTestEnvironment(), and ilSystemStyleMessageStack\hasMessages().

211  : void
212  {
213  $this->createTestEnvironment();
214 
215  $this->assertFalse($this->ilSystemStyleMessageStack->hasMessages());
216 
218 
219  $this->assertTrue($this->ilSystemStyleMessageStack->hasMessages());
220  }
hasMessages()
Return wheter there are any message at all stored in the stack.
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
Used to stack messages to be shown to the user.
+ Here is the call graph for this function:

◆ testJoinedMessages()

ilSystemStyleMessageStackTest::testJoinedMessages ( )

Definition at line 98 of file ilSystemStyleMessageStackTest.php.

References ilSystemStyleMessageStack\addMessage(), createTestEnvironment(), ilSystemStyleMessageStack\getJoinedMessages(), ilSystemStyleMessage\TYPE_ERROR, and ilSystemStyleMessage\TYPE_SUCCESS.

98  : void
99  {
100  $this->createTestEnvironment();
101 
103 
105  $this->messageStringTwo,
107  );
109 
111  'Another SUCCESS message',
113  );
115 
117  $this->messageStringThree,
119  );
121 
123  'Another ERROR message',
125  );
127 
129  'YET another ERROR message',
131  );
133 
134  $this->assertTrue(count($this->ilSystemStyleMessageStack->getJoinedMessages()) === 3);
135  $this->assertTrue($this->ilSystemStyleMessageStack->getJoinedMessages()[0] === $this->messageStringOne . '</br>');
136  $this->assertTrue($this->ilSystemStyleMessageStack->getJoinedMessages()[1] === $this->messageStringTwo .
137  '</br>' . 'Another SUCCESS message' . '</br>');
138  $this->assertTrue($this->ilSystemStyleMessageStack->getJoinedMessages()[2] === $this->messageStringThree .
139  '</br>' . 'Another ERROR message' . '</br>' . 'YET another ERROR message' . '</br>');
140  }
addMessage(ilSystemStyleMessage $message)
Add a message to be displayed by the stack.
Used to stack messages to be shown to the user.
getJoinedMessages()
Return an array containing a string with all messages for each type.
+ Here is the call graph for this function:

◆ testPrependMessage()

ilSystemStyleMessageStackTest::testPrependMessage ( )

Definition at line 40 of file ilSystemStyleMessageStackTest.php.

References createTestEnvironment(), ilSystemStyleMessageStack\getMessages(), ilSystemStyleMessageStack\prependMessage(), ilSystemStyleMessage\TYPE_ERROR, ilSystemStyleMessage\TYPE_INFO, and ilSystemStyleMessage\TYPE_SUCCESS.

40  : void
41  {
42  $this->createTestEnvironment();
43 
45 
47  $this->messageStringTwo,
49  );
51 
53  $this->messageStringThree,
55  );
57  $this->messages = $this->ilSystemStyleMessageStack->getMessages();
58 
59  $this->assertTrue($this->messages[0]->getMessage() === $this->messageStringThree);
60  $this->assertTrue($this->messages[0]->getTypeId() === ilSystemStyleMessage::TYPE_ERROR);
61 
62  $this->assertTrue($this->messages[1]->getMessage() === $this->messageStringTwo);
63  $this->assertTrue($this->messages[1]->getTypeId() === ilSystemStyleMessage::TYPE_SUCCESS);
64 
65  $this->assertTrue($this->messages[2]->getMessage() === $this->messageStringOne);
66  $this->assertTrue($this->messages[2]->getTypeId() === ilSystemStyleMessage::TYPE_INFO);
67  }
prependMessage(ilSystemStyleMessage $message)
Add a message to be displayed before all others.
Used to stack messages to be shown to the user.
+ Here is the call graph for this function:

Field Documentation

◆ $ilSystemStyleMessage

ilSystemStyleMessage ilSystemStyleMessageStackTest::$ilSystemStyleMessage
protected

Definition at line 29 of file ilSystemStyleMessageStackTest.php.

◆ $ilSystemStyleMessageStack

ilSystemStyleMessageStack ilSystemStyleMessageStackTest::$ilSystemStyleMessageStack
protected

Definition at line 38 of file ilSystemStyleMessageStackTest.php.

◆ $messages

array ilSystemStyleMessageStackTest::$messages = []
protected

Definition at line 37 of file ilSystemStyleMessageStackTest.php.

◆ $messageStringOne

string ilSystemStyleMessageStackTest::$messageStringOne = 'This is a message'
protected

Definition at line 31 of file ilSystemStyleMessageStackTest.php.

◆ $messageStringThree

string ilSystemStyleMessageStackTest::$messageStringThree = 'A small, cute cat destroyed Godzilla.'
protected

Definition at line 33 of file ilSystemStyleMessageStackTest.php.

◆ $messageStringTwo

string ilSystemStyleMessageStackTest::$messageStringTwo = 'Godzilla has taken over the world.'
protected

Definition at line 32 of file ilSystemStyleMessageStackTest.php.

Referenced by testGetAndSetMessages().


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