@@ -18,6 +18,9 @@ class TestPresenter extends Application\UI\Presenter
18
18
/** @persistent */
19
19
public $ var1 = 10 ;
20
20
21
+ /** @persistent */
22
+ public $ var2 ;
23
+
21
24
22
25
protected function createTemplate ($ class = NULL )
23
26
{
@@ -33,7 +36,8 @@ class TestPresenter extends Application\UI\Presenter
33
36
Assert::same ('/index.php?var1=20&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , ['var1 ' => $ this ->var1 * 2 ]));
34
37
Assert::same ('/index.php?y=2&action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , 1 , 2 ));
35
38
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 ' => '' ]));
37
41
Assert::same ('/index.php?action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' , [1 ]));
38
42
Assert::same ('#error: Argument $x passed to TestPresenter::handleHint() must be int, array given. ' , $ this ->link ('hint! ' , [1 ], (object ) [1 ]));
39
43
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
43
47
Assert::same ('/index.php?action=default&presenter=Test ' , $ this ->link ('this! ' , ['var1 ' => $ this ->var1 ]));
44
48
Assert::same ('/index.php?sort%5By%5D%5Basc%5D=1&action=default&presenter=Test ' , $ this ->link ('this ' , ['sort ' => ['y ' => ['asc ' => TRUE ]]]));
45
49
46
- // Presenter & signal link type checking
50
+ // type checking
47
51
Assert::same ('#error: Argument $x passed to TestPresenter::handleHint() must be int, string given. ' , $ this ->link ('hint! ' , 'x ' ));
48
52
Assert::same ('#error: Argument $bool passed to TestPresenter::handleHint() must be bool, integer given. ' , $ this ->link ('hint! ' , 1 , 2 , 3 ));
49
53
Assert::same ('#error: Argument $x passed to TestPresenter::handleHint() must be int, array given. ' , $ this ->link ('hint! ' , [[]]));
50
54
Assert::same ('/index.php?action=default&do=hint&presenter=Test ' , $ this ->link ('hint! ' ));
51
55
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 ]));
52
70
}
53
71
54
72
55
73
public function handleHint (int $ x = 1 , int $ y , bool $ bool , string $ str )
56
74
{
57
75
}
58
76
77
+
78
+ public function handleNull (int $ x = 1 , int $ y = NULL , bool $ bool = NULL , string $ str = NULL )
79
+ {
80
+ }
81
+
59
82
}
60
83
61
84
0 commit comments