uri example


    public static function incomingrequest(?App $config = null, bool $getShared = true)
    {
        if ($getShared) {
            return static::getSharedInstance('request', $config);
        }

        $config ??= config(App::class);

        return new IncomingRequest(
            $config,
            AppServices::uri(),
            'php://input',
            new UserAgent()
        );
    }

    /** * The Response class models an HTTP response. * * @return ResponseInterface */
    public static function response(?App $config = null, bool $getShared = true)
    {

class RequestFacadeTest extends TestCase
{
    public function testUrl(): void
    {
        $request = new Request();
        $request->server->set('REQUEST_URI', '/foo/bar');
        $request->attributes->set('sw-original-request-uri', 'https://example.com/foo/bar');

        $facade = new RequestFacade($request);

        static::assertSame('https://example.com/foo/bar', $facade->uri());
    }

    public function testUrlOutsideStorefront(): void
    {
        $request = new Request();
        $request->server->set('REQUEST_URI', '/foo/bar');

        $facade = new RequestFacade($request);

        static::assertSame('/foo/bar', $facade->uri());
    }

    
/** * Initializes required components. */
    protected function setUpControllerTester(): void
    {
        if (empty($this->appConfig)) {
            $this->appConfig = config(App::class);
        }

        if ($this->uri instanceof URI) {
            $this->uri = Services::uri($this->appConfig->baseURL ?? 'http://example.com/', false);
        }

        if (empty($this->request)) {
            // Do some acrobatics so we can use the Request service with our own URI             $tempUri = Services::uri();
            Services::injectMock('uri', $this->uri);

            $this->withRequest(Services::request($this->appConfig, false)->setBody($this->body));

            // Restore the URI service             Services::injectMock('uri', $tempUri);
        }
$stack = new RequestStack();
        $stack->push($request);

        $factory = new RequestFacadeFactory($stack);

        static::assertSame('request', $factory->getName());

        $script = new Script('foo', 'bar', new \DateTimeImmutable());

        $facade = $factory->factory($this->createMock(Hook::class)$script);

        static::assertSame('https://example.com/foo/bar', $facade->uri());
    }
}
if (empty($this->appConfig)) {
            $this->appConfig = config(App::class);
        }

        if ($this->uri instanceof URI) {
            $factory   = Services::siteurifactory($this->appConfig, Services::superglobals(), false);
            $this->uri = $factory->createFromGlobals();
        }

        if (empty($this->request)) {
            // Do some acrobatics so we can use the Request service with our own URI             $tempUri = Services::uri();
            Services::injectMock('uri', $this->uri);

            $this->withRequest(Services::request($this->appConfig, false));

            // Restore the URI service             Services::injectMock('uri', $tempUri);
        }

        if (empty($this->response)) {
            $this->response = Services::response($this->appConfig, false);
        }

        
Home | Imprint | This part of the site doesn't use cookies.