function routeIn(Nette\Application\IRouter $route, $url, $expectedPresenter = NULL, $expectedParams = NULL, $expectedUrl = NULL, $scriptPath = NULL) { $url = new Nette\Http\UrlScript("http://example.com{$url}"); if ($scriptPath) { $url->setScriptPath($scriptPath); } if ($url->getQueryParameter('presenter') === NULL) { $url->setQueryParameter('presenter', 'querypresenter'); } $url->appendQuery(['test' => 'testvalue']); $httpRequest = new Nette\Http\Request($url); $request = $route->match($httpRequest); if ($request) { // matched $params = $request->getParameters(); asort($params); asort($expectedParams); Assert::same($expectedPresenter, $request->getPresenterName()); Assert::same($expectedParams, $params); $result = $route->constructUrl($request, $url); Assert::same($expectedUrl, $result); } else { // not matched Assert::null($expectedPresenter); } }
/** * @param array $args * @return \Nette\Http\UrlScript */ protected function getUrl($args = []) { $url = new \Nette\Http\UrlScript(); $args = array_merge($this->params, $args); if (!array_key_exists('signature', $args)) { $args['signature'] = $this->getCorrectSignature(array_merge(['password' => 'my$up3rsecr3tp4$$word', 'merchantId' => 1, 'accountId' => 3], $args)); } foreach ($args as $name => $value) { if (is_array($value)) { $value = serialize($value); } $url->setQueryParameter($name, $value); } return $url; }