ILIAS  release_9 Revision v9.13-25-g2c18ec4c24f
PropertyListingTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
22 use ILIAS\UI\Component as I;
23 
25 {
26  protected function getListingFactory(): Listing\Factory
27  {
28  return new Listing\Factory();
29  }
30 
31  public function testPropertyListingConstruction(): void
32  {
33  $pl = $this->getListingFactory()->property();
34  $this->assertInstanceOf(I\Listing\Listing::class, $pl);
35  $this->assertInstanceOf(I\Listing\Property::class, $pl);
36  }
37 
38  public function testPropertyListingWithProperty(): void
39  {
40  $props = [
41  ['label1', 'value1', true],
42  ['label2', 'value2', false]
43  ];
44  $pl = $this->getListingFactory()->property()
45  ->withProperty(...$props[0])
46  ->withProperty(...$props[1]);
47 
48  $this->assertEquals($props, $pl->getItems());
49  }
50 
51  public function testPropertyListingWithItems(): void
52  {
53  $props = [
54  ['label1', 'value1', true],
55  ['label2', 'value2', false]
56  ];
57  $pl = $this->getListingFactory()->property()
58  ->withProperty('overwritten', 'by props');
59 
60  $pl = $pl->withItems($props);
61  $this->assertEquals($props, $pl->getItems());
62  }
63 
64  public function testPropertyListingRendering(): void
65  {
66  $props = [
67  ['label1', 'value1', true],
68  ['label2', 'value2', false]
69  ];
70  $pl = $this->getListingFactory()->property()
71  ->withItems($props);
72 
73  $expected = $this->brutallyTrimHTML('
74 <div class="l-bar__space-keeper c-listing-property">
75  <div class="l-bar__group c-listing-property__property">
76  <span class="l-bar__element c-listing-property__propertylabel">label1</span>
77  <span class="l-bar__element c-listing-property__propertyvalue">value1</span>
78  </div>
79  <div class="l-bar__group c-listing-property__property">
80  <span class="l-bar__element c-listing-property__propertyvalue">value2</span>
81  </div>
82 </div>
83  ');
84 
85  $this->assertEquals(
86  $expected,
87  $this->brutallyTrimHTML($this->getDefaultRenderer()->render($pl))
88  );
89  }
90 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:377
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:475
Provides common functionality for UI tests.
Definition: Base.php:310
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...