ILIAS  trunk Revision v11.0_alpha-1715-g7fc467680fb
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
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  new Listing\Workflow\Factory(),
30  new Listing\CharacteristicValue\Factory(),
31  new Listing\Entity\Factory(),
32  );
33  }
34 
35  public function testPropertyListingConstruction(): void
36  {
37  $pl = $this->getListingFactory()->property();
38  $this->assertInstanceOf(I\Listing\Listing::class, $pl);
39  $this->assertInstanceOf(I\Listing\Property::class, $pl);
40  }
41 
42  public function testPropertyListingWithProperty(): void
43  {
44  $props = [
45  ['label1', 'value1', true],
46  ['label2', 'value2', false]
47  ];
48  $pl = $this->getListingFactory()->property()
49  ->withProperty(...$props[0])
50  ->withProperty(...$props[1]);
51 
52  $this->assertEquals($props, $pl->getItems());
53  }
54 
55  public function testPropertyListingWithItems(): void
56  {
57  $props = [
58  ['label1', 'value1', true],
59  ['label2', 'value2', false]
60  ];
61  $pl = $this->getListingFactory()->property()
62  ->withProperty('overwritten', 'by props');
63 
64  $pl = $pl->withItems($props);
65  $this->assertEquals($props, $pl->getItems());
66  }
67 
68  public function testPropertyListingRendering(): void
69  {
70  $props = [
71  ['label1', 'value1', true],
72  ['label2', 'value2', false]
73  ];
74  $pl = $this->getListingFactory()->property()
75  ->withItems($props);
76 
77  $expected = $this->brutallyTrimHTML('
78 <div class="l-bar__space-keeper c-listing-property">
79  <div class="l-bar__group c-listing-property__property">
80  <span class="l-bar__element c-listing-property__propertylabel">label1</span>
81  <span class="l-bar__element c-listing-property__propertyvalue">value1</span>
82  </div>
83  <div class="l-bar__group c-listing-property__property">
84  <span class="l-bar__element c-listing-property__propertyvalue">value2</span>
85  </div>
86 </div>
87  ');
88 
89  $this->assertEquals(
90  $expected,
91  $this->brutallyTrimHTML($this->getDefaultRenderer()->render($pl))
92  );
93  }
94 }