@@ -92,6 +92,22 @@ class TestPresenter extends Application\UI\Presenter
9292 Assert::same ('/index.php?x=1&y=2&action=product&presenter=Test ' , $ this ->link ('product?x=1&y=2 ' ));
9393 Assert::same ('/index.php?x=1&y=2&action=product&presenter=Test#fragment ' , $ this ->link ('product?x=1&y=2#fragment ' ));
9494
95+ // fragment via args
96+ Assert::same ('/index.php?action=product&presenter=Test#fragment ' , $ this ->link ('product ' , ['# ' => 'fragment ' ]));
97+ Assert::same ('/index.php?x=1&action=product&presenter=Test#fragment ' , $ this ->link ('product ' , ['x ' => 1 , '# ' => 'fragment ' ]));
98+ Assert::same ('/index.php?action=product&presenter=Test#b ' , $ this ->link ('product#a ' , ['# ' => 'b ' ])); // args win over destination
99+ Assert::same ('/index.php?action=product&presenter=Test#a ' , $ this ->link ('product#a ' , ['# ' => '' ])); // empty arg falls back to destination
100+ Assert::same ('/index.php?action=product&presenter=Test ' , $ this ->link ('product ' , ['# ' => '' ])); // empty fragment omitted
101+ Assert::same ('/index.php?action=product&presenter=Test ' , $ this ->link ('product ' , ['# ' => null ]));
102+ Assert::same (['pint ' => null , 'parr ' => null , 'pbool ' => null , 'action ' => 'product ' ], $ this ->getLastCreatedRequest ()->getParameters ()); // # not propagated to request
103+ Assert::same ('http://localhost/index.php?x=1&action=product&presenter=Test#fragment ' , $ this ->link ('//product ' , ['x ' => 1 , '# ' => 'fragment ' ]));
104+ Assert::same ('/index.php?action=product&presenter=Test#hello%20world%20%26%20co ' , $ this ->link ('product ' , ['# ' => 'hello world & co ' ])); // URL encoding
105+ Assert::same ('/index.php?action=product&presenter=Test#42 ' , $ this ->link ('product ' , ['# ' => 42 ])); // scalar coercion
106+ Assert::same ("#error: Value of '#' must be scalar, array given. " , $ this ->link ('product ' , ['# ' => [1 , 2 ]]));
107+ Assert::same ("#error: Value of '#' must be scalar, stdClass given. " , $ this ->link ('product ' , ['# ' => new stdClass ]));
108+ Assert::same ('/index.php?mycontrol-x=1&mycontrol-y=2&action=default&do=mycontrol-click&presenter=Test#frag ' , $ this ['mycontrol ' ]->link ('click ' , ['x ' => 1 , 'y ' => 2 , '# ' => 'frag ' ])); // component signal + fragment
109+ Assert::same ('/index.php?action=product&presenter=Test#frag ' , (string ) new Application \UI \Link ($ this , 'product ' , ['# ' => 'frag ' ])); // Link class
110+
95111 // absolute
96112 Assert::same ('http://localhost/index.php?x=1&y=2&action=product&presenter=Test#fragment ' , $ this ->link ('//product?x=1&y=2#fragment ' ));
97113 $ this ->absoluteUrls = true ;
0 commit comments