19 declare(strict_types=1);
39 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
41 $this->assertInstanceOf(PresentationHeader::class, $head);
47 public function testShow(
bool $additional =
false): void
49 $mode = $this->getMockBuilder(Mode::class)->disableOriginalConstructor()->getMock();
50 $mode->expects(self::once())->method(
'withActive')->with(
'tile_view')->willReturn($mode);
52 $view_control = $this->getMockBuilder(ViewControl::class)->disableOriginalConstructor()->getMock();
53 $view_control->expects(self::once())->method(
'mode')->with([
54 'tile_view' =>
'list URL',
55 'table_view' =>
'manage URL',
56 ])->willReturn($mode);
58 $additional_component = [];
59 $consecutive_expected = [$mode];
61 $mock = $this->getMockBuilder(Component::class)->getMock();
62 $additional_component[] = [$mock];
63 $consecutive_expected[] = $mock;
66 $toolbar = $this->getMockBuilder(ilToolbarGUI::class)->disableOriginalConstructor()->getMock();
68 ->expects(self::exactly($additional + 1))
69 ->method(
'addStickyItem')
71 function ($component) use (&$consecutive_expected) {
72 $expected = array_shift($consecutive_expected);
73 $this->assertEquals($expected, $component);
78 $factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
79 $factory->expects(self::once())->method(
'viewControl')->willReturn($view_control);
81 $ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();
82 $ui->method(
'factory')->willReturn($factory);
85 [
'Some class.',
'listBadges',
'list URL'],
86 [
'Some class.',
'manageBadges',
'manage URL'],
88 $ctrl = $this->getMockBuilder(ilCtrl::class)->disableOriginalConstructor()->getMock();
90 ->expects(self::exactly(2))
91 ->method(
'getLinkTargetByClass')
93 function ($class, $cmd) use (&$consecutive) {
94 list($expected_class, $expected_cmd, $ret) = array_shift($consecutive);
95 $this->assertEquals($class, $expected_class);
96 $this->assertEquals($cmd, $expected_cmd);
101 $language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
102 $language->method(
'txt')->willReturnCallback(
static fn(
string $name):
string => $name);
104 $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
105 $container->expects(self::once())->method(
'toolbar')->willReturn($toolbar);
107 $container->method(
'ctrl')->willReturn($ctrl);
108 $container->method(
'language')->willReturn($language);
111 $head->show(
'tile_view', $additional_component[0][0] ??
null);
117 'Without additional component' => [],
118 'With additional component' => [
true],
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
while($session_entry=$r->fetchRow(ilDBConstants::FETCHMODE_ASSOC)) return null
This is how the factory for UI elements looks.