public function testCanonicalUrlForHomepage() { $expected = 'http://foo.dev/'; /** @var \Silex\Application $app */ $app = $this->getApp(); $app['config']->set('general/homepage', 'page/1'); $this->setRequest(Request::create($expected)); $app['request_context']->fromRequest($this->getRequest()); $templates = $this->getMockBuilder(TemplateChooser::class)->setMethods(['record'])->setConstructorArgs([$this->getApp()])->getMock(); $templates->expects($this->any())->method('record')->will($this->returnValue('index.twig')); $this->setService('templatechooser', $templates); // Route for /page/1 instead of homepage $this->controller()->record($this->getRequest(), 'page', '1'); $this->assertEquals($expected, $app['canonical']->getUrl(), 'Canonical url should be homepage'); }