ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
ViewControlGroupTest.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
27
29{
30 public function testViewControlGroupCreation(): void
31 {
32 $f = $this->buildVCFactory();
33 $vc1 = $f->nullControl();
34 $vc2 = $f->pagination();
35 $group = $f->group([$vc1, $vc2]);
36
37 $this->assertEquals([$vc1, $vc2], $group->getInputs());
38 }
39
40 public function testViewControlGroupGetContent(): void
41 {
42 $f = $this->buildVCFactory();
43 $input = $this->createMock(InputData::class);
44 $namesource = new DefNamesource();
45
46 $group = $f->group(
47 [
48 $f->nullControl(),
49 $f->pagination(),
50 $f->sortation(
51 [
52 'a' => new Order('field1', 'ASC'),
53 'b' => new Order('field2', 'ASC')]
54 )
55 ]
56 )
57 ->withNameFrom($namesource)
58 ->withInput($input);
59
60 $this->assertInstanceOf(Result\Ok::class, $group->getContent());
61 $this->assertCount(3, $group->getContent()->value());
62 list($a, $b, $c) = $group->getContent()->value();
63 $this->assertNull($a);
64 $this->assertInstanceOf(Range::class, $b);
65 $this->assertInstanceOf(Order::class, $c);
66 }
67
68 public function testViewControlGroupRendering(): void
69 {
70 $f = $this->buildVCFactory();
71 $group = $f->group(
72 [
73 $f->nullControl(),
74 $f->pagination()
75 ->withLimitOptions([2, 5, 10])
76 ->withTotalCount(12)
77 ->withOnChange((new SignalGenerator())->create()),
78 $f->sortation([
79 'a' => new Order('field1', 'ASC'),
80 'b' => new Order('field2', 'ASC')
81 ])
82 ->withOnChange((new SignalGenerator())->create()),
83 $f->fieldSelection(['A', 'B'])
84 ->withOnChange((new SignalGenerator())->create())
85 ]
86 );
87
88 $html = $this->brutallyTrimHTML($this->getDefaultRenderer()->render($group));
89 $this->assertStringContainsString('il-viewcontrol il-viewcontrol-pagination', $html);
90 $this->assertStringContainsString('il-viewcontrol il-viewcontrol-sortation', $html);
91 $this->assertStringContainsString('il-viewcontrol il-viewcontrol-fieldselection', $html);
92 }
93}
Both the subject and the direction need to be specified when expressing an order.
Definition: Order.php:29
A simple class to express a naive range of whole positive numbers.
Definition: Range.php:29
$c
Definition: deliver.php:25
A result encapsulates a value or an error and simplifies the handling of those.
Definition: Result.php:29
Describes how Input-Elements want to interact with posted data.
Definition: InputData.php:30
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
Definition: Factory.php:21
$a
thx to https://mlocati.github.io/php-cs-fixer-configurator for the examples