From 38031887a90fb214a47e992503c4541d934f0152 Mon Sep 17 00:00:00 2001 From: Robbie Averill Date: Wed, 30 Aug 2017 11:54:42 +1200 Subject: [PATCH] FIX Update alternateTreeTitle to updateTreeTitle --- code/extensions/GroupSubsites.php | 18 +++++++++--------- tests/php/GroupSubsitesTest.php | 10 ++++++---- 2 files changed, 15 insertions(+), 13 deletions(-) diff --git a/code/extensions/GroupSubsites.php b/code/extensions/GroupSubsites.php index bd60f00..a0290a2 100644 --- a/code/extensions/GroupSubsites.php +++ b/code/extensions/GroupSubsites.php @@ -123,20 +123,20 @@ class GroupSubsites extends DataExtension implements PermissionProvider } /** - * 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 ed35292..c2eaa3e 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 @@ class GroupSubsitesTest extends BaseSubsiteTest $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()); } }