ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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)
 

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 ()
 

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 <dialog class="c-modal c-modal--interruptive" tabindex="-1" 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">
121  <button formmethod="dialog" class="close" aria-label="cancel"><span aria-hidden="true">&times;</span></button>
122  <h1 class="modal-title">Title</h1>
123  </div>
124  <div class="modal-body">
125  <div class="alert alert-warning c-modal--interruptive__message" role="alert">Message</div>
126 EOT;
127  $expected_items = <<<EOT
128  <div class="c-modal--interruptive__items">
129  <table>
130  standard1
131  standard2
132  </table>
133  </div>
134  <div class="c-modal--interruptive__items">
135  <dl>
136  keyvalue1
137  keyvalue2
138  keyvalue3
139  </dl>
140  </div>
141 EOT;
142  $expected_end = <<<EOT
143  </div>
144  <div class="modal-footer">
145  <input type="submit" class="btn btn-primary" value="delete"/>
146  <button formmethod="dialog" class="btn btn-default" data-dismiss="modal">cancel</button>
147  </div>
148  </div>
149  </form>
150  </div>
151 </dialog>
152 EOT;
153  if ($with_items) {
154  return $expected_start . $expected_items . $expected_end;
155  }
156  return $expected_start . $expected_end;
157  }
button(string $caption, string $cmd)
Title class.
Definition: Title.php:41
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:50
+ 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:50
+ 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:50
+ 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:50
+ Here is the call graph for this function:

◆ testLabels()

InterruptiveTest::testLabels ( )

Definition at line 160 of file InterruptiveTest.php.

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

◆ testRenderingWithItems()

InterruptiveTest::testRenderingWithItems ( )

Definition at line 82 of file InterruptiveTest.php.

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

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)
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
normalizeHTML(string $html)
Definition: ModalBase.php:75
getModalFactory()
Definition: ModalBase.php:50
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 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)
getModalFactory()
Definition: ModalBase.php:50
+ 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:50
+ 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:50
+ Here is the call graph for this function:

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