mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge remote-tracking branch 'origin/3.2' into 3
This commit is contained in:
commit
19b10044ec
@ -263,6 +263,10 @@ class Group extends DataObject {
|
|||||||
|
|
||||||
// First get direct members as a base result
|
// First get direct members as a base result
|
||||||
$result = $this->DirectMembers();
|
$result = $this->DirectMembers();
|
||||||
|
|
||||||
|
// Unsaved group cannot have child groups because its ID is still 0.
|
||||||
|
if(!$this->exists()) return $result;
|
||||||
|
|
||||||
// Remove the default foreign key filter in prep for re-applying a filter containing all children groups.
|
// Remove the default foreign key filter in prep for re-applying a filter containing all children groups.
|
||||||
// Filters are conjunctive in DataQuery by default, so this filter would otherwise overrule any less specific
|
// Filters are conjunctive in DataQuery by default, so this filter would otherwise overrule any less specific
|
||||||
// ones.
|
// ones.
|
||||||
@ -288,9 +292,14 @@ class Group extends DataObject {
|
|||||||
/**
|
/**
|
||||||
* Return a set of this record's "family" of IDs - the IDs of
|
* Return a set of this record's "family" of IDs - the IDs of
|
||||||
* this record and all its descendants.
|
* this record and all its descendants.
|
||||||
|
*
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function collateFamilyIDs() {
|
public function collateFamilyIDs() {
|
||||||
|
if (!$this->exists()) {
|
||||||
|
throw new \InvalidArgumentException("Cannot call collateFamilyIDs on unsaved Group.");
|
||||||
|
}
|
||||||
|
|
||||||
$familyIDs = array();
|
$familyIDs = array();
|
||||||
$chunkToAdd = array($this->ID);
|
$chunkToAdd = array($this->ID);
|
||||||
|
|
||||||
|
@ -69,6 +69,20 @@ class GroupTest extends FunctionalTest {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function testUnsavedGroups() {
|
||||||
|
$member = $this->objFromFixture('GroupTest_Member', 'admin');
|
||||||
|
$group = new Group();
|
||||||
|
|
||||||
|
// Can save user to unsaved group
|
||||||
|
$group->Members()->add($member);
|
||||||
|
$this->assertEquals(array($member->ID), array_values($group->Members()->getIDList()));
|
||||||
|
|
||||||
|
// Persists after writing to DB
|
||||||
|
$group->write();
|
||||||
|
$group = Group::get()->byID($group->ID);
|
||||||
|
$this->assertEquals(array($member->ID), array_values($group->Members()->getIDList()));
|
||||||
|
}
|
||||||
|
|
||||||
public function testCollateAncestorIDs() {
|
public function testCollateAncestorIDs() {
|
||||||
$parentGroup = $this->objFromFixture('Group', 'parentgroup');
|
$parentGroup = $this->objFromFixture('Group', 'parentgroup');
|
||||||
$childGroup = $this->objFromFixture('Group', 'childgroup');
|
$childGroup = $this->objFromFixture('Group', 'childgroup');
|
||||||
|
Loading…
Reference in New Issue
Block a user