ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
InterruptiveTest Class Reference

Tests on implementation for the interruptive modal. More...

+ Inheritance diagram for InterruptiveTest:
+ Collaboration diagram for InterruptiveTest:

Public Member Functions

 testGetTitle ()
 
 testGetMessage ()
 
 testGetFormAction ()
 
 testGetAffectedItems ()
 
 testWithFormAction ()
 
 testWithAffectedItems ()
 
 testSimpleRendering ()
 
 testRenderingWithItems ()
 
 testLabels ()
 
- Public Member Functions inherited from ModalBase
 getUIFactory ()
 
 normalizeHTML (string $html)
 
- Public Member Functions inherited from ILIAS_UI_TestBase
 setUp ()
 
 tearDown ()
 
 getUIFactory ()
 
 getTemplateFactory ()
 
 getResourceRegistry ()
 
 getLanguage ()
 
 getJavaScriptBinding ()
 
 getRefinery ()
 
 getImagePathResolver ()
 
 getDataFactory ()
 
 getHelpTextRetriever ()
 
 getUploadLimitResolver ()
 
 getDefaultRenderer (JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
 
 getDecoratedRenderer (Renderer $default)
 
 normalizeHTML (string $html)
 
 assertHTMLEquals (string $expected_html_as_string, string $html_as_string)
 

Protected Member Functions

 getInterruptiveItem ()
 
 getStandardInterruptiveItem (string $canonical_name)
 
 getKeyValueInterruptiveItem (string $canonical_name)
 
 getExpectedHTML (bool $with_items=false)
 
- Protected Member Functions inherited from ModalBase
 getModalFactory ()
 
 getButtonFactory ()
 
 getDummyComponent ()
 
- Protected Member Functions inherited from ILIAS_UI_TestBase
 brutallyTrimHTML (string $html)
 A more radical version of normalizeHTML. More...
 
 brutallyTrimSignals (string $html)
 A naive replacement of all il_signal-ids with dots to ease comparisons of rendered output. More...
 

Detailed Description

Tests on implementation for the interruptive modal.

Definition at line 29 of file InterruptiveTest.php.

Member Function Documentation

◆ getExpectedHTML()

InterruptiveTest::getExpectedHTML ( bool  $with_items = false)
protected

Definition at line 113 of file InterruptiveTest.php.

References ILIAS\Repository\button(), and ILIAS\Repository\form().

Referenced by testRenderingWithItems(), and testSimpleRendering().

113  : string
114  {
115  $expected_start = <<<EOT
116 <div class="modal fade c-modal--interruptive" tabindex="-1" role="dialog" id="id_1">
117  <div class="modal-dialog" role="document">
118  <form action="myAction.php" method="POST">
119  <div class="modal-content">
120  <div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="cancel">
121  <span aria-hidden="true">&times;</span></button><h1 class="modal-title">Title</h1>
122  </div>
123  <div class="modal-body">
124  <div class="alert alert-warning c-modal--interruptive__message" role="alert">Message</div>
125 EOT;
126  $expected_items = <<<EOT
127  <div class="c-modal--interruptive__items">
128  <table>
129  standard1
130  standard2
131  </table>
132  </div>
133  <div class="c-modal--interruptive__items">
134  <dl>
135  keyvalue1
136  keyvalue2
137  keyvalue3
138  </dl>
139  </div>
140 EOT;
141  $expected_end = <<<EOT
142  </div>
143  <div class="modal-footer">
144  <input type="submit" class="btn btn-primary" value="delete"/>
145  <button class="btn btn-default" data-dismiss="modal">cancel</button>
146  </div>
147  </div>
148  </form>
149  </div>
150 </div>
151 EOT;
152  if ($with_items) {
153  return $expected_start . $expected_items . $expected_end;
154  }
155  return $expected_start . $expected_end;
156  }
button(string $caption, string $cmd)
Title class.
Definition: Title.php:26
form( $class_path, string $cmd, string $submit_caption="")
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getInterruptiveItem()

InterruptiveTest::getInterruptiveItem ( )
protected

Definition at line 98 of file InterruptiveTest.php.

Referenced by testGetAffectedItems(), and testWithAffectedItems().

99  {
100  return new InterruptiveItemMock();
101  }
+ Here is the caller graph for this function:

◆ getKeyValueInterruptiveItem()

InterruptiveTest::getKeyValueInterruptiveItem ( string  $canonical_name)
protected

Definition at line 108 of file InterruptiveTest.php.

Referenced by testRenderingWithItems().

109  {
110  return new KeyValueItemMock($canonical_name);
111  }
+ Here is the caller graph for this function:

◆ getStandardInterruptiveItem()

InterruptiveTest::getStandardInterruptiveItem ( string  $canonical_name)
protected

Definition at line 103 of file InterruptiveTest.php.

Referenced by testRenderingWithItems().

104  {
105  return new StandardItemMock($canonical_name);
106  }
+ Here is the caller graph for this function:

◆ testGetAffectedItems()

InterruptiveTest::testGetAffectedItems ( )

Definition at line 49 of file InterruptiveTest.php.

References getInterruptiveItem(), and ModalBase\getModalFactory().

49  : void
50  {
51  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
52  $items = [$this->getInterruptiveItem(), $this->getInterruptiveItem()];
53  $interruptive = $interruptive->withAffectedItems($items);
54  $this->assertEquals($items, $interruptive->getAffectedItems());
55  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testGetFormAction()

InterruptiveTest::testGetFormAction ( )

Definition at line 43 of file InterruptiveTest.php.

References ModalBase\getModalFactory().

43  : void
44  {
45  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
46  $this->assertEquals('myFormAction', $interruptive->getFormAction());
47  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testGetMessage()

InterruptiveTest::testGetMessage ( )

Definition at line 37 of file InterruptiveTest.php.

References ModalBase\getModalFactory().

37  : void
38  {
39  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
40  $this->assertEquals('myMessage', $interruptive->getMessage());
41  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testGetTitle()

InterruptiveTest::testGetTitle ( )

Definition at line 31 of file InterruptiveTest.php.

References ModalBase\getModalFactory().

31  : void
32  {
33  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
34  $this->assertEquals('myTitle', $interruptive->getTitle());
35  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testLabels()

InterruptiveTest::testLabels ( )

Definition at line 159 of file InterruptiveTest.php.

References ModalBase\getModalFactory().

159  : void
160  {
161  $action_label = 'actionlabel';
162  $cancel_label = 'cancellabel';
163  $interruptive = $this->getModalFactory()->interruptive('Title', 'Message', 'someaction')
164  ->withActionButtonLabel($action_label)
165  ->withCancelButtonLabel($cancel_label);
166 
167  $this->assertEquals(
168  $action_label,
169  $interruptive->getActionButtonLabel()
170  );
171  $this->assertEquals(
172  $cancel_label,
173  $interruptive->getCancelButtonLabel()
174  );
175  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testRenderingWithItems()

InterruptiveTest::testRenderingWithItems ( )

Definition at line 82 of file InterruptiveTest.php.

References ILIAS_UI_TestBase\getDefaultRenderer(), getExpectedHTML(), getKeyValueInterruptiveItem(), ModalBase\getModalFactory(), getStandardInterruptiveItem(), and ModalBase\normalizeHTML().

82  : void
83  {
84  $interruptive = $this->getModalFactory()->interruptive('Title', 'Message', 'myAction.php');
85  $items = [
86  $this->getKeyValueInterruptiveItem('keyvalue1'),
87  $this->getStandardInterruptiveItem('standard1'),
88  $this->getKeyValueInterruptiveItem('keyvalue2'),
89  $this->getKeyValueInterruptiveItem('keyvalue3'),
90  $this->getStandardInterruptiveItem('standard2')
91  ];
92  $interruptive = $interruptive->withAffectedItems($items);
93  $expected = $this->normalizeHTML($this->getExpectedHTML(true));
94  $actual = $this->normalizeHTML($this->getDefaultRenderer(null, $items)->render($interruptive));
95  $this->assertEquals($expected, $actual);
96  }
getExpectedHTML(bool $with_items=false)
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
normalizeHTML(string $html)
Definition: ModalBase.php:76
getModalFactory()
Definition: ModalBase.php:51
getKeyValueInterruptiveItem(string $canonical_name)
getStandardInterruptiveItem(string $canonical_name)
+ Here is the call graph for this function:

◆ testSimpleRendering()

InterruptiveTest::testSimpleRendering ( )

Definition at line 74 of file InterruptiveTest.php.

References ILIAS_UI_TestBase\brutallyTrimHTML(), ILIAS_UI_TestBase\getDefaultRenderer(), getExpectedHTML(), and ModalBase\getModalFactory().

74  : void
75  {
76  $interruptive = $this->getModalFactory()->interruptive('Title', 'Message', 'myAction.php');
77  $expected = $this->brutallyTrimHTML($this->getExpectedHTML());
78  $actual = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($interruptive));
79  $this->assertEquals($expected, $actual);
80  }
getExpectedHTML(bool $with_items=false)
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testWithAffectedItems()

InterruptiveTest::testWithAffectedItems ( )

Definition at line 65 of file InterruptiveTest.php.

References getInterruptiveItem(), and ModalBase\getModalFactory().

65  : void
66  {
67  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
68  $items = [$this->getInterruptiveItem(), $this->getInterruptiveItem()];
69  $interruptive2 = $interruptive->withAffectedItems($items);
70  $this->assertEquals(0, count($interruptive->getAffectedItems()));
71  $this->assertEquals($items, $interruptive2->getAffectedItems());
72  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

◆ testWithFormAction()

InterruptiveTest::testWithFormAction ( )

Definition at line 57 of file InterruptiveTest.php.

References ModalBase\getModalFactory().

57  : void
58  {
59  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
60  $interruptive2 = $interruptive->withFormAction('myFormAction2');
61  $this->assertEquals('myFormAction', $interruptive->getFormAction());
62  $this->assertEquals('myFormAction2', $interruptive2->getFormAction());
63  }
getModalFactory()
Definition: ModalBase.php:51
+ Here is the call graph for this function:

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