ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
CharacteristicValueTextTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once(__DIR__ . '/CharacteristicValueTest.php');
22
24{
25 public function testGetItems(): void
26 {
28
29 $items = $this->getTextItemsMock();
30 $textListing = $f->text($items);
31 $this->assertEquals($items, $textListing->getItems());
32 }
33
34 public function testValidation(): void
35 {
37
38 foreach ($this->getInvalidTextItemsMocks() as $invalidItemsMock) {
39 try {
40 $f->text($invalidItemsMock);
41
42 $this->throwException(new Exception(
43 'expected InvalidArgumentException, catched none'
44 ));
45 } catch (InvalidArgumentException $e) {
46 $this->assertInstanceOf('InvalidArgumentException', $e);
47 }
48 }
49 }
50
51 public function testRendered(): void
52 {
54 $r = $this->getDefaultRenderer();
55
56 $items = $this->getTextItemsMock();
57 $textListing = $f->text($items);
58 $actualHtml = $r->render($textListing);
59
60 $expectedHtml = $this->getExpectedHtml();
61
62 $this->assertHTMLEquals($expectedHtml, $actualHtml);
63 }
64
65 private function getExpectedHtml(): string
66 {
67 $html = '<div class="il-listing-characteristic-value clearfix">';
68 $html .= ' <div class="il-listing-characteristic-value-row clearfix">';
69 $html .= ' <div class="il-listing-characteristic-value-label">label1</div>';
70 $html .= ' <div class="il-listing-characteristic-value-item">item1</div>';
71 $html .= ' </div>';
72 $html .= ' <div class="il-listing-characteristic-value-row clearfix">';
73 $html .= ' <div class="il-listing-characteristic-value-label">label2</div>';
74 $html .= ' <div class="il-listing-characteristic-value-item">item2</div>';
75 $html .= ' </div>';
76 $html .= ' <div class="il-listing-characteristic-value-row clearfix">';
77 $html .= ' <div class="il-listing-characteristic-value-label">label3</div>';
78 $html .= ' <div class="il-listing-characteristic-value-item">item3</div>';
79 $html .= ' </div>';
80 $html .= '</div>';
81
82 return $html;
83 }
84}