ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
InterruptiveTest.php
Go to the documentation of this file.
1 <?php
2 
3 require_once(__DIR__ . '/ModalBase.php');
4 
5 use \ILIAS\UI\Component as C;
6 use \ILIAS\UI\Implementation as I;
7 
14 {
15  public function test_get_title()
16  {
17  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
18  $this->assertEquals('myTitle', $interruptive->getTitle());
19  }
20 
21  public function test_get_message()
22  {
23  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
24  $this->assertEquals('myMessage', $interruptive->getMessage());
25  }
26 
27  public function test_get_form_action()
28  {
29  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
30  $this->assertEquals('myFormAction', $interruptive->getFormAction());
31  }
32 
33  public function test_get_affected_items()
34  {
35  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
36  $items = [$this->getInterruptiveItem(), $this->getInterruptiveItem()];
37  $interruptive = $interruptive->withAffectedItems($items);
38  $this->assertEquals($items, $interruptive->getAffectedItems());
39  }
40 
41  public function test_with_form_action()
42  {
43  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
44  $interruptive2 = $interruptive->withFormAction('myFormAction2');
45  $this->assertEquals('myFormAction', $interruptive->getFormAction());
46  $this->assertEquals('myFormAction2', $interruptive2->getFormAction());
47  }
48 
49  public function test_with_affected_items()
50  {
51  $interruptive = $this->getModalFactory()->interruptive('myTitle', 'myMessage', 'myFormAction');
52  $items = [$this->getInterruptiveItem(), $this->getInterruptiveItem()];
53  $interruptive2 = $interruptive->withAffectedItems($items);
54  $this->assertEquals(0, count($interruptive->getAffectedItems()));
55  $this->assertEquals($items, $interruptive2->getAffectedItems());
56  }
57 
58  public function test_simple_rendering()
59  {
60  $interruptive = $this->getModalFactory()->interruptive('Title', 'Message', 'myAction.php');
61  $expected = $this->normalizeHTML($this->getExpectedHTML());
62  $actual = $this->normalizeHTML($this->getDefaultRenderer()->render($interruptive));
63  $this->assertEquals($expected, $actual);
64  }
65 
66  protected function getInterruptiveItem()
67  {
68  return new InterruptiveItemMock();
69  }
70 
71  protected function getExpectedHTML()
72  {
73  $expected = <<<EOT
74 <div class="modal fade il-modal-interruptive" tabindex="-1" role="dialog" id="id_1">
75  <div class="modal-dialog" role="document">
76  <form action="myAction.php" method="POST">
77  <div class="modal-content">
78  <div class="modal-header"><button type="button" class="close" data-dismiss="modal" aria-label="Close">
79  <span aria-hidden="true"></span></button><h4 class="modal-title">Title</h4>
80  </div>
81  <div class="modal-body">
82  <div class="alert alert-warning il-modal-interruptive-message" role="alert">Message</div>
83  </div>
84  <div class="modal-footer">
85  <input type="submit" class="btn btn-primary" value="delete">
86  <a class="btn btn-default" data-dismiss="modal" aria-label="Close">cancel</a>
87  </div>
88  </div>
89  </form>
90  </div>
91 </div>
92 EOT;
93  return $expected;
94  }
95 }
96 
97 class InterruptiveItemMock implements C\Modal\InterruptiveItem
98 {
99  public function getId()
100  {
101  return 1;
102  }
103 
104  public function getTitle()
105  {
106  return 'title';
107  }
108 
109  public function getDescription()
110  {
111  return 'description';
112  }
113 
114  public function getIcon()
115  {
116  return null;
117  }
118 }
Tests on implementation for the interruptive modal.
Title class.
Definition: Title.php:36
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:228
normalizeHTML($html)
Definition: ModalBase.php:56
Base class for modal tests.
Definition: ModalBase.php:13
input
Definition: langcheck.php:166
getModalFactory()
Definition: ModalBase.php:41
$this data['403_header']