function ConfigEntityImportTest::doFilterFormatUpdate

Same name and namespace in other branches
  1. 9 core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::doFilterFormatUpdate()
  2. 10 core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::doFilterFormatUpdate()
  3. 11.x core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php \Drupal\Tests\system\Kernel\Entity\ConfigEntityImportTest::doFilterFormatUpdate()

Tests updating a filter format during import.

1 call to ConfigEntityImportTest::doFilterFormatUpdate()
ConfigEntityImportTest::testConfigUpdateImport in core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php
Runs test methods for each module within a single test run.

File

core/modules/system/tests/src/Kernel/Entity/ConfigEntityImportTest.php, line 100

Class

ConfigEntityImportTest
Tests ConfigEntity importing.

Namespace

Drupal\Tests\system\Kernel\Entity

Code

protected function doFilterFormatUpdate() {
    // Create a test filter format with a known label.
    $name = 'filter.format.plain_text';
    
    /** @var $entity \Drupal\filter\Entity\FilterFormat */
    $entity = FilterFormat::load('plain_text');
    $plugin_collection = $entity->getPluginCollections()['filters'];
    $filters = $entity->get('filters');
    $this->assertSame(72, $filters['filter_url']['settings']['filter_url_length']);
    $filters['filter_url']['settings']['filter_url_length'] = 100;
    $entity->set('filters', $filters);
    $entity->save();
    $this->assertSame($filters, $entity->get('filters'));
    $this->assertSame($filters, $plugin_collection->getConfiguration());
    $filters['filter_url']['settings']['filter_url_length'] = -100;
    $entity->getPluginCollections()['filters']
        ->setConfiguration($filters);
    $entity->save();
    $this->assertSame($filters, $entity->get('filters'));
    $this->assertSame($filters, $plugin_collection->getConfiguration());
    // Read the existing data, and prepare an altered version in sync.
    $custom_data = $original_data = $this->container
        ->get('config.storage')
        ->read($name);
    $custom_data['filters']['filter_url']['settings']['filter_url_length'] = 100;
    $this->assertConfigUpdateImport($name, $original_data, $custom_data);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.