public function FilterAPITest::testFilterFormatPreSave in Zircon Profile 8.0
Same name and namespace in other branches
- 8 core/modules/filter/src/Tests/FilterAPITest.php \Drupal\filter\Tests\FilterAPITest::testFilterFormatPreSave()
Tests that FilterFormat::preSave() only saves customized plugins.
File
- core/
modules/ filter/ src/ Tests/ FilterAPITest.php, line 402 - Contains \Drupal\filter\Tests\FilterAPITest.
Class
- FilterAPITest
- Tests the behavior of the API of the Filter module.
Namespace
Drupal\filter\TestsCode
public function testFilterFormatPreSave() {
/** @var \Drupal\filter\FilterFormatInterface $crazy_format */
$crazy_format = entity_create('filter_format', array(
'format' => 'crazy',
'name' => 'Crazy',
'weight' => 1,
'filters' => array(
'filter_html_escape' => array(
'weight' => 10,
'status' => 1,
),
'filter_html' => array(
'weight' => -10,
'status' => 1,
'settings' => array(
'allowed_html' => '<p>',
),
),
),
));
$crazy_format
->save();
// Use config to directly load the configuration and check that only enabled
// or customized plugins are saved to configuration.
$filters = $this
->config('filter.format.crazy')
->get('filters');
$this
->assertEqual(array(
'filter_html_escape',
'filter_html',
), array_keys($filters));
// Disable a plugin to ensure that disabled plugins with custom settings are
// stored in configuration.
$crazy_format
->setFilterConfig('filter_html_escape', array(
'status' => FALSE,
));
$crazy_format
->save();
$filters = $this
->config('filter.format.crazy')
->get('filters');
$this
->assertEqual(array(
'filter_html_escape',
'filter_html',
), array_keys($filters));
// Set the settings as per default to ensure that disable plugins in this
// state are not stored in configuration.
$crazy_format
->setFilterConfig('filter_html_escape', array(
'weight' => -10,
));
$crazy_format
->save();
$filters = $this
->config('filter.format.crazy')
->get('filters');
$this
->assertEqual(array(
'filter_html',
), array_keys($filters));
}