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