Issue #3095339 by Wim Leers, longwave, heddn, quietone: Text formats disabled in D7 are migrated to D8 as enabled

(cherry picked from commit 798af1ff30)
merge-requests/55/head
webchick 2019-11-26 13:25:34 -08:00
parent d29f4f107a
commit 0a68ef68ad
3 changed files with 13 additions and 11 deletions

View File

@ -7,6 +7,7 @@ source:
plugin: d7_filter_format plugin: d7_filter_format
process: process:
format: format format: format
status: status
name: name name: name
cache: cache cache: cache
weight: weight weight: weight

View File

@ -38,8 +38,10 @@ class MigrateFilterFormatTest extends MigrateDrupal7TestBase {
* The expected filters in the format, keyed by ID with weight as values. * The expected filters in the format, keyed by ID with weight as values.
* @param int $weight * @param int $weight
* The weight of the filter. * The weight of the filter.
* @param bool $status
* The status of the filter.
*/ */
protected function assertEntity($id, $label, array $enabled_filters, $weight) { protected function assertEntity($id, $label, array $enabled_filters, $weight, $status) {
/** @var \Drupal\filter\FilterFormatInterface $entity */ /** @var \Drupal\filter\FilterFormatInterface $entity */
$entity = FilterFormat::load($id); $entity = FilterFormat::load($id);
$this->assertInstanceOf(FilterFormatInterface::class, $entity); $this->assertInstanceOf(FilterFormatInterface::class, $entity);
@ -47,6 +49,7 @@ class MigrateFilterFormatTest extends MigrateDrupal7TestBase {
// get('filters') will return enabled filters only, not all of them. // get('filters') will return enabled filters only, not all of them.
$this->assertSame(array_keys($enabled_filters), array_keys($entity->get('filters'))); $this->assertSame(array_keys($enabled_filters), array_keys($entity->get('filters')));
$this->assertSame($weight, $entity->get('weight')); $this->assertSame($weight, $entity->get('weight'));
$this->assertSame($status, $entity->status());
foreach ($entity->get('filters') as $filter_id => $filter) { foreach ($entity->get('filters') as $filter_id => $filter) {
$this->assertSame($filter['weight'], $enabled_filters[$filter_id]); $this->assertSame($filter['weight'], $enabled_filters[$filter_id]);
} }
@ -56,10 +59,10 @@ class MigrateFilterFormatTest extends MigrateDrupal7TestBase {
* Tests the Drupal 7 filter format to Drupal 8 migration. * Tests the Drupal 7 filter format to Drupal 8 migration.
*/ */
public function testFilterFormat() { public function testFilterFormat() {
$this->assertEntity('custom_text_format', 'Custom Text format', ['filter_autop' => 0, 'filter_html' => -10], 0); $this->assertEntity('custom_text_format', 'Custom Text format', ['filter_autop' => 0, 'filter_html' => -10], 0, TRUE);
$this->assertEntity('filtered_html', 'Filtered HTML', ['filter_autop' => 2, 'filter_html' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 0); $this->assertEntity('filtered_html', 'Filtered HTML', ['filter_autop' => 2, 'filter_html' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 0, TRUE);
$this->assertEntity('full_html', 'Full HTML', ['filter_autop' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 1); $this->assertEntity('full_html', 'Full HTML', ['filter_autop' => 1, 'filter_htmlcorrector' => 10, 'filter_url' => 0], 1, TRUE);
$this->assertEntity('plain_text', 'Plain text', ['filter_html_escape' => 0, 'filter_url' => 1, 'filter_autop' => 2], 10); $this->assertEntity('plain_text', 'Plain text', ['filter_html_escape' => 0, 'filter_url' => 1, 'filter_autop' => 2], 10, TRUE);
// This assertion covers issue #2555089. Drupal 7 formats are identified // This assertion covers issue #2555089. Drupal 7 formats are identified
// by machine names, so migrated formats should be merged into existing // by machine names, so migrated formats should be merged into existing
// ones. // ones.
@ -74,11 +77,9 @@ class MigrateFilterFormatTest extends MigrateDrupal7TestBase {
$config = $format->filters('filter_url')->getConfiguration(); $config = $format->filters('filter_url')->getConfiguration();
$this->assertSame(128, $config['settings']['filter_url_length']); $this->assertSame(128, $config['settings']['filter_url_length']);
// The php_code format gets migrated, but the php_code filter is changed to // The disabled php_code format gets migrated, but the php_code filter is
// filter_null. // changed to filter_null.
$format = FilterFormat::load('php_code'); $this->assertEntity('php_code', 'PHP code', ['filter_null' => 0], 11, FALSE);
$this->assertInstanceOf(FilterFormatInterface::class, $format);
$this->assertArrayHasKey('filter_null', $format->get('filters'));
} }
} }

View File

@ -15812,7 +15812,7 @@ $connection->insert('filter_format')
'format' => 'php_code', 'format' => 'php_code',
'name' => 'PHP code', 'name' => 'PHP code',
'cache' => '0', 'cache' => '0',
'status' => '1', 'status' => '0',
'weight' => '11', 'weight' => '11',
)) ))
->values(array( ->values(array(