1111function callIsLinkCurrent (Application \Request $ request , $ destination , array $ args )
1212{
1313 $ presenter = new TestPresenter ;
14+ return callIsComponentLinkCurrent ($ presenter , $ presenter , $ request , $ destination , $ args );
15+ }
1416
17+ function callIsComponentLinkCurrent (
18+ Application \UI \Presenter $ presenter ,
19+ Application \UI \PresenterComponent $ component ,
20+ Application \Request $ request ,
21+ $ destination ,
22+ array $ args
23+ ) {
1524 $ url = new Http \UrlScript ('http://localhost/index.php ' );
1625 $ url ->setScriptPath ('/index.php ' );
1726
@@ -24,7 +33,7 @@ function callIsLinkCurrent(Application\Request $request, $destination, array $ar
2433 );
2534 $ presenter ->run ($ request );
2635
27- return $ presenter ->isLinkCurrent ($ destination , $ args );
36+ return $ component ->isLinkCurrent ($ destination , $ args );
2837}
2938
3039Assert::true (callIsLinkCurrent (
@@ -223,3 +232,109 @@ function callIsLinkCurrent(Application\Request $request, $destination, array $ar
223232 Application \UI \Presenter::SIGNAL_KEY => 'signal ' ,
224233 ]
225234));
235+
236+
237+ // signal for nested component
238+ $ testPresenter = new TestPresenter ;
239+ $ testControl = new TestControl ;
240+ $ testPresenter ['test ' ] = $ testControl ;
241+ Assert::true (callIsComponentLinkCurrent (
242+ $ testPresenter ,
243+ $ testControl ,
244+ new Application \Request ('Test ' , Http \Request::GET , [
245+ Application \UI \Presenter::SIGNAL_KEY => 'test-click ' ,
246+ 'int ' => 1 ,
247+ 'bool ' => TRUE ,
248+ ]),
249+ 'click! ' ,
250+ []
251+ ));
252+
253+ $ testPresenter = new TestPresenter ;
254+ $ testControl = new TestControl ;
255+ $ testPresenter ['test ' ] = $ testControl ;
256+ Assert::false (callIsComponentLinkCurrent (
257+ $ testPresenter ,
258+ $ testControl ,
259+ new Application \Request ('Test ' , Http \Request::GET , [
260+ Application \UI \Presenter::SIGNAL_KEY => 'test-click ' ,
261+ 'int ' => 1 ,
262+ 'bool ' => TRUE ,
263+ ]),
264+ 'otherSignal! ' ,
265+ []
266+ ));
267+
268+ $ testPresenter = new TestPresenter ;
269+ $ testControl = new TestControl ;
270+ $ testPresenter ['test ' ] = $ testControl ;
271+ Assert::true (callIsComponentLinkCurrent (
272+ $ testPresenter ,
273+ $ testControl ,
274+ new Application \Request ('Test ' , Http \Request::GET , [
275+ Application \UI \Presenter::SIGNAL_KEY => 'test-click ' ,
276+ 'int ' => 1 ,
277+ 'bool ' => TRUE ,
278+ 'test-x ' => 1 ,
279+ ]),
280+ 'click! ' ,
281+ [
282+ 'x ' => 1 ,
283+ ]
284+ ));
285+
286+ $ testPresenter = new TestPresenter ;
287+ $ testControl = new TestControl ;
288+ $ testPresenter ['test ' ] = $ testControl ;
289+ Assert::false (callIsComponentLinkCurrent (
290+ $ testPresenter ,
291+ $ testControl ,
292+ new Application \Request ('Test ' , Http \Request::GET , [
293+ Application \UI \Presenter::SIGNAL_KEY => 'test-click ' ,
294+ 'int ' => 1 ,
295+ 'bool ' => TRUE ,
296+ 'test-x ' => 1 ,
297+ ]),
298+ 'click! ' ,
299+ [
300+ 'x ' => 2 ,
301+ ]
302+ ));
303+
304+ $ testPresenter = new TestPresenter ;
305+ $ testControlWithAnotherTestControl = new TestControl ;
306+ $ testPresenter ['test ' ] = $ testControlWithAnotherTestControl ;
307+ $ testControlWithAnotherTestControl ['test ' ] = new TestControl ;
308+ Assert::true (callIsComponentLinkCurrent (
309+ $ testPresenter ,
310+ $ testControlWithAnotherTestControl ,
311+ new Application \Request ('Test ' , Http \Request::GET , [
312+ Application \UI \Presenter::SIGNAL_KEY => 'test-test-click ' ,
313+ 'int ' => 1 ,
314+ 'bool ' => TRUE ,
315+ 'test-test-x ' => 1 ,
316+ ]),
317+ 'test:click! ' ,
318+ [
319+ 'x ' => 1 ,
320+ ]
321+ ));
322+
323+ $ testPresenter = new TestPresenter ;
324+ $ testControlWithAnotherTestControl = new TestControl ;
325+ $ testPresenter ['test ' ] = $ testControlWithAnotherTestControl ;
326+ $ testControlWithAnotherTestControl ['test ' ] = new TestControl ;
327+ Assert::false (callIsComponentLinkCurrent (
328+ $ testPresenter ,
329+ $ testControlWithAnotherTestControl ,
330+ new Application \Request ('Test ' , Http \Request::GET , [
331+ Application \UI \Presenter::SIGNAL_KEY => 'test-test-click ' ,
332+ 'int ' => 1 ,
333+ 'bool ' => TRUE ,
334+ 'test-test-x ' => 1 ,
335+ ]),
336+ 'test:click! ' ,
337+ [
338+ 'x ' => 2 ,
339+ ]
340+ ));
0 commit comments