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

testMatchRequestWithRootLocation() public method

    public function testMatchRequestWithRootLocation()
    {
        $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 = '/root/prefix';
        $this->urlALiasGenerator->expects($this->exactly(2))->method('getPathPrefixByRootLocationId')->with($rootLocationId)->will($this->returnValue($prefix));
        $locationId = 789;
        $path = '/foo/bar';
        $urlAlias = new URLAlias(array('destination' => $locationId, 'path' => $prefix . $path, 'type' => URLAlias::LOCATION, 'isHistory' => false));
        $this->urlAliasService->expects($this->once())->method('lookup')->with($prefix . $path)->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($path);
        $this->assertEquals($expected, $this->router->matchRequest($request));
        $this->assertSame($locationId, $request->attributes->get('locationId'));
    }