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,8 +1062,7 @@ 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);
$this->assertEquals( $expected = array(
array(
'ID', 'ID',
'ClassName', 'ClassName',
'LastEdited', 'LastEdited',
@ -1075,14 +1074,18 @@ class DataObjectTest extends SapphireTest
'FounderID', 'FounderID',
'HasOneRelationshipID', 'HasOneRelationshipID',
'ExtendedHasOneRelationshipID' 'ExtendedHasOneRelationshipID'
), );
array_keys($teamSpecifications), $actual = array_keys($teamSpecifications);
sort($expected);
sort($actual);
$this->assertEquals(
$expected,
$actual,
'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);
$this->assertEquals( $expected = array(
array(
'ID', 'ID',
'ClassName', 'ClassName',
'LastEdited', 'LastEdited',
@ -1094,14 +1097,18 @@ class DataObjectTest extends SapphireTest
'FounderID', 'FounderID',
'HasOneRelationshipID', 'HasOneRelationshipID',
'ExtendedHasOneRelationshipID' 'ExtendedHasOneRelationshipID'
), );
array_keys($teamFields), $actual = array_keys($teamFields);
sort($expected);
sort($actual);
$this->assertEquals(
$expected,
$actual,
'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);
$this->assertEquals( $expected = array(
array(
'ID', 'ID',
'ClassName', 'ClassName',
'LastEdited', 'LastEdited',
@ -1115,19 +1122,28 @@ class DataObjectTest extends SapphireTest
'ExtendedHasOneRelationshipID', 'ExtendedHasOneRelationshipID',
'SubclassDatabaseField', 'SubclassDatabaseField',
'ParentTeamID', 'ParentTeamID',
), );
array_keys($subteamSpecifications), $actual = array_keys($subteamSpecifications);
sort($expected);
sort($actual);
$this->assertEquals(
$expected,
$actual,
'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);
$this->assertEquals( $expected = array(
array(
'ID', 'ID',
'SubclassDatabaseField', 'SubclassDatabaseField',
'ParentTeamID', 'ParentTeamID',
), );
array_keys($subteamFields), $actual = array_keys($subteamFields);
sort($expected);
sort($actual);
$this->assertEquals(
$expected,
$actual,
'databaseFields() on subclass contains only fields defined on instance' 'databaseFields() on subclass contains only fields defined on instance'
); );
} }