44 * @copyright Copyright (C) Ibexa AS. All rights reserved.
55 * @license For full copyright and license information view LICENSE file distributed with this source code.
66 */
7+ declare (strict_types=1 );
78
89namespace Ibexa \Tests \AdminUi \Tab ;
910
1617use Symfony \Contracts \Translation \TranslatorInterface ;
1718use Twig \Environment ;
1819
19- class TabRegistryTest extends TestCase
20+ final class TabRegistryTest extends TestCase
2021{
21- private $ groupName ;
22+ private string $ groupName ;
2223
2324 protected function setUp (): void
2425 {
2526 parent ::setUp ();
2627 $ this ->groupName = 'group_name ' ;
2728 }
2829
29- public function testGetTabsByGroupNameWhenGroupDoesNotExist ()
30+ public function testGetTabsByGroupNameWhenGroupDoesNotExist (): void
3031 {
3132 $ this ->expectException (\InvalidArgumentException::class);
3233 $ this ->expectExceptionMessage (sprintf ('Could not find the requested group named "%s". Did you tag the service? ' , $ this ->groupName ));
@@ -35,17 +36,19 @@ public function testGetTabsByGroupNameWhenGroupDoesNotExist()
3536 $ tabRegistry ->getTabsByGroupName ($ this ->groupName );
3637 }
3738
38- public function testGetTabsByGroupName ()
39+ public function testGetTabsByGroupName (): void
3940 {
40- $ tabs = ['tab1 ' , 'tab2 ' ];
41+ $ twig = $ this ->createMock (Environment::class);
42+ $ translator = $ this ->createMock (TranslatorInterface::class);
43+ $ tabs = [$ this ->createTab ('tab1 ' , $ twig , $ translator ), $ this ->createTab ('tab1 ' , $ twig , $ translator )];
4144 $ tabGroup = $ this ->createTabGroup ($ this ->groupName , $ tabs );
4245 $ tabRegistry = new TabRegistry ();
4346 $ tabRegistry ->addTabGroup ($ tabGroup );
4447
4548 self ::assertSame ($ tabs , $ tabRegistry ->getTabsByGroupName ($ this ->groupName ));
4649 }
4750
48- public function testGetTabFromGroup ()
51+ public function testGetTabFromGroup (): void
4952 {
5053 $ twig = $ this ->createMock (Environment::class);
5154 $ translator = $ this ->createMock (TranslatorInterface::class);
@@ -59,7 +62,7 @@ public function testGetTabFromGroup()
5962 self ::assertSame ($ tab1 , $ tabRegistry ->getTabFromGroup ('tab1 ' , $ this ->groupName ));
6063 }
6164
62- public function testGetTabFromGroupWhenGroupDoesNotExist ()
65+ public function testGetTabFromGroupWhenGroupDoesNotExist (): void
6366 {
6467 $ this ->expectException (\InvalidArgumentException::class);
6568 $ this ->expectExceptionMessage (sprintf ('Could not find the requested group named "%s". Did you tag the service? ' , $ this ->groupName ));
@@ -68,7 +71,7 @@ public function testGetTabFromGroupWhenGroupDoesNotExist()
6871 $ tabRegistry ->getTabFromGroup ('tab1 ' , $ this ->groupName );
6972 }
7073
71- public function testGetTabFromGroupWhenTabDoesNotExist ()
74+ public function testGetTabFromGroupWhenTabDoesNotExist (): void
7275 {
7376 $ tabName = 'tab1 ' ;
7477
@@ -82,7 +85,7 @@ public function testGetTabFromGroupWhenTabDoesNotExist()
8285 $ tabRegistry ->getTabFromGroup ($ tabName , $ this ->groupName );
8386 }
8487
85- public function testAddTabGroup ()
88+ public function testAddTabGroup (): void
8689 {
8790 $ tabRegistry = new TabRegistry ();
8891 $ tabGroup = $ this ->createTabGroup ();
@@ -91,7 +94,7 @@ public function testAddTabGroup()
9194 self ::assertSame ($ tabGroup , $ tabRegistry ->getTabGroup ('lorem ' ));
9295 }
9396
94- public function testAddTabGroupWithSameIdentifier ()
97+ public function testAddTabGroupWithSameIdentifier (): void
9598 {
9699 $ tabGroup = $ this ->createTabGroup ($ this ->groupName );
97100 $ tabGroupWithSameIdentifier = $ this ->createTabGroup ($ this ->groupName );
@@ -104,7 +107,7 @@ public function testAddTabGroupWithSameIdentifier()
104107 self ::assertSame ($ tabGroupWithSameIdentifier , $ tabRegistry ->getTabGroup ($ this ->groupName ));
105108 }
106109
107- public function testAddTabToExistingGroup ()
110+ public function testAddTabToExistingGroup (): void
108111 {
109112 $ twig = $ this ->createMock (Environment::class);
110113 $ translator = $ this ->createMock (TranslatorInterface::class);
@@ -120,7 +123,7 @@ public function testAddTabToExistingGroup()
120123 self ::assertCount (2 , $ tabRegistry ->getTabsByGroupName ($ this ->groupName ));
121124 }
122125
123- public function testAddTabToNonExistentGroup ()
126+ public function testAddTabToNonExistentGroup (): void
124127 {
125128 $ twig = $ this ->createMock (Environment::class);
126129 $ translator = $ this ->createMock (TranslatorInterface::class);
@@ -133,12 +136,7 @@ public function testAddTabToNonExistentGroup()
133136 }
134137
135138 /**
136- * Returns Tab Group.
137- *
138- * @param string $name
139- * @param array $tabs
140- *
141- * @return TabGroup
139+ * @param TabInterface[] $tabs
142140 */
143141 private function createTabGroup (
144142 string $ name = 'lorem ' ,
@@ -148,73 +146,39 @@ private function createTabGroup(
148146 }
149147
150148 /**
151- * Returns Tab.
152- *
153- * @param string $name
154- * @param Environment|MockObject $twig
155- * @param MockObject|TranslatorInterface $translator
156- *
157- * @return TabInterface
149+ * @param Environment&MockObject $twig
150+ * @param TranslatorInterface&MockObject $translator
158151 */
159152 private function createTab (
160153 string $ name ,
161154 Environment $ twig ,
162155 TranslatorInterface $ translator
163156 ): TabInterface {
164157 return new class ($ name , $ twig , $ translator ) extends AbstractTab {
165- /** @var string */
166- protected $ name ;
167-
168- /** @var Environment */
169- protected $ twig ;
170-
171- /** @var TranslatorInterface */
172- protected $ translator ;
158+ protected string $ name ;
173159
174- /**
175- * @param string $name
176- * @param Environment $twig
177- * @param TranslatorInterface $translator
178- */
179160 public function __construct (
180- string $ name = ' tab ' ,
161+ string $ name ,
181162 Environment $ twig ,
182163 TranslatorInterface $ translator
183164 ) {
184165 parent ::__construct ($ twig , $ translator );
185166 $ this ->name = $ name ;
186167 }
187168
188- /**
189- * Returns identifier of the tab.
190- *
191- * @return string
192- */
193169 public function getIdentifier (): string
194170 {
195171 return 'identifier ' ;
196172 }
197173
198- /**
199- * Returns name of the tab which is displayed as a tab's title in the UI.
200- *
201- * @return string
202- */
203174 public function getName (): string
204175 {
205176 return $ this ->name ;
206177 }
207178
208- /**
209- * Returns HTML body of the tab.
210- *
211- * @param array $parameters
212- *
213- * @return string
214- */
215179 public function renderView (array $ parameters ): string
216180 {
217- return null ;
181+ return '' ;
218182 }
219183 };
220184 }
0 commit comments