ILIAS  trunk Revision v11.0_alpha-1713-gd8962da2f67
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
StandardInterruptiveItemTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 require_once("vendor/composer/vendor/autoload.php");
22 require_once(__DIR__ . "../../../../Base.php");
23 
24 use ILIAS\UI\Component as C;
27 
29 {
30  private string $id;
31  private string $title;
32  private I\Image\Image $image;
33  private string $description;
34 
35  public function setUp(): void
36  {
37  $this->id = 'id';
38  $this->title = 'title';
39  $this->image = new I\Image\Image(C\Image\Image::STANDARD, 'path', 'alt');
40  $this->description = 'description';
41  }
42 
43  protected function getItem(): Standard
44  {
45  return new Standard(
46  $this->id,
47  $this->title,
48  $this->image,
49  $this->description
50  );
51  }
52 
53  protected function getItemWithoutDescription(): Standard
54  {
55  return new Standard(
56  $this->id,
57  $this->title,
58  $this->image
59  );
60  }
61 
62  protected function getItemWithoutIcon(): Standard
63  {
64  return new Standard(
65  $this->id,
66  $this->title,
67  null,
68  $this->description
69  );
70  }
71 
72  public function testGetTitle(): void
73  {
74  $item = $this->getItem();
75  $this->assertEquals($this->title, $item->getTitle());
76  }
77 
78  public function testGetIcon(): void
79  {
80  $item = $this->getItem();
81  $this->assertEquals($this->image, $item->getIcon());
82  $item = $this->getItemWithoutIcon();
83  $this->assertNull($item->getIcon());
84  }
85 
86  public function testGetDescription(): void
87  {
88  $item = $this->getItem();
89  $this->assertEquals($this->description, $item->getDescription());
90  $item = $this->getItemWithoutDescription();
91  $this->assertEquals('', $item->getDescription());
92  }
93 
94  public function testRender(): void
95  {
96  $r = $this->getDefaultRenderer();
97  $html = $r->render($this->getItem());
98 
99  $expected = <<<EOT
100 <tr class="c-modal--interruptive__items__standard">
101  <td>
102  <img src="path" class="img-standard" alt="alt" />
103  </td>
104  <td>
105  title <br>
106  description
107  </td>
108  <td>
109  <input type="hidden" name="interruptive_items[]" value="id">
110  </td>
111 </tr>
112 EOT;
113 
114  $this->assertEquals(
115  $this->brutallyTrimHTML($expected),
116  $this->brutallyTrimHTML($html)
117  );
118  }
119 
120  public function testRenderWithoutDescription(): void
121  {
122  $r = $this->getDefaultRenderer();
123  $html = $r->render($this->getItemWithoutDescription());
124 
125  $expected = <<<EOT
126 <tr class="c-modal--interruptive__items__standard">
127  <td>
128  <img src="path" class="img-standard" alt="alt" />
129  </td>
130  <td>
131  title
132  </td>
133  <td>
134  <input type="hidden" name="interruptive_items[]" value="id">
135  </td>
136 </tr>
137 EOT;
138 
139  $this->assertEquals(
140  $this->brutallyTrimHTML($expected),
141  $this->brutallyTrimHTML($html)
142  );
143  }
144 
145  public function testRenderWithoutIcon(): void
146  {
147  $r = $this->getDefaultRenderer();
148  $html = $r->render($this->getItemWithoutIcon());
149 
150  $expected = <<<EOT
151 <tr class="c-modal--interruptive__items__standard">
152  <td></td>
153  <td>
154  title <br>
155  description
156  </td>
157  <td>
158  <input type="hidden" name="interruptive_items[]" value="id">
159  </td>
160 </tr>
161 EOT;
162 
163  $this->assertEquals(
164  $this->brutallyTrimHTML($expected),
165  $this->brutallyTrimHTML($html)
166  );
167  }
168 }
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
$r