Commit 11cd1c5f authored by webchick's avatar webchick

Issue #2562073 by phenaproxima, mikeryan: Filter format migrations need to handle php_code filter

parent e3d0b79f
......@@ -34,8 +34,6 @@ process:
- filter_url
- filter_htmlcorrector
- filter_html_escape
php:
- php_code
settings: settings
status:
plugin: default_value
......
......@@ -8,6 +8,20 @@ process:
format: format
name: name
cache: cache
filters: filters
filters:
plugin: iterator
source: filters
key: @id
process:
id:
plugin: static_map
bypass: true
source: name
map:
php_code: filter_null
settings: settings
status:
plugin: default_value
default_value: true
destination:
plugin: entity:filter_format
......@@ -7,6 +7,7 @@
namespace Drupal\filter\Tests\Migrate\d6;
use Drupal\filter\Entity\FilterFormat;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
......@@ -21,19 +22,12 @@ class MigrateFilterFormatTest extends MigrateDrupal6TestBase {
*/
static $modules = array('filter');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->executeMigration('d6_filter_format');
}
/**
* Tests the Drupal 6 filter format to Drupal 8 migration.
*/
public function testFilterFormat() {
$filter_format = entity_load('filter_format', 'filtered_html');
$this->executeMigration('d6_filter_format');
$filter_format = FilterFormat::load('filtered_html');
// Check filter status.
$filters = $filter_format->get('filters');
......@@ -52,6 +46,10 @@ public function testFilterFormat() {
$this->assertIdentical(TRUE, $filters['filter_html']['settings']['filter_html_help']);
$this->assertIdentical(FALSE, $filters['filter_html']['settings']['filter_html_nofollow']);
$this->assertIdentical(72, $filters['filter_url']['settings']['filter_url_length']);
// Check that the PHP code filter is converted to filter_null.
$filters = FilterFormat::load('php_code')->get('filters');
$this->assertTrue(isset($filters['filter_null']));
}
}
......@@ -71,6 +71,11 @@ public function testFilterFormat() {
$this->assertIdentical('<div> <span> <ul> <li>', $config['settings']['allowed_html']);
$config = $format->filters('filter_url')->getConfiguration();
$this->assertIdentical(128, $config['settings']['filter_url_length']);
// The php_code format gets migrated, but the php_code filter is changed to
// filter_null.
$filters = FilterFormat::load('php_code')->get('filters');
$this->assertTrue(isset($filters['filter_null']));
}
}
......@@ -72,8 +72,13 @@ public function load() {
'name' => 'Escape HTML Filter',
'roles' => '',
'cache' => '1',
))->values(array(
'format' => '4',
'name' => 'PHP Code',
'roles' => ',3,4,5,',
'cache' => '0',
))->execute();
}
}
#bbec2c10ac788fac1807d23774b34b49
#6b9360c3aed58a0826b32b015d659c94
......@@ -130,8 +130,14 @@ public function load() {
'module' => 'filter',
'delta' => '3',
'weight' => '10',
))->values(array(
'fid' => '16',
'format' => '4',
'module' => 'php',
'delta' => '0',
'weight' => '10',
))->execute();
}
}
#e4ed25d991f88bc73a10b840dcc1b004
#7944abbf862871fb50d6742602093713
......@@ -5180,8 +5180,86 @@ public function load() {
'p8' => '0',
'p9' => '0',
'updated' => '0',
))->values(array(
'menu_name' => 'navigation',
'mlid' => '394',
'plid' => '166',
'link_path' => 'admin/build/path',
'router_path' => 'admin/build/path',
'link_title' => 'URL aliases',
'options' => "a:1:{s:10:\"attributes\";a:1:{s:5:\"title\";s:46:\"Change your site's URL paths by aliasing them.\";}}",
'module' => 'system',
'hidden' => '0',
'external' => '0',
'has_children' => '0',
'expanded' => '0',
'weight' => '0',
'depth' => '3',
'customized' => '0',
'p1' => '144',
'p2' => '166',
'p3' => '394',
'p4' => '0',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
))->values(array(
'menu_name' => 'navigation',
'mlid' => '395',
'plid' => '394',
'link_path' => 'admin/build/path/delete',
'router_path' => 'admin/build/path/delete',
'link_title' => 'Delete alias',
'options' => 'a:0:{}',
'module' => 'system',
'hidden' => '-1',
'external' => '0',
'has_children' => '0',
'expanded' => '0',
'weight' => '0',
'depth' => '4',
'customized' => '0',
'p1' => '144',
'p2' => '166',
'p3' => '394',
'p4' => '395',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
))->values(array(
'menu_name' => 'navigation',
'mlid' => '396',
'plid' => '394',
'link_path' => 'admin/build/path/edit',
'router_path' => 'admin/build/path/edit',
'link_title' => 'Edit alias',
'options' => 'a:0:{}',
'module' => 'system',
'hidden' => '-1',
'external' => '0',
'has_children' => '0',
'expanded' => '0',
'weight' => '0',
'depth' => '4',
'customized' => '0',
'p1' => '144',
'p2' => '166',
'p3' => '394',
'p4' => '396',
'p5' => '0',
'p6' => '0',
'p7' => '0',
'p8' => '0',
'p9' => '0',
'updated' => '0',
))->execute();
}
}
#8e902b6a6367838c553b463060befdd3
#ee26910a904b8d0de72248c7b8fec0c9
......@@ -176,6 +176,48 @@ public function load() {
'weight' => '0',
'status' => '1',
'settings' => 'a:1:{s:17:"filter_url_length";i:72;}',
))->values(array(
'format' => 'php_code',
'module' => 'filter',
'name' => 'filter_autop',
'weight' => '0',
'status' => '0',
'settings' => 'a:0:{}',
))->values(array(
'format' => 'php_code',
'module' => 'filter',
'name' => 'filter_html',
'weight' => '-10',
'status' => '0',
'settings' => 'a:3:{s:12:"allowed_html";s:74:"<a> <em> <strong> <cite> <blockquote> <code> <ul> <ol> <li> <dl> <dt> <dd>";s:16:"filter_html_help";i:1;s:20:"filter_html_nofollow";i:0;}',
))->values(array(
'format' => 'php_code',
'module' => 'filter',
'name' => 'filter_htmlcorrector',
'weight' => '10',
'status' => '0',
'settings' => 'a:0:{}',
))->values(array(
'format' => 'php_code',
'module' => 'filter',
'name' => 'filter_html_escape',
'weight' => '-10',
'status' => '0',
'settings' => 'a:0:{}',
))->values(array(
'format' => 'php_code',
'module' => 'filter',
'name' => 'filter_url',
'weight' => '0',
'status' => '0',
'settings' => 'a:1:{s:17:"filter_url_length";i:72;}',
))->values(array(
'format' => 'php_code',
'module' => 'php',
'name' => 'php_code',
'weight' => '0',
'status' => '1',
'settings' => 'a:0:{}',
))->values(array(
'format' => 'plain_text',
'module' => 'filter',
......@@ -215,4 +257,4 @@ public function load() {
}
}
#d47ad1c59579daa0db744321977c5e4b
#7f8ea668d5deed8ce2d6c782dad2bcd5
......@@ -83,6 +83,12 @@ public function load() {
'cache' => '1',
'status' => '1',
'weight' => '1',
))->values(array(
'format' => 'php_code',
'name' => 'PHP code',
'cache' => '0',
'status' => '1',
'weight' => '11',
))->values(array(
'format' => 'plain_text',
'name' => 'Plain text',
......@@ -93,4 +99,4 @@ public function load() {
}
}
#1e6fc650aec40ccdac7d9290778b5708
#1b5a38dba80d3aa28301b147d36c3d9e
......@@ -372,6 +372,10 @@ public function load() {
'rid' => '3',
'permission' => 'use advanced search',
'module' => 'search',
))->values(array(
'rid' => '3',
'permission' => 'use PHP for settings',
'module' => 'php',
))->values(array(
'rid' => '2',
'permission' => 'use text format custom_text_format',
......@@ -416,4 +420,4 @@ public function load() {
}
}
#f2497ea0a9b301afa3b03fea57bcf71a
#452b942b6abf9fb88da1a682e7f333fd
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -240,10 +240,10 @@ public function load() {
'value' => 's:43:"_vWFj-dRR2rNoHDwl7N__J9uZNutDcLz3w4tlPJzRAM";',
))->values(array(
'name' => 'cron_last',
'value' => 'i:1440523817;',
'value' => 'i:1441286523;',
))->values(array(
'name' => 'css_js_query_string',
'value' => 's:6:"nihmmw";',
'value' => 's:6:"nu3rtz";',
))->values(array(
'name' => 'ctools_last_cron',
'value' => 'i:1421720834;',
......@@ -357,7 +357,7 @@ public function load() {
'value' => 'a:0:{}',
))->values(array(
'name' => 'menu_masks',
'value' => 'a:35:{i:0;i:501;i:1;i:493;i:2;i:250;i:3;i:247;i:4;i:246;i:5;i:245;i:6;i:126;i:7;i:125;i:8;i:123;i:9;i:122;i:10;i:121;i:11;i:117;i:12;i:63;i:13;i:62;i:14;i:61;i:15;i:60;i:16;i:59;i:17;i:58;i:18;i:44;i:19;i:31;i:20;i:30;i:21;i:29;i:22;i:24;i:23;i:21;i:24;i:15;i:25;i:14;i:26;i:13;i:27;i:12;i:28;i:11;i:29;i:7;i:30;i:6;i:31;i:5;i:32;i:3;i:33;i:2;i:34;i:1;}',
'value' => 'a:36:{i:0;i:501;i:1;i:493;i:2;i:250;i:3;i:247;i:4;i:246;i:5;i:245;i:6;i:126;i:7;i:125;i:8;i:123;i:9;i:122;i:10;i:121;i:11;i:117;i:12;i:63;i:13;i:62;i:14;i:61;i:15;i:60;i:16;i:59;i:17;i:58;i:18;i:44;i:19;i:31;i:20;i:30;i:21;i:29;i:22;i:24;i:23;i:21;i:24;i:15;i:25;i:14;i:26;i:13;i:27;i:12;i:28;i:11;i:29;i:8;i:30;i:7;i:31;i:6;i:32;i:5;i:33;i:3;i:34;i:2;i:35;i:1;}',
))->values(array(
'name' => 'menu_options_article',
'value' => 'a:1:{i:0;s:9:"main-menu";}',
......@@ -692,4 +692,4 @@ public function load() {
}
}
#7dc2bf954651dff3a1774f619801d40b
#ce49dea65e803f696bbb2b7adb81548b
......@@ -7,6 +7,7 @@
namespace Drupal\user\Tests\Migrate\d6;
use Drupal\migrate\Entity\Migration;
use Drupal\user\Entity\Role;
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
......@@ -29,14 +30,7 @@ class MigrateUserRoleTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
// We need some sample data so we can use the Migration process plugin.
$id_mappings = array(
'd6_filter_format' => array(
array(array(1), array('filtered_html')),
array(array(2), array('full_html'))
),
);
$this->prepareMigrations($id_mappings);
$this->executeMigration('d6_filter_format');
$this->executeMigration('d6_user_role');
}
......@@ -45,22 +39,22 @@ protected function setUp() {
*/
public function testUserRole() {
/** @var \Drupal\migrate\entity\Migration $migration */
$migration = entity_load('migration', 'd6_user_role');
$id_map = Migration::load('d6_user_role')->getIdMap();
$rid = 'anonymous';
$anonymous = Role::load($rid);
$this->assertIdentical($rid, $anonymous->id());
$this->assertIdentical(array('migrate test anonymous permission', 'use text format filtered_html'), $anonymous->getPermissions());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(1)));
$this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(1)));
$rid = 'authenticated';
$authenticated = Role::load($rid);
$this->assertIdentical($rid, $authenticated->id());
$this->assertIdentical(array('migrate test authenticated permission', 'use text format filtered_html'), $authenticated->getPermissions());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(2)));
$this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(2)));
$rid = 'migrate_test_role_1';
$migrate_test_role_1 = Role::load($rid);
$this->assertIdentical($rid, $migrate_test_role_1->id());
$this->assertIdentical(array(0 => 'migrate test role 1 test permission', 'use text format full_html'), $migrate_test_role_1->getPermissions());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(3)));
$this->assertIdentical(array('migrate test role 1 test permission', 'use text format full_html', 'use text format php_code'), $migrate_test_role_1->getPermissions());
$this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(3)));
$rid = 'migrate_test_role_2';
$migrate_test_role_2 = Role::load($rid);
$this->assertIdentical(array(
......@@ -79,13 +73,14 @@ public function testUserRole() {
'edit own forum content',
'administer nodes',
'access content overview',
'use text format php_code',
), $migrate_test_role_2->getPermissions());
$this->assertIdentical($rid, $migrate_test_role_2->id());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(4)));
$this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(4)));
$rid = 'migrate_test_role_3_that_is_long';
$migrate_test_role_3 = Role::load($rid);
$this->assertIdentical($rid, $migrate_test_role_3->id());
$this->assertIdentical(array($rid), $migration->getIdMap()->lookupDestinationId(array(5)));
$this->assertIdentical(array($rid), $id_map->lookupDestinationId(array(5)));
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment