FIX Fixed bug in config merging priorities so that config values set by extensions are now least important instead of most important

This commit is contained in:
Daniel Hensby 2018-03-29 14:46:34 +01:00
parent 87159ea820
commit 4acec33562
No known key found for this signature in database
GPG Key ID: B00D1E9767F0B06E
2 changed files with 67 additions and 51 deletions

View File

@ -39,7 +39,7 @@ class ExtensionMiddleware implements Middleware
} }
foreach ($this->getExtraConfig($class, $config, $excludeMiddleware) as $extra) { foreach ($this->getExtraConfig($class, $config, $excludeMiddleware) as $extra) {
$config = Priority::mergeArray($extra, $config); $config = Priority::mergeArray($config, $extra);
} }
return $config; return $config;
} }

View File

@ -1062,72 +1062,88 @@ class DataObjectTest extends SapphireTest
// Test logical fields (including composite) // Test logical fields (including composite)
$teamSpecifications = $schema->fieldSpecs(DataObjectTest\Team::class); $teamSpecifications = $schema->fieldSpecs(DataObjectTest\Team::class);
$expected = array(
'ID',
'ClassName',
'LastEdited',
'Created',
'Title',
'DatabaseField',
'ExtendedDatabaseField',
'CaptainID',
'FounderID',
'HasOneRelationshipID',
'ExtendedHasOneRelationshipID'
);
$actual = array_keys($teamSpecifications);
sort($expected);
sort($actual);
$this->assertEquals( $this->assertEquals(
array( $expected,
'ID', $actual,
'ClassName',
'LastEdited',
'Created',
'Title',
'DatabaseField',
'ExtendedDatabaseField',
'CaptainID',
'FounderID',
'HasOneRelationshipID',
'ExtendedHasOneRelationshipID'
),
array_keys($teamSpecifications),
'fieldSpecifications() contains all fields defined on instance: base, extended and foreign keys' 'fieldSpecifications() contains all fields defined on instance: base, extended and foreign keys'
); );
$teamFields = $schema->databaseFields(DataObjectTest\Team::class, false); $teamFields = $schema->databaseFields(DataObjectTest\Team::class, false);
$expected = array(
'ID',
'ClassName',
'LastEdited',
'Created',
'Title',
'DatabaseField',
'ExtendedDatabaseField',
'CaptainID',
'FounderID',
'HasOneRelationshipID',
'ExtendedHasOneRelationshipID'
);
$actual = array_keys($teamFields);
sort($expected);
sort($actual);
$this->assertEquals( $this->assertEquals(
array( $expected,
'ID', $actual,
'ClassName',
'LastEdited',
'Created',
'Title',
'DatabaseField',
'ExtendedDatabaseField',
'CaptainID',
'FounderID',
'HasOneRelationshipID',
'ExtendedHasOneRelationshipID'
),
array_keys($teamFields),
'databaseFields() contains only fields defined on instance, including base, extended and foreign keys' 'databaseFields() contains only fields defined on instance, including base, extended and foreign keys'
); );
$subteamSpecifications = $schema->fieldSpecs(DataObjectTest\SubTeam::class); $subteamSpecifications = $schema->fieldSpecs(DataObjectTest\SubTeam::class);
$expected = array(
'ID',
'ClassName',
'LastEdited',
'Created',
'Title',
'DatabaseField',
'ExtendedDatabaseField',
'CaptainID',
'FounderID',
'HasOneRelationshipID',
'ExtendedHasOneRelationshipID',
'SubclassDatabaseField',
'ParentTeamID',
);
$actual = array_keys($subteamSpecifications);
sort($expected);
sort($actual);
$this->assertEquals( $this->assertEquals(
array( $expected,
'ID', $actual,
'ClassName',
'LastEdited',
'Created',
'Title',
'DatabaseField',
'ExtendedDatabaseField',
'CaptainID',
'FounderID',
'HasOneRelationshipID',
'ExtendedHasOneRelationshipID',
'SubclassDatabaseField',
'ParentTeamID',
),
array_keys($subteamSpecifications),
'fieldSpecifications() on subclass contains all fields, including base, extended and foreign keys' 'fieldSpecifications() on subclass contains all fields, including base, extended and foreign keys'
); );
$subteamFields = $schema->databaseFields(DataObjectTest\SubTeam::class, false); $subteamFields = $schema->databaseFields(DataObjectTest\SubTeam::class, false);
$expected = array(
'ID',
'SubclassDatabaseField',
'ParentTeamID',
);
$actual = array_keys($subteamFields);
sort($expected);
sort($actual);
$this->assertEquals( $this->assertEquals(
array( $expected,
'ID', $actual,
'SubclassDatabaseField',
'ParentTeamID',
),
array_keys($subteamFields),
'databaseFields() on subclass contains only fields defined on instance' 'databaseFields() on subclass contains only fields defined on instance'
); );
} }