Replace core uses of DataObject::has_one/has_many/many_many

This commit is contained in:
Loz Calver 2015-02-25 15:21:33 +00:00
parent 7e2a00aa3d
commit c58f4c469d
15 changed files with 82 additions and 73 deletions

View File

@ -62,7 +62,7 @@ class JSONDataFormatter extends DataFormatter {
}
if($this->relationDepth > 0) {
foreach($obj->has_one() as $relName => $relClass) {
foreach($obj->hasOne() as $relName => $relClass) {
if(!singleton($relClass)->stat('api_access')) continue;
// Field filtering
@ -82,7 +82,7 @@ class JSONDataFormatter extends DataFormatter {
));
}
foreach($obj->has_many() as $relName => $relClass) {
foreach($obj->hasMany() as $relName => $relClass) {
if(!singleton($relClass)->stat('api_access')) continue;
// Field filtering
@ -103,7 +103,7 @@ class JSONDataFormatter extends DataFormatter {
$serobj->$relName = $innerParts;
}
foreach($obj->many_many() as $relName => $relClass) {
foreach($obj->manyMany() as $relName => $relClass) {
if(!singleton($relClass)->stat('api_access')) continue;
// Field filtering

View File

@ -68,7 +68,7 @@ class XMLDataFormatter extends DataFormatter {
}
if($this->relationDepth > 0) {
foreach($obj->has_one() as $relName => $relClass) {
foreach($obj->hasOne() as $relName => $relClass) {
if(!singleton($relClass)->stat('api_access')) continue;
// Field filtering
@ -85,7 +85,7 @@ class XMLDataFormatter extends DataFormatter {
. "\"></$relName>\n";
}
foreach($obj->has_many() as $relName => $relClass) {
foreach($obj->hasMany() as $relName => $relClass) {
if(!singleton($relClass)->stat('api_access')) continue;
// Field filtering
@ -103,7 +103,7 @@ class XMLDataFormatter extends DataFormatter {
$xml .= "</$relName>\n";
}
foreach($obj->many_many() as $relName => $relClass) {
foreach($obj->manyMany() as $relName => $relClass) {
if(!singleton($relClass)->stat('api_access')) continue;
// Field filtering

View File

@ -220,9 +220,9 @@ abstract class BulkLoader extends ViewableData {
// using $$includerelations flag as false, so that it only contain $db fields
$spec['fields'] = (array)singleton($this->objectClass)->fieldLabels(false);
$has_ones = singleton($this->objectClass)->has_one();
$has_manys = singleton($this->objectClass)->has_many();
$many_manys = singleton($this->objectClass)->many_many();
$has_ones = singleton($this->objectClass)->hasOne();
$has_manys = singleton($this->objectClass)->hasMany();
$many_manys = singleton($this->objectClass)->manyMany();
$spec['relations'] = (array)$has_ones + (array)$has_manys + (array)$many_manys;

View File

@ -120,7 +120,7 @@ class CsvBulkLoader extends BulkLoader {
$relationObj = $obj->{$this->relationCallbacks[$fieldName]['callback']}($val, $record);
}
if(!$relationObj || !$relationObj->exists()) {
$relationClass = $obj->has_one($relationName);
$relationClass = $obj->hasOneComponent($relationName);
$relationObj = new $relationClass();
//write if we aren't previewing
if (!$preview) $relationObj->write();

View File

@ -110,7 +110,11 @@ class FixtureBlueprint {
// Populate overrides
if($data) foreach($data as $fieldName => $fieldVal) {
// Defer relationship processing
if($obj->many_many($fieldName) || $obj->has_many($fieldName) || $obj->has_one($fieldName)) {
if(
$obj->manyManyComponent($fieldName)
|| $obj->hasManyComponent($fieldName)
|| $obj->hasOneComponent($fieldName)
) {
continue;
}
@ -127,7 +131,7 @@ class FixtureBlueprint {
// Populate all relations
if($data) foreach($data as $fieldName => $fieldVal) {
if($obj->many_many($fieldName) || $obj->has_many($fieldName)) {
if($obj->manyManyComponent($fieldName) || $obj->hasManyComponent($fieldName)) {
$obj->write();
$parsedItems = array();
@ -165,15 +169,15 @@ class FixtureBlueprint {
$parsedItems[] = $this->parseValue($item, $fixtures);
}
if($obj->has_many($fieldName)) {
if($obj->hasManyComponent($fieldName)) {
$obj->getComponents($fieldName)->setByIDList($parsedItems);
} elseif($obj->many_many($fieldName)) {
} elseif($obj->manyManyComponent($fieldName)) {
$obj->getManyManyComponents($fieldName)->setByIDList($parsedItems);
}
}
} else {
$hasOneField = preg_replace('/ID$/', '', $fieldName);
if($className = $obj->has_one($hasOneField)) {
if($className = $obj->hasOneComponent($hasOneField)) {
$obj->{$hasOneField.'ID'} = $this->parseValue($fieldVal, $fixtures, $fieldClass);
// Inject class for polymorphic relation
if($className === 'DataObject') {

View File

@ -109,7 +109,7 @@ class FileField extends FormField {
if($this->relationAutoSetting) {
// assume that the file is connected via a has-one
$hasOnes = $record->has_one($this->name);
$hasOnes = $record->hasOne($this->name);
// try to create a file matching the relation
$file = (is_string($hasOnes)) ? Object::create($hasOnes) : new $fileClass();
} else if($record instanceof File) {

View File

@ -93,8 +93,8 @@ class FormScaffolder extends Object {
}
// add has_one relation fields
if($this->obj->has_one()) {
foreach($this->obj->has_one() as $relationship => $component) {
if($this->obj->hasOne()) {
foreach($this->obj->hasOne() as $relationship => $component) {
if($this->restrictFields && !in_array($relationship, $this->restrictFields)) continue;
$fieldName = $component === 'DataObject'
? $relationship // Polymorphic has_one field is composite, so don't refer to ID subfield
@ -118,10 +118,10 @@ class FormScaffolder extends Object {
// only add relational fields if an ID is present
if($this->obj->ID) {
// add has_many relation fields
if($this->obj->has_many()
if($this->obj->hasMany()
&& ($this->includeRelations === true || isset($this->includeRelations['has_many']))) {
foreach($this->obj->has_many() as $relationship => $component) {
foreach($this->obj->hasMany() as $relationship => $component) {
if($this->tabbed) {
$relationTab = $fields->findOrMakeTab(
"Root.$relationship",
@ -145,10 +145,10 @@ class FormScaffolder extends Object {
}
}
if($this->obj->many_many()
if($this->obj->manyMany()
&& ($this->includeRelations === true || isset($this->includeRelations['many_many']))) {
foreach($this->obj->many_many() as $relationship => $component) {
foreach($this->obj->manyMany() as $relationship => $component) {
if($this->tabbed) {
$relationTab = $fields->findOrMakeTab(
"Root.$relationship",

View File

@ -502,7 +502,7 @@ class UploadField extends FileField {
if($relation && ($relation instanceof RelationList || $relation instanceof UnsavedRelationList)) {
// has_many or many_many
$relation->setByIDList($idList);
} elseif($record->has_one($fieldname)) {
} elseif($record->hasOneComponent($fieldname)) {
// has_one
$record->{"{$fieldname}ID"} = $idList ? reset($idList) : 0;
}
@ -590,7 +590,7 @@ class UploadField extends FileField {
if(empty($allowedMaxFileNumber)) {
$record = $this->getRecord();
$name = $this->getName();
if($record && $record->has_one($name)) {
if($record && $record->hasOneComponent($name)) {
return 1; // Default for has_one
} else {
return null; // Default for has_many and many_many

View File

@ -78,7 +78,7 @@ class DataDifferencer extends ViewableData {
$fields = array_keys($this->toRecord->toMap());
}
$hasOnes = array_merge($this->fromRecord->has_one(), $this->toRecord->has_one());
$hasOnes = array_merge($this->fromRecord->hasOne(), $this->toRecord->hasOne());
// Loop through properties
foreach($fields as $field) {

View File

@ -547,10 +547,10 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// DO NOT copy has_many relations, because copying the relation would result in us changing the has_one
// relation on the other side of this relation to point at the copy and no longer the original (being a
// has_one, it can only point at one thing at a time). So, all relations except has_many can and are copied
if ($sourceObject->has_one()) foreach($sourceObject->has_one() as $name => $type) {
if ($sourceObject->hasOne()) foreach($sourceObject->hasOne() as $name => $type) {
$this->duplicateRelations($sourceObject, $destinationObject, $name);
}
if ($sourceObject->many_many()) foreach($sourceObject->many_many() as $name => $type) {
if ($sourceObject->manyMany()) foreach($sourceObject->manyMany() as $name => $type) {
//many_many include belongs_many_many
$this->duplicateRelations($sourceObject, $destinationObject, $name);
}
@ -666,24 +666,24 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
if($this->class == 'DataObject') return;
// Set up accessors for joined items
if($manyMany = $this->many_many()) {
if($manyMany = $this->manyMany()) {
foreach($manyMany as $relationship => $class) {
$this->addWrapperMethod($relationship, 'getManyManyComponents');
}
}
if($hasMany = $this->has_many()) {
if($hasMany = $this->hasMany()) {
foreach($hasMany as $relationship => $class) {
$this->addWrapperMethod($relationship, 'getComponents');
}
}
if($hasOne = $this->has_one()) {
if($hasOne = $this->hasOne()) {
foreach($hasOne as $relationship => $class) {
$this->addWrapperMethod($relationship, 'getComponent');
}
}
if($belongsTo = $this->belongs_to()) foreach(array_keys($belongsTo) as $relationship) {
if($belongsTo = $this->belongsTo()) foreach(array_keys($belongsTo) as $relationship) {
$this->addWrapperMethod($relationship, 'getComponent');
}
}
@ -972,7 +972,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
// merge relations
if($includeRelations) {
if($manyMany = $this->many_many()) {
if($manyMany = $this->manyMany()) {
foreach($manyMany as $relationship => $class) {
$leftComponents = $leftObj->getManyManyComponents($relationship);
$rightComponents = $rightObj->getManyManyComponents($relationship);
@ -983,7 +983,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
}
}
if($hasMany = $this->has_many()) {
if($hasMany = $this->hasMany()) {
foreach($hasMany as $relationship => $class) {
$leftComponents = $leftObj->getComponents($relationship);
$rightComponents = $rightObj->getComponents($relationship);
@ -995,7 +995,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
}
if($hasOne = $this->has_one()) {
if($hasOne = $this->hasOne()) {
foreach($hasOne as $relationship => $class) {
$leftComponent = $leftObj->getComponent($relationship);
$rightComponent = $rightObj->getComponent($relationship);
@ -1130,7 +1130,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$this->$fieldName = $fieldValue;
}
// Set many-many defaults with an array of ids
if(is_array($fieldValue) && $this->many_many($fieldName)) {
if(is_array($fieldValue) && $this->manyManyComponent($fieldName)) {
$manyManyJoin = $this->$fieldName();
$manyManyJoin->setByIdList($fieldValue);
}
@ -1497,7 +1497,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
return $this->components[$componentName];
}
if($class = $this->has_one($componentName)) {
if($class = $this->hasOneComponent($componentName)) {
$joinField = $componentName . 'ID';
$joinID = $this->getField($joinField);
@ -1514,7 +1514,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
if(empty($component)) {
$component = $this->model->$class->newObject();
}
} elseif($class = $this->belongs_to($componentName)) {
} elseif($class = $this->belongsToComponent($componentName)) {
$joinField = $this->getRemoteJoinField($componentName, 'belongs_to', $polymorphic);
$joinID = $this->ID;
@ -1564,7 +1564,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
public function getComponents($componentName, $filter = null, $sort = null, $join = null, $limit = null) {
$result = null;
if(!$componentClass = $this->has_many($componentName)) {
if(!$componentClass = $this->hasManyComponent($componentName)) {
user_error("DataObject::getComponents(): Unknown 1-to-many component '$componentName'"
. " on class '$this->class'", E_USER_ERROR);
}
@ -1652,7 +1652,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
*/
public function getRemoteJoinField($component, $type = 'has_many', &$polymorphic = false) {
// Extract relation from current object
$remoteClass = $this->$type($component, false);
if($type === 'has_many') {
$remoteClass = $this->hasManyComponent($component, false);
} else {
$remoteClass = $this->belongsToComponent($component, false);
}
if(empty($remoteClass)) {
throw new Exception("Unknown $type component '$component' on class '$this->class'");
}
@ -1742,7 +1747,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
$result = ManyManyList::create(
$componentClass, $table, $componentField, $parentField,
$this->many_many_extraFields($componentName)
$this->manyManyExtraFieldsForComponent($componentName)
);
if($this->model) $result->setDataModel($this->model);
@ -1879,7 +1884,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
/**
* Return all of the database fields defined in self::$db and all the parent classes.
* Doesn't include any fields specified by self::$has_one. Use $this->has_one() to get these fields
* Doesn't include any fields specified by self::$has_one. Use $this->hasOne() to get these fields
*
* @param string $fieldName Limit the output to a specific field name
* @return array The database fields
@ -2693,7 +2698,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
return (
array_key_exists($field, $this->record)
|| $this->db($field)
|| (substr($field,-2) == 'ID') && $this->has_one(substr($field,0, -2))
|| (substr($field,-2) == 'ID') && $this->hasOneComponent(substr($field,0, -2))
|| $this->hasMethod("get{$field}")
);
}
@ -2782,7 +2787,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
}
if(Permission::checkMember($member, "ADMIN")) return true;
if($this->many_many('Can' . $perm)) {
if($this->manyManyComponent('Can' . $perm)) {
if($this->ParentID && $this->SecurityType == 'Inherit') {
if(!($p = $this->Parent)) {
return false;
@ -2966,12 +2971,12 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
return $obj;
// Special case for has_one relationships
} else if(preg_match('/ID$/', $fieldName) && $this->has_one(substr($fieldName,0,-2))) {
} else if(preg_match('/ID$/', $fieldName) && $this->hasOneComponent(substr($fieldName,0,-2))) {
$val = $this->$fieldName;
return DBField::create_field('ForeignKey', $val, $fieldName, $this);
// has_one for polymorphic relations do not end in ID
} else if(($type = $this->has_one($fieldName)) && ($type === 'DataObject')) {
} else if(($type = $this->hasOneComponent($fieldName)) && ($type === 'DataObject')) {
$val = $this->$fieldName();
return DBField::create_field('PolymorphicForeignKey', $val, $fieldName, $this);
@ -3069,16 +3074,16 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
* @return String
*/
public function getReverseAssociation($className) {
if (is_array($this->many_many())) {
$many_many = array_flip($this->many_many());
if (is_array($this->manyMany())) {
$many_many = array_flip($this->manyMany());
if (array_key_exists($className, $many_many)) return $many_many[$className];
}
if (is_array($this->has_many())) {
$has_many = array_flip($this->has_many());
if (is_array($this->hasMany())) {
$has_many = array_flip($this->hasMany());
if (array_key_exists($className, $has_many)) return $has_many[$className];
}
if (is_array($this->has_one())) {
$has_one = array_flip($this->has_one());
if (is_array($this->hasOne())) {
$has_one = array_flip($this->hasOne());
if (array_key_exists($className, $has_one)) return $has_one[$className];
}
@ -3947,7 +3952,7 @@ class DataObject extends ViewableData implements DataObjectInterface, i18nEntity
*/
public function hasValue($field, $arguments = null, $cache = true) {
// has_one fields should not use dbObject to check if a value is given
if(!$this->has_one($field) && ($obj = $this->dbObject($field))) {
if(!$this->hasOneComponent($field) && ($obj = $this->dbObject($field))) {
return $obj->exists();
} else {
return parent::hasValue($field, $arguments, $cache);

View File

@ -645,7 +645,7 @@ class DataQuery {
foreach($relation as $rel) {
$model = singleton($modelClass);
if ($component = $model->has_one($rel)) {
if ($component = $model->hasOneComponent($rel)) {
if(!$this->query->isJoinedTo($component)) {
$foreignKey = $rel;
$realModelClass = ClassInfo::table_for_object_field($modelClass, "{$foreignKey}ID");
@ -668,7 +668,7 @@ class DataQuery {
}
$modelClass = $component;
} elseif ($component = $model->has_many($rel)) {
} elseif ($component = $model->hasManyComponent($rel)) {
if(!$this->query->isJoinedTo($component)) {
$ancestry = $model->getClassAncestry();
$foreignKey = $model->getRemoteJoinField($rel);
@ -690,7 +690,7 @@ class DataQuery {
}
$modelClass = $component;
} elseif ($component = $model->many_many($rel)) {
} elseif ($component = $model->manyManyComponent($rel)) {
list($parentClass, $componentClass, $parentField, $componentField, $relationTable) = $component;
$parentBaseClass = ClassInfo::baseDataClass($parentClass);
$componentBaseClass = ClassInfo::baseDataClass($componentClass);

View File

@ -28,7 +28,7 @@ class ForeignKey extends Int {
public function scaffoldFormField($title = null, $params = null) {
$relationName = substr($this->name,0,-2);
$hasOneClass = $this->object->has_one($relationName);
$hasOneClass = $this->object->hasOneComponent($relationName);
if($hasOneClass && singleton($hasOneClass) instanceof Image) {
$field = new UploadField($relationName, $title);

View File

@ -269,7 +269,7 @@ class PermissionCheckboxSetField extends FormField {
$permission->delete();
}
if($fieldname && $record && ($record->has_many($fieldname) || $record->many_many($fieldname))) {
if($fieldname && $record && ($record->hasManyComponent($fieldname) || $record->manyManyComponent($fieldname))) {
if(!$record->ID) $record->write(); // We need a record ID to write permissions

View File

@ -1086,7 +1086,7 @@ class DataObjectTest extends SapphireTest {
$equipmentSuppliers = $team->EquipmentSuppliers();
// Check that DataObject::many_many() works as expected
list($class, $targetClass, $parentField, $childField, $joinTable) = $team->many_many('Sponsors');
list($class, $targetClass, $parentField, $childField, $joinTable) = $team->manyManyComponent('Sponsors');
$this->assertEquals('DataObjectTest_Team', $class,
'DataObject::many_many() didn\'t find the correct base class');
$this->assertEquals('DataObjectTest_EquipmentCompany', $targetClass,
@ -1138,27 +1138,27 @@ class DataObjectTest extends SapphireTest {
$team = $this->objFromFixture('DataObjectTest_Team', 'team1');
// Get all extra fields
$teamExtraFields = $team->many_many_extraFields();
$teamExtraFields = $team->manyManyExtraFields();
$this->assertEquals(array(
'Players' => array('Position' => 'Varchar(100)')
), $teamExtraFields);
// Ensure fields from parent classes are included
$subTeam = singleton('DataObjectTest_SubTeam');
$teamExtraFields = $subTeam->many_many_extraFields();
$teamExtraFields = $subTeam->manyManyExtraFields();
$this->assertEquals(array(
'Players' => array('Position' => 'Varchar(100)'),
'FormerPlayers' => array('Position' => 'Varchar(100)')
), $teamExtraFields);
// Extra fields are immediately available on the Team class (defined in $many_many_extraFields)
$teamExtraFields = $team->many_many_extraFields('Players');
$teamExtraFields = $team->manyManyExtraFieldsForComponent('Players');
$this->assertEquals($teamExtraFields, array(
'Position' => 'Varchar(100)'
));
// We'll have to go through the relation to get the extra fields on Player
$playerExtraFields = $player->many_many_extraFields('Teams');
$playerExtraFields = $player->manyManyExtraFieldsForComponent('Teams');
$this->assertEquals($playerExtraFields, array(
'Position' => 'Varchar(100)'
));
@ -1188,7 +1188,7 @@ class DataObjectTest extends SapphireTest {
// Check that ordering a many-many relation by an aggregate column doesn't fail
$player = $this->objFromFixture('DataObjectTest_Player', 'player2');
$player->Teams("", "count(DISTINCT \"DataObjectTest_Team_Players\".\"DataObjectTest_PlayerID\") DESC");
$player->Teams()->sort("count(DISTINCT \"DataObjectTest_Team_Players\".\"DataObjectTest_PlayerID\") DESC");
}
/**
@ -1341,13 +1341,13 @@ class DataObjectTest extends SapphireTest {
'CurrentStaff' => 'DataObjectTest_Staff',
'PreviousStaff' => 'DataObjectTest_Staff'
),
$company->has_many(),
$company->hasMany(),
'has_many strips field name data by default.'
);
$this->assertEquals (
'DataObjectTest_Staff',
$company->has_many('CurrentStaff'),
$company->hasManyComponent('CurrentStaff'),
'has_many strips field name data by default on single relationships.'
);
@ -1356,13 +1356,13 @@ class DataObjectTest extends SapphireTest {
'CurrentStaff' => 'DataObjectTest_Staff.CurrentCompany',
'PreviousStaff' => 'DataObjectTest_Staff.PreviousCompany'
),
$company->has_many(null, false),
$company->hasMany(null, false),
'has_many returns field name data when $classOnly is false.'
);
$this->assertEquals (
'DataObjectTest_Staff.CurrentCompany',
$company->has_many('CurrentStaff', false),
$company->hasManyComponent('CurrentStaff', false),
'has_many returns field name data on single records when $classOnly is false.'
);
}

View File

@ -46,7 +46,7 @@ class PermissionCheckboxSetFieldTest extends SapphireTest {
$this->assertEquals($group->Permissions()->Count(), 0, 'The tested group has no permissions');
$this->assertEquals($untouchable->Permissions()->Count(), 1, 'The other group has one permission');
$this->assertEquals($untouchable->Permissions("\"Code\"='ADMIN'")->Count(), 1,
$this->assertEquals($untouchable->Permissions()->where("\"Code\"='ADMIN'")->Count(), 1,
'The other group has ADMIN permission');
$this->assertEquals(DataObject::get('Permission')->Count(), $baseCount, 'There are no orphaned permissions');
@ -62,14 +62,14 @@ class PermissionCheckboxSetFieldTest extends SapphireTest {
$untouchable->flushCache();
$this->assertEquals($group->Permissions()->Count(), 2,
'The tested group has two permissions permission');
$this->assertEquals($group->Permissions("\"Code\"='ADMIN'")->Count(), 1,
$this->assertEquals($group->Permissions()->where("\"Code\"='ADMIN'")->Count(), 1,
'The tested group has ADMIN permission');
$this->assertEquals($group->Permissions("\"Code\"='NON-ADMIN'")->Count(), 1,
$this->assertEquals($group->Permissions()->where("\"Code\"='NON-ADMIN'")->Count(), 1,
'The tested group has CMS_ACCESS_AssetAdmin permission');
$this->assertEquals($untouchable->Permissions()->Count(), 1,
'The other group has one permission');
$this->assertEquals($untouchable->Permissions("\"Code\"='ADMIN'")->Count(), 1,
$this->assertEquals($untouchable->Permissions()->where("\"Code\"='ADMIN'")->Count(), 1,
'The other group has ADMIN permission');
$this->assertEquals(DataObject::get('Permission')->Count(), $baseCount+2,
@ -85,12 +85,12 @@ class PermissionCheckboxSetFieldTest extends SapphireTest {
$untouchable->flushCache();
$this->assertEquals($group->Permissions()->Count(), 1,
'The tested group has 1 permission');
$this->assertEquals($group->Permissions("\"Code\"='ADMIN'")->Count(), 1,
$this->assertEquals($group->Permissions()->where("\"Code\"='ADMIN'")->Count(), 1,
'The tested group has ADMIN permission');
$this->assertEquals($untouchable->Permissions()->Count(), 1,
'The other group has one permission');
$this->assertEquals($untouchable->Permissions("\"Code\"='ADMIN'")->Count(), 1,
$this->assertEquals($untouchable->Permissions()->where("\"Code\"='ADMIN'")->Count(), 1,
'The other group has ADMIN permission');
$this->assertEquals(DataObject::get('Permission')->Count(), $baseCount+1,