FIX Update alternateTreeTitle to updateTreeTitle

This commit is contained in:
Robbie Averill 2017-08-30 11:54:42 +12:00
parent e129cafa94
commit 38031887a9
2 changed files with 15 additions and 13 deletions

View File

@ -123,20 +123,20 @@ class GroupSubsites extends DataExtension implements PermissionProvider
} }
/** /**
* If this group belongs to a subsite, * If this group belongs to a subsite, append the subsites title to the group title to make it easy to
* append the subsites title to the group title * distinguish in the tree-view of the security admin interface.
* 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) { if ($this->owner->AccessAllSubsites) {
$title = _t('GroupSubsites.GlobalGroup', 'global group'); $title = _t('GroupSubsites.GlobalGroup', 'global group');
return htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' <i>(' . $title . ')</i>'; $title = htmlspecialchars($this->owner->Title, ENT_QUOTES) . ' <i>(' . $title . ')</i>';
} } else {
$subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title'))); $subsites = Convert::raw2xml(implode(', ', $this->owner->Subsites()->column('Title')));
return htmlspecialchars($this->owner->Title) . " <i>($subsites)</i>"; $title = htmlspecialchars($this->owner->Title) . " <i>($subsites)</i>";
}
} }
/** /**

View File

@ -15,8 +15,8 @@ class GroupSubsitesTest extends BaseSubsiteTest
public function testTrivialFeatures() public function testTrivialFeatures()
{ {
$this->assertTrue(is_array(singleton(GroupSubsites::class)->extraStatics())); $this->assertInternalType('array', singleton(GroupSubsites::class)->extraStatics());
$this->assertTrue(is_array(singleton(GroupSubsites::class)->providePermissions())); $this->assertInternalType('array', singleton(GroupSubsites::class)->providePermissions());
$this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields()); $this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields());
} }
@ -25,11 +25,13 @@ class GroupSubsitesTest extends BaseSubsiteTest
$group = new Group(); $group = new Group();
$group->Title = 'The A Team'; $group->Title = 'The A Team';
$group->AccessAllSubsites = true; $group->AccessAllSubsites = true;
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(global group)</i>'); $this->assertEquals('The A Team <i>(global group)</i>', $group->getTreeTitle());
$group->AccessAllSubsites = false; $group->AccessAllSubsites = false;
$group->write(); $group->write();
$group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest1')); $group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest1'));
$group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest2')); $group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest2'));
$this->assertEquals($group->getTreeTitle(), 'The A Team <i>(Test 1, Test 2)</i>'); $this->assertEquals('The A Team <i>(Test 1, Test 2)</i>', $group->getTreeTitle());
} }
} }