Esempio n. 1
0
 public function setSchemeAndHost($scheme, $host)
 {
     $url = new \Nette\Http\UrlScript();
     $url->setScheme($scheme);
     $url->setHost($host);
     $this->httpRequest = new HttpRequest($url);
 }
Esempio n. 2
0
 /**
  * @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;
 }
Esempio n. 3
0
 /**
  * @return \TestPresenter
  */
 private function createPresenter()
 {
     $url = new \Nette\Http\UrlScript('http://localhost/');
     $url->setScriptPath('/');
     $configurator = new \Nette\Config\Configurator();
     $configurator->addConfig(__DIR__ . '/config.neon');
     \Nella\Doctrine\Config\Extension::register($configurator);
     $container = $configurator->setTempDirectory(TEMP_DIR)->createContainer();
     $container->removeService('httpRequest');
     $container->addService('httpRequest', new \Nette\Http\Request($url));
     $application = $container->getService('application');
     $application->router[] = new \Nette\Application\Routers\SimpleRouter();
     $presenter = new TestPresenter($container);
     $presenter->invalidLinkMode = $presenter::INVALID_LINK_WARNING;
     $presenter->autoCanonicalize = FALSE;
     return $presenter;
 }
Esempio n. 4
0
File: Helper.php Progetto: o5/grido
 /**
  * @return \TestPresenter
  */
 private function createPresenter()
 {
     $url = new \Nette\Http\UrlScript('http://localhost/');
     $url->setScriptPath('/');
     $configurator = new \Nette\Configurator();
     $configurator->addConfig(__DIR__ . '/config.neon');
     \Kdyby\Events\DI\EventsExtension::register($configurator);
     \Kdyby\Annotations\DI\AnnotationsExtension::register($configurator);
     \Kdyby\Doctrine\DI\OrmExtension::register($configurator);
     $container = $configurator->setTempDirectory(TEMP_DIR)->createContainer();
     $container->removeService('httpRequest');
     $container->addService('httpRequest', new \Nette\Http\Request($url));
     $router = $container->getByType(\Nette\Application\IRouter::class);
     $router[] = new \Nette\Application\Routers\Route('<presenter>/<action>[/<id>]', 'Dashboard:default');
     $presenter = new TestPresenter($container);
     $container->callInjects($presenter);
     $presenter->invalidLinkMode = $presenter::INVALID_LINK_WARNING;
     $presenter->autoCanonicalize = FALSE;
     return $presenter;
 }
Esempio n. 5
0
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);
    }
}
Esempio n. 6
0
function toRelativePath($url)
{
    $urlscript = new Nette\Http\UrlScript($url);
    return rtrim($urlscript->getPath(), '/');
}