コード例 #1
0
 public function testReverseMatch2()
 {
     $request = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\Routing\\SimplifiedRequest');
     $siteAccessName = 'fr_eng';
     $mapUriConfig = array('eng' => true);
     $mapHostConfig = array('fr.ezpublish.dev' => true);
     $compoundMatcher = new LogicalOr(array(array('matchers' => array('Map\\URI' => $mapUriConfig, 'Map\\Host' => $mapHostConfig), 'match' => $siteAccessName)));
     $compoundMatcher->setRequest($request);
     $matcher1 = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\VersatileMatcher');
     $matcher2 = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\VersatileMatcher');
     $this->matcherBuilder->expects($this->exactly(2))->method('buildMatcher')->will($this->returnValueMap(array(array('Map\\URI', $mapUriConfig, $request, $matcher1), array('Map\\Host', $mapHostConfig, $request, $matcher2))));
     $matcher1->expects($this->once())->method('reverseMatch')->with($siteAccessName)->will($this->returnValue(null));
     $reverseMatchedMatcher2 = $this->getMock('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\VersatileMatcher');
     $matcher2->expects($this->once())->method('reverseMatch')->with($siteAccessName)->will($this->returnValue($reverseMatchedMatcher2));
     $compoundMatcher->setMatcherBuilder($this->matcherBuilder);
     $result = $compoundMatcher->reverseMatch($siteAccessName);
     $this->assertInstanceOf('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\Matcher\\Compound\\LogicalOr', $result);
     foreach ($result->getSubMatchers() as $subMatcher) {
         $this->assertInstanceOf('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\VersatileMatcher', $subMatcher);
     }
 }
コード例 #2
0
 public function testSerialize()
 {
     $matcher = new LogicalOr(array());
     $matcher->setRequest(new SimplifiedRequest(array('pathinfo' => '/foo/bar')));
     $sa = new SiteAccess('test', 'test', $matcher);
     $serializedSA1 = serialize($sa);
     $matcher->setRequest(new SimplifiedRequest(array('pathinfo' => '/foo/bar/baz')));
     $serializedSA2 = serialize($sa);
     $this->assertSame($serializedSA1, $serializedSA2);
 }