Limitation: If the element number is > 1, we cannot predict how URI segments are expected to be built.
So we expect "_" will be reversed to "/"
e.g. foo_bar => foo/bar with elementNumber == 2
Hence if number of elements is different than the element number, we report as non matched.
public reverseMatch ( string $siteAccessName ) : |
||
$siteAccessName | string | |
return |
/** * @dataProvider reverseMatchProvider */ public function testReverseMatch($siteAccessName, $originalPathinfo) { $matcher = new URIElementMatcher(1); $matcher->setRequest(new SimplifiedRequest(array('pathinfo' => $originalPathinfo))); $result = $matcher->reverseMatch($siteAccessName); $this->assertInstanceOf('eZ\\Publish\\Core\\MVC\\Symfony\\SiteAccess\\Matcher\\URIElement', $result); $this->assertSame("/{$siteAccessName}{$originalPathinfo}", $result->getRequest()->pathinfo); $this->assertSame("/{$siteAccessName}/some/linked/uri", $result->analyseLink('/some/linked/uri')); $this->assertSame('/foo/bar/baz', $result->analyseURI("/{$siteAccessName}/foo/bar/baz")); }
public function testReverseMatchFail() { $matcher = new URIElementMatcher(array(2)); $matcher->setRequest(new SimplifiedRequest(array('pathinfo' => '/my/siteaccess/foo/bar'))); $this->assertNull($matcher->reverseMatch('another_siteaccess_again_dont_tell_me')); }