@@ -18,6 +18,9 @@ class TestPresenter extends Application\UI\Presenter
1818 /** @persistent */
1919 public $ var1 = 10 ;
2020
21+ /** @persistent */
22+ public $ var2 ;
23+
2124
2225 protected function createTemplate ($ class = NULL )
2326 {
@@ -33,7 +36,8 @@ class TestPresenter extends Application\UI\Presenter
3336 Assert::same ('/index.php?var1=20&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , ['var1 ' => $ this ->var1 * 2 ]));
3437 Assert::same ('/index.php?y=2&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , 1 , 2 ));
3538 Assert::same ('/index.php?y=2&bool=1&str=1&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , '1 ' , '2 ' , TRUE , TRUE ));
36- Assert::same ('/index.php?y=2&str=0&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , '1 ' , '2 ' , FALSE , FALSE ));
39+ Assert::same ('/index.php?y=0&str=0&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , '1 ' , 0 , FALSE , FALSE ));
40+ Assert::same ('/index.php?action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , ['str ' => '' , 'var2 ' => '' ]));
3741 Assert::same ('/index.php?action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , [1 ]));
3842 Assert::same ('#error: Argument $x passed to TestPresenter::handleHint() must be int, array given. ' , $ this ->link ('hint! ' , [1 ], (object ) [1 ]));
3943 Assert::same ('/index.php?y=2&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , [1 , 'y ' => 2 ]));
@@ -43,19 +47,38 @@ class TestPresenter extends Application\UI\Presenter
4347 Assert::same ('/index.php?action=default&presenter=Test ' , $ this ->link ('this! ' , ['var1 ' => $ this ->var1 ]));
4448 Assert::same ('/index.php?sort%5By%5D%5Basc%5D=1&action=default&presenter=Test ' , $ this ->link ('this ' , ['sort ' => ['y ' => ['asc ' => TRUE ]]]));
4549
46- // Presenter & signal link type checking
50+ // type checking
4751 Assert::same ('#error: Argument $x passed to TestPresenter::handleHint() must be int, string given. ' , $ this ->link ('hint! ' , 'x ' ));
4852 Assert::same ('#error: Argument $bool passed to TestPresenter::handleHint() must be bool, integer given. ' , $ this ->link ('hint! ' , 1 , 2 , 3 ));
4953 Assert::same ('#error: Argument $x passed to TestPresenter::handleHint() must be int, array given. ' , $ this ->link ('hint! ' , [[]]));
5054 Assert::same ('/index.php?action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' ));
5155 Assert::same ('#error: Argument $x passed to TestPresenter::handleHint() must be int, stdClass given. ' , $ this ->link ('hint! ' , [new stdClass ]));
56+
57+ // optional arguments
58+ Assert::same ('/index.php?y=2&action=default&do=null&presenter=Test ' , $ this ->link ('null! ' , 1 , 2 ));
59+ Assert::same ('/index.php?y=2&bool=1&str=1&action=default&do=null&presenter=Test ' , $ this ->link ('null! ' , '1 ' , '2 ' , TRUE , TRUE ));
60+ Assert::same ('/index.php?y=0&str=0&action=default&do=null&presenter=Test ' , $ this ->link ('null! ' , '1 ' , 0 , FALSE , FALSE ));
61+ Assert::same ('/index.php?action=default&do=null&presenter=Test ' , $ this ->link ('null! ' , ['str ' => '' , 'var2 ' => '' ]));
62+ Assert::same ('/index.php?action=default&do=null&presenter=Test ' , $ this ->link ('null! ' , [1 ]));
63+ Assert::same ('#error: Argument $x passed to TestPresenter::handleNull() must be int, array given. ' , $ this ->link ('null! ' , [1 ], (object ) [1 ]));
64+ Assert::same ('/index.php?y=2&action=default&do=null&presenter=Test ' , $ this ->link ('null! ' , [1 , 'y ' => 2 ]));
65+ Assert::same ('/index.php?y=2&action=default&do=null&presenter=Test ' , $ this ->link ('null! ' , ['x ' => 1 , 'y ' => 2 , 'var1 ' => $ this ->var1 ]));
66+ Assert::same ('#error: Argument $bool passed to TestPresenter::handleNull() must be bool, integer given. ' , $ this ->link ('null! ' , 1 , 2 , 3 ));
67+ Assert::same ('#error: Argument $x passed to TestPresenter::handleNull() must be int, array given. ' , $ this ->link ('null! ' , [[]]));
68+ Assert::same ('/index.php?action=default&do=null&presenter=Test ' , $ this ->link ('null! ' ));
69+ Assert::same ('#error: Argument $x passed to TestPresenter::handleNull() must be int, stdClass given. ' , $ this ->link ('null! ' , [new stdClass ]));
5270 }
5371
5472
5573 public function handleHint (int $ x = 1 , int $ y , bool $ bool , string $ str )
5674 {
5775 }
5876
77+
78+ public function handleNull (int $ x = 1 , int $ y = NULL , bool $ bool = NULL , string $ str = NULL )
79+ {
80+ }
81+
5982}
6083
6184
0 commit comments