ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ColumnFactoryTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
21require_once 'components/ILIAS/UI/tests/AbstractFactoryTestCase.php';
22
24use ILIAS\Data;
25
27{
28 public static array $kitchensink_info_settings = [
29 "text" => ["context" => false, "rules" => false],
30 "number" => ["context" => false, "rules" => false],
31 "date" => ["context" => false, "rules" => false],
32 "boolean" => ["context" => false, "rules" => false],
33 "eMail" => ["context" => false, "rules" => false],
34 "status" => ["context" => false, "rules" => false],
35 "statusIcon" => ["context" => false, "rules" => false],
36 "timeSpan" => ["context" => false, "rules" => false],
37 "link" => ["context" => false, "rules" => false],
38 "linkListing" => ["context" => false, "rules" => false],
39 "breadcrumb" => ["context" => false, "rules" => false],
40 ];
41
42 public static string $factory_title = 'ILIAS\\UI\\Component\\Table\\Column\\Factory';
43
44 protected function buildColumnFactory()
45 {
46 $lng = $this->getMockBuilder(\ILIAS\Language\Language::class)
47 ->disableOriginalConstructor()
48 ->getMock();
49 $lng->method('txt')->willReturnCallback(fn($v) => $v);
50
51 return new \ILIAS\UI\Implementation\Component\Table\Column\Factory($lng);
52 }
53
54 public static function getColumnTypeProvider(): array
55 {
56 $date_format = (new Data\Factory())->dateFormat()->germanShort();
57
58 return [
59 [static fn($f) => [Column\Text::class, $f->text("")]],
60 [static fn($f) => [Column\Text::class, $f->text("")]],
61 [static fn($f) => [Column\Date::class, $f->date("", $date_format)]],
62 [static fn($f) => [Column\TimeSpan::class, $f->timespan("", $date_format)]],
63 [static fn($f) => [Column\Number::class, $f->number("")]],
64 [static fn($f) => [Column\Boolean::class, $f->boolean("", '1', '0')]],
65 [static fn($f) => [Column\Status::class, $f->status("")]],
66 [static fn($f) => [Column\StatusIcon::class, $f->statusIcon("")]],
67 [static fn($f) => [Column\Link::class, $f->link("")]],
68 [static fn($f) => [Column\EMail::class, $f->eMail("")]],
69 [static fn($f) => [Column\LinkListing::class, $f->linkListing("")]]
70 ];
71 }
72
73 #[\PHPUnit\Framework\Attributes\DataProvider('getColumnTypeProvider')]
74 public function testDataTableColsImplementInterfaces(\Closure $col): void
75 {
76 $factory = $this->buildColumnFactory();
77 list($class, $instance) = $col($factory);
78 $this->assertInstanceOf(Column\Column::class, $instance);
79 $this->assertInstanceOf($class, $instance);
80 }
81}
Defines tests every SHOULD pass UI-factory.
static string $factory_title
testDataTableColsImplementInterfaces(\Closure $col)
static getColumnTypeProvider()
static array $kitchensink_info_settings
A Column describes the form of presentation for a certain aspect of data, i.e.
Definition: Column.php:28
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.
global $lng
Definition: privfeed.php:31