19declare(strict_types=1);
21require_once(__DIR__ .
"/../../../../../../../vendor/composer/vendor/autoload.php");
22require_once(__DIR__ .
"/../../../Base.php");
27use Psr\Http\Message\ServerRequestInterface;
33 protected I\Button\Factory $button_factory;
34 protected I\Button\Standard $button_stub;
35 protected string $button_html;
36 protected I\Symbol\Factory $symbol_factory;
38 protected DataFactory $data_factory;
39 protected ServerRequestInterface $request;
41 public function setUp(): void
43 $this->button_stub = $this->createMock(
I\
Button\Standard::class);
44 $this->button_html = sha1(
I\
Button\Standard::class);
45 $this->button_stub->method(
'getCanonicalName')->willReturn($this->button_html);
46 $this->button_stub->method(
'withSymbol')->willReturn($this->button_stub);
47 $this->button_stub->method(
'withUnavailableAction')->willReturn($this->button_stub);
49 $this->button_factory = $this->createMock(
I\
Button\Factory::class);
50 $this->button_factory->method(
'standard')->willReturn($this->button_stub);
52 $this->symbol_factory = $this->createMock(
I\Symbol\Factory::class);
55 $this->data_factory =
new DataFactory();
58 $this->request = $this->createMock(ServerRequestInterface::class);
59 $this->request->method(
"getUri")
60 ->willReturn(
new \GuzzleHttp\Psr7\Uri(
'http://localhost:80/doil'));
68 $this->button_factory,
69 $this->symbol_factory,
73 protected I\Symbol\
Factory $symbol_factory,
79 return $this->button_factory;
83 return $this->symbol_factory;
89 protected function getNavigationFactory(): Navigation\
Factory
91 return new Navigation\Factory(
94 $this->createMock(
ILIAS\UI\Storage::class)
98 public function testSequenceNavigationBasics(): void
100 $sequence = $this->getNavigationFactory()->sequence(
101 $this->createMock(
C\Navigation\Sequence\SegmentRetrieval::class)
105 $view_controls = $this->createMock(
I\Input\Container\ViewControl\ViewControl::class);
107 $this->createMock(
I\
Button\Standard::class),
108 $this->createMock(
I\
Button\Standard::class),
111 $this->assertEquals($view_controls, $sequence->withViewControls($view_controls)->getViewControls());
112 $this->assertEquals($actions, $sequence->withActions(...$actions)->getActions());
113 $this->assertEquals($this->request, $sequence->withRequest($this->request)->getRequest());
114 $this->assertStringContainsString(
115 'sequence_' .
$id .
'_p=1',
116 $sequence->withId(
$id)->withRequest($this->request)->getNext(1)->__toString()
120 public function testSequenceNavigationRendering(): void
122 $binding =
new class () implements
C\Navigation\Sequence\SegmentRetrieval {
123 public function getAllPositions(
124 ServerRequestInterface $request,
125 mixed $viewcontrol_values,
126 mixed $filter_values,
129 [
'pos 1',
'content 1'],
130 [
'pos 2',
'content 2'],
133 public function getSegment(
134 ServerRequestInterface $request,
135 mixed $position_data,
136 mixed $viewcontrol_values,
137 mixed $filter_values,
138 ):
I\Legacy\Segment {
139 return new
I\Legacy\Segment(
'title',
'content');
143 $sequence = $this->getNavigationFactory()->sequence($binding)->withRequest($this->request);
144 $actual_html = $this->getDefaultRenderer(
null, [$this->button_stub])
147 $expected_html = <<<EOT
148 <div
class=
"c-sequence c-sequence--linear">
149 <div
class=
"c-sequence__header">
151 <div
id=
"id_3" class=
"c-sequence__navigation">
152 <div
class=
"c-sequence__navigation--back">
155 <div
class=
"c-sequence__navigation--next">
160 <div
class=
"c-sequence__header__segment">
161 <div
class=
"c-sequence__header__segment__title">
162 <div
id=
"id_2">title</div>
168 <div
class=
"c-sequence__segment">
169 <div
id=
"id_1" class=
"c-sequence__segment__contents">
178 $this->brutallyTrimHTML($expected_html),
179 $this->brutallyTrimHTML($actual_html)
183 public function testSequenceNavigationPositionsFromQuery(): void
185 $request = $this->request;
187 ->method(
'getQueryParams')
188 ->willReturn([
'sequence__p' => 12]);
189 $sequence = $this->getNavigationFactory()->sequence(
190 $this->createMock(
C\Navigation\Sequence\SegmentRetrieval::class)
191 )->withRequest($request);
193 $this->assertEquals(12, $sequence->getCurrentPosition());
194 $this->assertStringContainsString(
'_p=11', $sequence->getNext(-1)->__toString());
$id
plugin.php for ilComponentBuildPluginInfoObjectiveTest::testAddPlugins
Provides common functionality for UI tests.
return['delivery_method'=> 'php',]
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc
button(string $caption, string $cmd)
Interface Observer \BackgroundTasks Contains several chained tasks and infos about them.