ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
CharacteristicValueTextTest.php
Go to the documentation of this file.
1 <?php
2 
3 require_once(__DIR__ . '/CharacteristicValueTest.php');
4 
6 {
7  public function test_getItems()
8  {
10 
11  $items = $this->getTextItemsMock();
12  $textListing = $f->text($items);
13  $this->assertEquals($items, $textListing->getItems());
14  }
15 
16  public function test_validation()
17  {
19 
20  foreach ($this->getInvalidTextItemsMocks() as $invalidItemsMock) {
21  try {
22  $f->text($invalidItemsMock);
23 
24  $this->throwException(new Exception(
25  'expected InvalidArgumentException, catched none'
26  ));
27  } catch (InvalidArgumentException $e) {
28  $this->assertInstanceOf('InvalidArgumentException', $e);
29  }
30  }
31  }
32 
33  public function test_rendered()
34  {
36  $r = $this->getDefaultRenderer();
37 
38  $items = $this->getTextItemsMock();
39  $textListing = $f->text($items);
40  $actualHtml = $r->render($textListing);
41 
42  $expectedHtml = $this->getExpectedHtml();
43 
44  $this->assertHTMLEquals($expectedHtml, $actualHtml);
45  }
46 
47  private function getExpectedHtml() : string
48  {
49  $html = '<div class="il-listing-characteristic-value clearfix">';
50  $html .= ' <div class="il-listing-characteristic-value-row clearfix">';
51  $html .= ' <div class="il-listing-characteristic-value-label">label1</div>';
52  $html .= ' <div class="il-listing-characteristic-value-item">item1</div>';
53  $html .= ' </div>';
54  $html .= ' <div class="il-listing-characteristic-value-row clearfix">';
55  $html .= ' <div class="il-listing-characteristic-value-label">label2</div>';
56  $html .= ' <div class="il-listing-characteristic-value-item">item2</div>';
57  $html .= ' </div>';
58  $html .= ' <div class="il-listing-characteristic-value-row clearfix">';
59  $html .= ' <div class="il-listing-characteristic-value-label">label3</div>';
60  $html .= ' <div class="il-listing-characteristic-value-item">item3</div>';
61  $html .= ' </div>';
62  $html .= '</div>';
63 
64  return $html;
65  }
66 }
getDefaultRenderer(JavaScriptBinding $js_binding=null)
Definition: Base.php:268
assertHTMLEquals($expected_html_as_string, $html_as_string)
Definition: Base.php:326