eZ\Bundle\EzPublishCoreBundle\Tests\Routing\UrlAliasRouterTest::testMatchRequestLocationCaseRedirectWithRootRootLocation PHP Method

testMatchRequestLocationCaseRedirectWithRootRootLocation() public method

    public function testMatchRequestLocationCaseRedirectWithRootRootLocation()
    {
        $rootLocationId = 123;
        $this->resetConfigResolver();
        $this->configResolver->expects($this->any())->method('getParameter')->will($this->returnValueMap(array(array('url_alias_router', null, null, true))));
        $this->router->setRootLocationId($rootLocationId);
        $prefix = '/';
        $this->urlALiasGenerator->expects($this->exactly(2))->method('getPathPrefixByRootLocationId')->with($rootLocationId)->will($this->returnValue($prefix));
        $locationId = 789;
        $path = '/foo/bar';
        $requestedPath = '/Foo/Bar';
        $urlAlias = new URLAlias(array('destination' => $locationId, 'path' => $path, 'type' => URLAlias::LOCATION, 'isHistory' => false));
        $this->urlAliasService->expects($this->once())->method('lookup')->with($requestedPath)->will($this->returnValue($urlAlias));
        $this->urlALiasGenerator->expects($this->once())->method('loadLocation')->will($this->returnValue(new Location(array('contentInfo' => new ContentInfo(array('id' => 456))))));
        $expected = array('_route' => UrlAliasRouter::URL_ALIAS_ROUTE_NAME, '_controller' => UrlAliasRouter::VIEW_ACTION, 'locationId' => $locationId, 'contentId' => 456, 'viewType' => ViewManager::VIEW_TYPE_FULL, 'layout' => true);
        $request = $this->getRequestByPathInfo($requestedPath);
        $this->assertEquals($expected, $this->router->matchRequest($request));
        $this->assertSame($locationId, $request->attributes->get('locationId'));
        $this->assertTrue($request->attributes->get('needsRedirect'));
        $this->assertSame($path, $request->attributes->get('semanticPathinfo'));
    }