eZ\Bundle\EzPublishCoreBundle\Tests\EventListener\SiteAccessListenerTest::testOnSiteAccessMatchMasterRequest PHP Method

testOnSiteAccessMatchMasterRequest() public method

public testOnSiteAccessMatchMasterRequest ( $uri, $expectedSemanticPathinfo, $expectedVPString, array $expectedVPArray )
$expectedVPArray array
    public function testOnSiteAccessMatchMasterRequest($uri, $expectedSemanticPathinfo, $expectedVPString, array $expectedVPArray)
    {
        $uri = rawurldecode($uri);
        $semanticPathinfoPos = strpos($uri, $expectedSemanticPathinfo);
        if ($semanticPathinfoPos !== 0) {
            $semanticPathinfo = substr($uri, $semanticPathinfoPos);
            $matcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\URILexer');
            $matcher->expects($this->once())->method('analyseURI')->with($uri)->will($this->returnValue($semanticPathinfo));
        } else {
            $matcher = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\Matcher');
        }
        $defaultSiteAccess = new SiteAccess('default');
        $siteAccess = new SiteAccess('test', 'test', $matcher);
        $request = Request::create($uri);
        $event = new PostSiteAccessMatchEvent($siteAccess, $request, HttpKernelInterface::MASTER_REQUEST);
        $this->container->expects($this->once())->method('get')->with('ezpublish.siteaccess')->willReturn($defaultSiteAccess);
        $this->listener->onSiteAccessMatch($event);
        $this->assertSame($expectedSemanticPathinfo, $request->attributes->get('semanticPathinfo'));
        $this->assertSame($expectedVPArray, $request->attributes->get('viewParameters'));
        $this->assertSame($expectedVPString, $request->attributes->get('viewParametersString'));
        $this->assertSame($defaultSiteAccess->name, $siteAccess->name);
        $this->assertSame($defaultSiteAccess->matchingType, $siteAccess->matchingType);
        $this->assertSame($defaultSiteAccess->matcher, $siteAccess->matcher);
    }