ILIAS  trunk Revision v11.0_alpha-1689-g66c127b4ae8
All Data Structures Namespaces Files Functions Variables Enumerations Enumerator Modules Pages
TileViewTest.php
Go to the documentation of this file.
1 <?php
2 
19 declare(strict_types=1);
20 
21 namespace ILIAS\Badge\test;
22 
30 use ilObjUser;
31 use ILIAS\UI\Factory as UI;
34 use ilCtrl;
38 use ilLanguage;
39 
40 class TileViewTest extends TestCase
41 {
42  public function testConstruct(): void
43  {
44  $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
45  $tile = $this->getMockBuilder(Tile::class)->disableOriginalConstructor()->getMock();
46  $head = $this->getMockBuilder(PresentationHeader::class)->disableOriginalConstructor()->getMock();
47 
48  $tile = new TileView($container, 'Some class.', $tile, $head);
49  $this->assertInstanceOf(TileView::class, $tile);
50  }
51 
52  public function testShow(): void
53  {
54  $request = $this->getMockBuilder(ServerRequest::class)->disableOriginalConstructor()->getMock();
55  $request->method('getQueryParams')->willReturn([]);
56 
57  $http = $this->getMockBuilder(Services::class)->disableOriginalConstructor()->getMock();
58  $http->method('request')->willReturn($request);
59 
60  $user = $this->getMockBuilder(ilObjUser::class)->disableOriginalConstructor()->getMock();
61 
62  $deck = $this->getMockBuilder(Deck::class)->disableOriginalConstructor()->getMock();
63 
64  $sortation = $this->getMockBuilder(Sortation::class)->disableOriginalConstructor()->getMock();
65  $sortation->method('withTargetURL')->willReturn($sortation);
66 
67  $view_control = $this->getMockBuilder(ViewControl::class)->disableOriginalConstructor()->getMock();
68  $view_control->method('sortation')->willReturn($sortation);
69 
70  $factory = $this->getMockBuilder(UI::class)->disableOriginalConstructor()->getMock();
71  $factory->method('deck')->willReturn($deck);
72  $factory->method('viewControl')->willReturn($view_control);
73 
74  $renderer = $this->getMockBuilder(Renderer::class)->disableOriginalConstructor()->getMock();
75  $renderer->method('render')->willReturn('');
76 
77  $ui = $this->getMockBuilder(UIServices::class)->disableOriginalConstructor()->getMock();
78  $ui->method('factory')->willReturn($factory);
79  $ui->method('renderer')->willReturn($renderer);
80 
81  $ctrl = $this->getMockBuilder(ilCtrl::class)->disableOriginalConstructor()->getMock();
82 
83  $language = $this->getMockBuilder(ilLanguage::class)->disableOriginalConstructor()->getMock();
84  $language->method('txt')->willReturnCallback(static fn(string $name): string => $name);
85 
86  $container = $this->getMockBuilder(Container::class)->disableOriginalConstructor()->getMock();
87  $container->method('http')->willReturn($http);
88  $container->method('user')->willReturn($user);
89  $container->method('ui')->willReturn($ui);
90  $container->method('ctrl')->willReturn($ctrl);
91  $container->method('language')->willReturn($language);
92 
93  $tile = $this->getMockBuilder(Tile::class)->disableOriginalConstructor()->getMock();
94  $head = $this->getMockBuilder(PresentationHeader::class)->disableOriginalConstructor()->getMock();
95 
96  $assignments_of_user = static fn() => [];
97  $tile = new TileView($container, 'Some class.', $tile, $head, $assignments_of_user);
98 
99  $this->assertEquals('', $tile->show());
100  }
101 }
$renderer
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
$http
Definition: deliver.php:30
$container
Definition: wac.php:36
This is how the factory for UI elements looks.
Definition: Factory.php:30