diff --git a/Page/Service/DefaultPageService.php b/Page/Service/DefaultPageService.php index 6619b292a..35759a023 100644 --- a/Page/Service/DefaultPageService.php +++ b/Page/Service/DefaultPageService.php @@ -73,7 +73,7 @@ protected function updateSeoPage(PageInterface $page) return; } - if ($page->getTitle()) { + if (!$this->seoPage->getTitle()) { $this->seoPage->setTitle($page->getTitle() ?: $page->getName()); } diff --git a/Tests/Page/Service/DefaultPageServiceTest.php b/Tests/Page/Service/DefaultPageServiceTest.php index 978cc8d2b..cd7d7beca 100644 --- a/Tests/Page/Service/DefaultPageServiceTest.php +++ b/Tests/Page/Service/DefaultPageServiceTest.php @@ -60,7 +60,8 @@ public function testExecute() // mock a page instance $page = $this->getMock('Sonata\PageBundle\Model\PageInterface'); - $page->expects($this->exactly(2))->method('getTitle')->will($this->returnValue('page title')); + $this->seoPage->expects($this->once())->method('getTitle')->will($this->returnValue(null)); + $page->expects($this->once())->method('getTitle')->will($this->returnValue('page title')); $page->expects($this->atLeastOnce())->method('getMetaDescription')->will($this->returnValue('page meta description')); $page->expects($this->atLeastOnce())->method('getMetaKeyword')->will($this->returnValue('page meta keywords')); $page->expects($this->once())->method('getTemplateCode')->will($this->returnValue('template code'));