public function testMatchByName()
{
$matcherBuilder = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\MatcherBuilderInterface');
$logger = $this->getMock('Psr\\Log\\LoggerInterface');
$matcherClass = 'Map\\Host';
$matchedSiteAccess = 'foo';
$matcherConfig = array('phoenix-rises.fm' => $matchedSiteAccess);
$config = array('Map\\URI' => array('default' => 'default_sa'), $matcherClass => $matcherConfig);
$router = new Router($matcherBuilder, $logger, 'default_sa', $config, array($matchedSiteAccess, 'default_sa'));
$matcherInitialSA = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\URILexer');
$router->setSiteAccess(new SiteAccess('test', 'test', $matcherInitialSA));
$matcherInitialSA->expects($this->once())->method('analyseURI');
$matcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\VersatileMatcher');
$matcherBuilder->expects($this->exactly(2))->method('buildMatcher')->will($this->onConsecutiveCalls($this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\Matcher'), $matcher));
$reverseMatchedMatcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\VersatileMatcher');
$matcher->expects($this->once())->method('reverseMatch')->with($matchedSiteAccess)->will($this->returnValue($reverseMatchedMatcher));
$siteAccess = $router->matchByName($matchedSiteAccess);
$this->assertInstanceOf('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess', $siteAccess);
$this->assertSame($reverseMatchedMatcher, $siteAccess->matcher);
$this->assertSame($matchedSiteAccess, $siteAccess->name);
}