2010-03-21 23:32:22 +01:00
|
|
|
<?php
|
|
|
|
|
2017-04-23 22:23:34 +02:00
|
|
|
namespace SilverStripe\Subsites\Tests;
|
|
|
|
|
2017-05-29 13:42:42 +02:00
|
|
|
use SilverStripe\Forms\FieldList;
|
2017-06-01 15:57:53 +02:00
|
|
|
use SilverStripe\Security\Group;
|
2017-05-24 15:25:34 +02:00
|
|
|
use SilverStripe\Subsites\Extensions\GroupSubsites;
|
|
|
|
use SilverStripe\Subsites\Model\Subsite;
|
|
|
|
|
2017-05-24 15:26:28 +02:00
|
|
|
class GroupSubsitesTest extends BaseSubsiteTest
|
|
|
|
{
|
2017-08-29 07:22:32 +02:00
|
|
|
protected static $fixture_file = 'SubsiteTest.yml';
|
2017-05-24 15:26:28 +02:00
|
|
|
|
|
|
|
protected $requireDefaultRecordsFrom = [GroupSubsites::class];
|
2017-06-01 15:57:53 +02:00
|
|
|
|
2017-05-29 13:42:42 +02:00
|
|
|
public function testTrivialFeatures()
|
2017-05-24 15:26:28 +02:00
|
|
|
{
|
2017-08-30 01:54:42 +02:00
|
|
|
$this->assertInternalType('array', singleton(GroupSubsites::class)->extraStatics());
|
|
|
|
$this->assertInternalType('array', singleton(GroupSubsites::class)->providePermissions());
|
2017-06-01 15:12:18 +02:00
|
|
|
$this->assertInstanceOf(FieldList::class, singleton(Group::class)->getCMSFields());
|
2017-05-24 15:26:28 +02:00
|
|
|
}
|
|
|
|
|
2017-05-29 13:42:42 +02:00
|
|
|
public function testAlternateTreeTitle()
|
2017-05-24 15:26:28 +02:00
|
|
|
{
|
|
|
|
$group = new Group();
|
|
|
|
$group->Title = 'The A Team';
|
|
|
|
$group->AccessAllSubsites = true;
|
2017-08-30 01:54:42 +02:00
|
|
|
$this->assertEquals('The A Team <i>(global group)</i>', $group->getTreeTitle());
|
|
|
|
|
2017-05-24 15:26:28 +02:00
|
|
|
$group->AccessAllSubsites = false;
|
|
|
|
$group->write();
|
2017-08-30 01:54:42 +02:00
|
|
|
|
2017-05-24 15:26:28 +02:00
|
|
|
$group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest1'));
|
|
|
|
$group->Subsites()->add($this->objFromFixture(Subsite::class, 'domaintest2'));
|
2017-08-30 01:54:42 +02:00
|
|
|
$this->assertEquals('The A Team <i>(Test 1, Test 2)</i>', $group->getTreeTitle());
|
2017-05-24 15:26:28 +02:00
|
|
|
}
|
|
|
|
}
|