/** * Tries to detect the base URI of request. * * @return void */ protected function detectBaseUri() { if ($this->baseUri === null) { $this->baseUri = clone $this->uri; $this->baseUri->setQuery(null); $this->baseUri->setFragment(null); $this->baseUri->setPath($this->getScriptRequestPath()); } }
/** * Sets up this test case */ public function setUp() { $this->routerCachingService = $this->getAccessibleMock(RouterCachingService::class, ['dummy']); $this->mockRouteCache = $this->getMockBuilder(VariableFrontend::class)->disableOriginalConstructor()->getMock(); $this->inject($this->routerCachingService, 'routeCache', $this->mockRouteCache); $this->mockResolveCache = $this->getMockBuilder(StringFrontend::class)->disableOriginalConstructor()->getMock(); $this->inject($this->routerCachingService, 'resolveCache', $this->mockResolveCache); $this->mockPersistenceManager = $this->getMockBuilder(PersistenceManagerInterface::class)->getMock(); $this->inject($this->routerCachingService, 'persistenceManager', $this->mockPersistenceManager); $this->mockSystemLogger = $this->getMockBuilder(SystemLoggerInterface::class)->getMock(); $this->inject($this->routerCachingService, 'systemLogger', $this->mockSystemLogger); $this->mockObjectManager = $this->createMock(ObjectManagerInterface::class); $this->mockApplicationContext = $this->getMockBuilder(ApplicationContext::class)->disableOriginalConstructor()->getMock(); $this->mockObjectManager->expects($this->any())->method('getContext')->will($this->returnValue($this->mockApplicationContext)); $this->inject($this->routerCachingService, 'objectManager', $this->mockObjectManager); $this->inject($this->routerCachingService, 'objectManager', $this->mockObjectManager); $this->mockHttpRequest = $this->getMockBuilder(\Neos\Flow\Http\Request::class)->disableOriginalConstructor()->getMock(); $this->mockHttpRequest->expects($this->any())->method('getMethod')->will($this->returnValue('GET')); $this->mockHttpRequest->expects($this->any())->method('getRelativePath')->will($this->returnValue('some/route/path')); $this->mockUri = $this->getMockBuilder(\Neos\Flow\Http\Uri::class)->disableOriginalConstructor()->getMock(); $this->mockUri->expects($this->any())->method('getHost')->will($this->returnValue('subdomain.domain.com')); $this->mockHttpRequest->expects($this->any())->method('getUri')->will($this->returnValue($this->mockUri)); }
/** * @test * @expectedException \InvalidArgumentException */ public function settingInvalidHostThrowsException() { $uri = new Uri(''); $uri->setHost('an#invalid.host'); }
/** * @param string|Uri $uri * @return string */ public function getScheme($uri) { if ($uri instanceof Uri) { return $uri->getScheme(); } if (preg_match(self::PATTERN_SUPPORTED_URIS, $uri, $matches) === 1) { return $matches[1]; } return ''; }