ILIAS  release_6 Revision v6.24-5-g0c8bfefb3b8
All Data Structures Namespaces Files Functions Variables Modules Pages
StandardPageTest.php
Go to the documentation of this file.
1 <?php
2 
3 /* Copyright (c) 2019 Nils Haagen <nils.haagen@concepts-and-training.de> Extended GPL, see docs/LICENSE */
4 
5 require_once("libs/composer/vendor/autoload.php");
6 require_once(__DIR__ . "/../../../Base.php");
7 
8 use \ILIAS\UI\Component as C;
9 use \ILIAS\UI\Component\MainControls\MetaBar;
10 use \ILIAS\UI\Component\MainControls\MainBar;
11 use \ILIAS\UI\Component\Breadcrumbs\Breadcrumbs;
12 use \ILIAS\UI\Component\Image\Image;
13 use \ILIAS\UI\Implementation\Component\Layout\Page;
14 use \ILIAS\UI\Implementation\Component\Legacy\Legacy;
15 
20 {
21  public function setUp() : void
22  {
23  $sig_gen = new \ILIAS\UI\Implementation\Component\SignalGenerator();
24  $this->metabar = $this->createMock(MetaBar::class);
25  $this->mainbar = $this->createMock(MainBar::class);
26  $this->crumbs = $this->createMock(Breadcrumbs::class);
27  $this->logo = $this->createMock(Image::class);
28  $this->logo->method("getCanonicalName")->willReturn("Logo Stub");
29  $this->responsive_logo = $this->createMock(Image::class);
30  $this->responsive_logo->method("getCanonicalName")->willReturn("Responsive Logo Stub");
31  $this->contents = array(new Legacy('some content', $sig_gen));
32  $this->title = 'pagetitle';
33 
34  $this->factory = new Page\Factory();
35  $this->stdpage = $this->factory->standard(
36  $this->contents,
37  $this->metabar,
38  $this->mainbar,
39  $this->crumbs,
40  $this->logo,
41  null,
42  $this->title
43  )->withResponsiveLogo($this->responsive_logo);
44  }
45 
46  public function testConstruction() : void
47  {
48  $this->assertInstanceOf(
49  "ILIAS\\UI\\Component\\Layout\\Page\\Standard",
50  $this->stdpage
51  );
52  }
53 
54  public function testGetContent() : void
55  {
56  $this->assertEquals(
57  $this->contents,
58  $this->stdpage->getContent()
59  );
60  }
61 
62  public function testGetMetabar() : void
63  {
64  $this->assertEquals(
65  $this->metabar,
66  $this->stdpage->getMetabar()
67  );
68  }
69 
70  public function testGetMainbar() : void
71  {
72  $this->assertEquals(
73  $this->mainbar,
74  $this->stdpage->getMainbar()
75  );
76  }
77 
78  public function testGetBreadcrumbs() : void
79  {
80  $this->assertEquals(
81  $this->crumbs,
82  $this->stdpage->getBreadcrumbs()
83  );
84  }
85 
86  public function testGetLogo() : void
87  {
88  $this->assertEquals(
89  $this->logo,
90  $this->stdpage->getLogo()
91  );
92  }
93 
94  public function testHasLogo() : void
95  {
96  $this->assertTrue($this->stdpage->hasLogo());
97  }
98 
99  public function testGetResponsiveLogo() : void
100  {
101  $this->assertEquals(
102  $this->responsive_logo,
103  $this->stdpage->getResponsiveLogo()
104  );
105  }
106 
107  public function testHasResponsiveLogo() : void
108  {
109  $this->assertTrue($this->stdpage->hasResponsiveLogo());
110  }
111 
112  public function testWithWrongContents() : void
113  {
114  $this->expectException(TypeError::class);
115  $this->stdpage = $this->factory->standard(
116  $this->metabar,
117  $this->mainbar,
118  'string is not allowed here',
119  $this->crumbs,
120  $this->logo
121  );
122  }
123 
124  public function testGetTitle() : void
125  {
126  $this->assertEquals(
127  $this->title,
128  $this->stdpage->getTitle()
129  );
130  }
131 
132  public function testWithTitle() : void
133  {
134  $title = 'some title';
135  $this->assertEquals(
136  $title,
137  $this->stdpage->withTitle($title)->getTitle()
138  );
139  }
140  public function testWithShortTitle() : void
141  {
142  $title = 'some short title';
143  $this->assertEquals(
144  $title,
145  $this->stdpage->withShortTitle($title)->getShortTitle()
146  );
147  }
148  public function testWithViewTitle() : void
149  {
150  $title = 'some view title';
151  $this->assertEquals(
152  $title,
153  $this->stdpage->withViewTitle($title)->getViewTitle()
154  );
155  }
156 
157  public function testWithMetaDatum()
158  {
159  $meta_datum_key = 'meta_datum_key';
160  $meta_datum_value = 'meta_datum_value';
161  $meta_data = [$meta_datum_key => $meta_datum_value];
162  $this->assertEquals(
163  $meta_data,
164  $this->stdpage->withAdditionalMetaDatum($meta_datum_key, $meta_datum_value)->getMetaData()
165  );
166  }
167 }
This describes the Legacy-Slate.
Definition: Legacy.php:10
Tests for the Standard Page.
metabar()
Definition: metabar.php:2
Provides common functionality for UI tests.
Definition: Base.php:224
mainbar()
Definition: mainbar.php:2