@@ -26,15 +26,15 @@ public function testData(): void
2626 $ data = [
2727 'tool1 ' => [
2828 'route ' => 'vis_tool1 ' ,
29- 'routeParameters ' => [],
29+ 'routeparameters ' => [],
3030 'label ' => 'Tool 1 '
3131 ]
3232 ];
3333 $ search ->setData ($ data );
3434 $ this ->assertEquals ($ data , $ search ->getData ());
3535 $ this ->assertEquals (1 , $ search ->getDataCounter ());
3636
37- $ search ->addData (['tool2 ' => ['route ' => 'vis_tool2 ' , 'routeParameters ' => [], 'label ' => 'Tool 2 ' ]]);
37+ $ search ->addData (['tool2 ' => ['route ' => 'vis_tool2 ' , 'routeparameters ' => [], 'label ' => 'Tool 2 ' ]]);
3838 $ this ->assertCount (2 , $ search ->getData ());
3939 $ this ->assertEquals (2 , $ search ->getDataCounter ());
4040 }
@@ -89,3 +89,44 @@ public function testSetVisAndDataLoading(): void
8989 $ this ->assertEquals ('Title 1 ' , $ data ['tool1 ' ]['label ' ]);
9090 }
9191}
92+
93+ class TopbarLiveSearchClientsTest extends TestCase
94+ {
95+ public function testConstructor (): void
96+ {
97+ $ clientsSearch = new \JBSNewMedia \VisBundle \Model \Topbar \TopbarLiveSearchClients ('test_tool ' );
98+ $ this ->assertEquals ('dropdown_clients_end ' , $ clientsSearch ->getId ());
99+ $ this ->assertEquals ('end ' , $ clientsSearch ->getPosition ());
100+ $ this ->assertEquals (90 , $ clientsSearch ->getOrder ());
101+ }
102+
103+ public function testSetVisAndDataLoading (): void
104+ {
105+ $ vis = $ this ->createMock (Vis::class);
106+ $ vis ->method ('getClients ' )->willReturn (['id1 ' => 'Client 1 ' , 'id2 ' => 'Client 2 ' ]);
107+ $ vis ->method ('getSelectedClientId ' )->willReturn ('id1 ' );
108+ $ vis ->method ('getSelectedClientTitle ' )->willReturn ('Client 1 ' );
109+ $ translator = $ this ->createMock (\Symfony \Contracts \Translation \TranslatorInterface::class);
110+ $ vis ->method ('getTranslator ' )->willReturn ($ translator );
111+
112+ $ clientsSearch = new \JBSNewMedia \VisBundle \Model \Topbar \TopbarLiveSearchClients ('test_tool ' );
113+ $ clientsSearch ->setVis ($ vis );
114+ $ this ->assertSame ($ vis , $ clientsSearch ->getVis ());
115+
116+ // getDataCounter triggers setVisData
117+ $ count = $ clientsSearch ->getDataCounter ();
118+ $ this ->assertEquals (2 , $ count );
119+
120+ $ data = $ clientsSearch ->getData ();
121+ $ this ->assertArrayHasKey ('id1 ' , $ data );
122+ $ this ->assertEquals ('vis_api_client ' , $ data ['id1 ' ]['route ' ]);
123+ $ this ->assertEquals (['id ' => 'id1 ' ], $ data ['id1 ' ]['routeparameters ' ]);
124+ $ this ->assertEquals ('Client 1 ' , $ data ['id1 ' ]['label ' ]);
125+
126+ $ content = $ clientsSearch ->getContent ();
127+ $ this ->assertEquals ('<i class="fa-solid fa-building fa-fw"></i> ' , $ content );
128+
129+ $ label = $ clientsSearch ->getLabel ();
130+ $ this ->assertEquals ('Client 1 ' , $ label );
131+ }
132+ }
0 commit comments