@@ -114,9 +114,21 @@ class TestPresenter extends Application\UI\Presenter
114114 Assert::same ('/index.php?sort%5By%5D%5Basc%5D=1&action=default&presenter=Test ' , $ this ->link ('this ' , ['sort ' => ['y ' => ['asc ' => TRUE ]]]));
115115
116116 // Presenter & signal link type checking
117+ Assert::same ("#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer. " , $ this ->link ('buy! ' , 'x ' ));
118+ Assert::same ("#error: Invalid value for parameter 'bool' in method TestPresenter::handlebuy(), expected boolean. " , $ this ->link ('buy! ' , 1 , 2 , 3 ));
117119 Assert::same ("#error: Invalid value for parameter 'x' in method TestPresenter::handlebuy(), expected integer. " , $ this ->link ('buy! ' , [[]]));
120+ Assert::same ('/index.php?action=default&do=buy&presenter=Test ' , $ this ->link ('buy! ' ));
118121 Assert::same ('/index.php?action=default&do=buy&presenter=Test ' , $ this ->link ('buy! ' , [new stdClass ]));
119122
123+ Assert::same ('/index.php?a=x&action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , ['x ' ]));
124+ Assert::same ('/index.php?action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , [new stdClass ]));
125+ Assert::same ('/index.php?action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , [new Exception ]));
126+ Assert::same ('/index.php?action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , [NULL ]));
127+ Assert::same ('/index.php?b=x&action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , ['b ' => 'x ' ]));
128+ Assert::same ('/index.php?action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , ['b ' => new stdClass ]));
129+ Assert::same ('/index.php?action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , ['b ' => new Exception ]));
130+ Assert::same ('/index.php?action=default&do=obj&presenter=Test ' , $ this ->link ('obj! ' , ['b ' => NULL ]));
131+
120132 // Component link
121133 Assert::same ('#error: Signal must be non-empty string. ' , $ this ['mycontrol ' ]->link ('' , 0 , 1 ));
122134 Assert::same ('/index.php?mycontrol-x=0&mycontrol-y=1&action=default&do=mycontrol-click&presenter=Test ' , $ this ['mycontrol ' ]->link ('click ' , 0 , 1 ));
@@ -155,16 +167,21 @@ class TestPresenter extends Application\UI\Presenter
155167 Assert::exception (function () {
156168 $ this ->link ('product ' , ['var1 ' => NULL , 'ok ' => 'a ' ]);
157169 }, Nette \Application \UI \InvalidLinkException::class, "Invalid value for persistent parameter 'ok' in 'Test', expected boolean. " );
170+
171+ $ this ->var1 = NULL ; // NULL in persistent parameter means default
172+ Assert::same ('/index.php?action=product&presenter=Test ' , $ this ->link ('product ' ));
158173 }
159174
160175
161- /**
162- * @view: default
163- */
164176 public function handleBuy ($ x = 1 , $ y = 1 , $ bool = FALSE , $ str = '' )
165177 {
166178 }
167179
180+
181+ public function handleObj (stdClass $ a , stdClass $ b = NULL )
182+ {
183+ }
184+
168185}
169186
170187
0 commit comments