Networking\InitCmsBundle\Tests\Helper\LanguageSwitcherHelperTest::testGetTranslationRoute_PageWithTranslation_ShouldReturnContentRoute PHP Method

testGetTranslationRoute_PageWithTranslation_ShouldReturnContentRoute() public method

    public function testGetTranslationRoute_PageWithTranslation_ShouldReturnContentRoute()
    {
        $contentRouteDe = new ContentRoute();
        $contentRouteEn = new ContentRoute();
        $dePage = new Page();
        $dePage->setLocale('de');
        $dePage->setMetaTitle('German page with english translation');
        $dePage->setContentRoute($contentRouteDe);
        $enPage = new Page();
        $enPage->setLocale('en');
        $enPage->setMetaTitle('English translation');
        $enPage->setContentRoute($contentRouteEn);
        $dePage->setTranslations(array($enPage));
        $request = $this->getMock('Symfony\\Component\\HttpFoundation\\Request');
        $request2 = Request::create('/foo');
        $router = $this->getMockBuilder('Symfony\\Cmf\\Component\\Routing\\DynamicRouter')->disableOriginalConstructor()->getMock();
        $router->expects($this->at(0))->method('matchRequest')->with($request2)->will($this->returnValue(array('_content' => $dePage)));
        $helper = $this->getLanguageHelper($request, $router, $request2);
        $result = $helper->getTranslationRoute('/foo', 'en');
        $this->assertInstanceOf('Networking\\InitCmsBundle\\Component\\Routing\\Route', $result);
    }