public function ChartsDefaultSettingsTest::testDefaults in Charts 8.4
Same name and namespace in other branches
- 8.3 tests/src/Unit/Settings/ChartsDefaultSettingsTest.php \Drupal\Tests\charts\Unit\Settings\ChartsDefaultSettingsTest::testDefaults()
- 5.0.x tests/src/Unit/Settings/ChartsDefaultSettingsTest.php \Drupal\Tests\charts\Unit\Settings\ChartsDefaultSettingsTest::testDefaults()
Tests getter and setter for defaults.
@dataProvider defaultSettingsProvider
Parameters
array $defaults: Array of default settings.
File
- tests/
src/ Unit/ Settings/ ChartsDefaultSettingsTest.php, line 68
Class
- ChartsDefaultSettingsTest
- @coversDefaultClass \Drupal\charts\Settings\ChartsDefaultSettings @group charts
Namespace
Drupal\Tests\charts\Unit\SettingsCode
public function testDefaults(array $defaults) {
// Legacy config.
$this->chartsDefaultSettings
->setDefaults($defaults);
$this
->assertArrayEquals($defaults, $this->chartsDefaultSettings
->getDefaults());
// New format config. This also allow us to test the transform to new;
// Format.
$keys_mapping = ChartsDefaultSettings::getLegacySettingsMappingKeys();
$keys_mapping['colors'] = 'display_colors';
$new_format = ChartsDefaultSettings::transformLegacySettingsToNew($defaults, $keys_mapping);
$this
->assertArrayEquals($new_format, $this->chartsDefaultSettings
->getDefaults(TRUE));
}