diff --git a/code/extensions/GroupSubsites.php b/code/extensions/GroupSubsites.php index bd60f00a..a0290a2e 100644 --- a/code/extensions/GroupSubsites.php +++ b/code/extensions/GroupSubsites.php @@ -123,20 +123,20 @@ public function updateCMSFields(FieldList $fields) } /** - * If this group belongs to a subsite, - * append the subsites title to the group title - * to make it easy to distinguish in the tree-view - * of the security admin interface. + * If this group belongs to a subsite, append the subsites title to the group title to make it easy to + * distinguish in the tree-view of the security admin interface. + * + * @param string $title */ - public function alternateTreeTitle() + public function updateTreeTitle(&$title) { if ($this->owner->AccessAllSubsites) { $title = _t('GroupSubsites.GlobalGroup', 'global group'); - return htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' (' . $title . ')'; + $title = htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' (' . $title . ')'; + } else { + $subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title'))); + $title = htmlspecialchars($this->owner->Title) . " ($subsites)"; } - - $subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title'))); - return htmlspecialchars($this->owner->Title) . " ($subsites)"; } /** diff --git a/tests/php/GroupSubsitesTest.php b/tests/php/GroupSubsitesTest.php index ed35292a..c2eaa3e4 100644 --- a/tests/php/GroupSubsitesTest.php +++ b/tests/php/GroupSubsitesTest.php @@ -15,8 +15,8 @@ class GroupSubsitesTest extends BaseSubsiteTest public function testTrivialFeatures() { - $this->assertTrue(is_array(singleton(GroupSubsites::class)->extraStatics())); - $this->assertTrue(is_array(singleton(GroupSubsites::class)->providePermissions())); + $this->assertInternalType('array', singleton(GroupSubsites::class)->extraStatics()); + $this->assertInternalType('array', singleton(GroupSubsites::class)->providePermissions()); $this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields()); } @@ -25,11 +25,13 @@ public function testAlternateTreeTitle() $group = new Group(); $group->Title = 'The A Team'; $group->AccessAllSubsites = true; - $this->assertEquals($group->getTreeTitle(), 'The A Team (global group)'); + $this->assertEquals('The A Team (global group)', $group->getTreeTitle()); + $group->AccessAllSubsites = false; $group->write(); + $group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest1')); $group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest2')); - $this->assertEquals($group->getTreeTitle(), 'The A Team (Test 1, Test 2)'); + $this->assertEquals('The A Team (Test 1, Test 2)', $group->getTreeTitle()); } }