Skip to content

Commit

Permalink
Check for empty seo title when setting a default one
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Jan 15, 2017
1 parent 85783f3 commit 5446c18
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Page/Service/DefaultPageService.php
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ protected function updateSeoPage(PageInterface $page)
return;
}

if ($page->getTitle()) {
if (!$this->seoPage->getTitle()) {
$this->seoPage->setTitle($page->getTitle() ?: $page->getName());
}

Expand Down
3 changes: 2 additions & 1 deletion Tests/Page/Service/DefaultPageServiceTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'));
Expand Down

0 comments on commit 5446c18

Please sign in to comment.