ILIAS  release_8 Revision v8.19
All Data Structures Namespaces Files Functions Variables Modules Pages
ViewControlGroupTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
27 
28 require_once('ViewControlBaseTest.php');
29 
31 {
32  public function testViewControlGroupCreation(): void
33  {
34  $f = $this->buildVCFactory();
35  $vc1 = $f->nullControl();
36  $vc2 = $f->pagination();
37  $group = $f->group([$vc1, $vc2]);
38 
39  $this->assertEquals([$vc1, $vc2], $group->getInputs());
40  }
41 
42  public function testViewControlGroupGetContent(): void
43  {
44  $f = $this->buildVCFactory();
45  $input = $this->createMock(InputData::class);
46  $namesource = new DefNamesource();
47 
48  $group = $f->group(
49  [
50  $f->nullControl(),
51  $f->pagination(),
52  $f->sortation(
53  [
54  'a' => new Order('field1', 'ASC'),
55  'b' => new Order('field2', 'ASC')]
56  )
57  ]
58  )
59  ->withNameFrom($namesource)
60  ->withInput($input);
61 
62  $this->assertInstanceOf(Result\Ok::class, $group->getContent());
63  $this->assertCount(3, $group->getContent()->value());
64  list($a, $b, $c) = $group->getContent()->value();
65  $this->assertNull($a);
66  $this->assertInstanceOf(Range::class, $b);
67  $this->assertInstanceOf(Order::class, $c);
68  }
69 
70  public function testViewControlGroupRendering(): void
71  {
72  $f = $this->buildVCFactory();
73  $group = $f->group(
74  [
75  $f->nullControl(),
76  $f->pagination()
77  ->withLimitOptions([2, 5, 10])
78  ->withTotalCount(12)
79  ->withOnChange((new SignalGenerator())->create()),
80  $f->sortation([
81  'a' => new Order('field1', 'ASC'),
82  'b' => new Order('field2', 'ASC')
83  ])
84  ->withOnChange((new SignalGenerator())->create()),
85  $f->fieldSelection(['A', 'B'])
86  ->withOnChange((new SignalGenerator())->create())
87  ]
88  );
89 
90  $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($group));
91  $this->assertStringContainsString('il-viewcontrol il-viewcontrol-pagination', $html);
92  $this->assertStringContainsString('il-viewcontrol il-viewcontrol-sortation', $html);
93  $this->assertStringContainsString('il-viewcontrol il-viewcontrol-fieldselection', $html);
94  }
95 }
getDefaultRenderer(JavaScriptBinding $js_binding=null, array $with_stub_renderings=[])
Definition: Base.php:355
$c
Definition: cli.php:38
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:14
brutallyTrimHTML(string $html)
A more radical version of normalizeHTML.
Definition: Base.php:444
Both the subject and the direction need to be specified when expressing an order. ...
Definition: Order.php:12
withNameFrom(NameSource $source, ?string $parent_name=null)
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21