Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
migrate_drupal_d5
Manage
Activity
Members
Labels
Plan
Wiki
Custom issue tracker
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Model registry
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
project
migrate_drupal_d5
Commits
75da9df2
Commit
75da9df2
authored
2 years ago
by
Kurucz István
Browse files
Options
Downloads
Patches
Plain Diff
Test refactor and "Filtered HTML" test.
parent
68bfb574
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Kernel/MigrateFilterFormatTest.php
+50
-6
50 additions, 6 deletions
tests/src/Kernel/MigrateFilterFormatTest.php
with
50 additions
and
6 deletions
tests/src/Kernel/MigrateFilterFormatTest.php
+
50
−
6
View file @
75da9df2
...
...
@@ -12,22 +12,66 @@ use Drupal\filter\FilterFormatInterface;
*/
class
MigrateFilterFormatTest
extends
MigrateDrupal5TestBase
{
/**
* @var \Drupal\filter\FilterPluginManager
*/
protected
$filterPluginManager
;
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
$this
->
filterPluginManager
=
\Drupal
::
service
(
'plugin.manager.filter'
);
$this
->
executeMigration
(
'd5_filter_format'
);
}
/**
* Test "Empty input format" filter format.
* Asserts various aspects of a filter format entity.
*
* @see \Drupal\Tests\filter\Kernel\Migrate\d7\MigrateFilterFormatTest::assertEntity
*
* @param string $id
* The format ID.
* @param string $label
* The expected label of the format.
* @param array $enabled_filters
* The expected filters in the format, keyed by ID with weight as values.
*
* @internal
*/
protected
function
assertEntity
(
string
$id
,
string
$label
,
array
$enabled_filters
):
void
{
/** @var \Drupal\filter\FilterFormatInterface $entity */
$entity
=
FilterFormat
::
load
(
$id
);
$this
->
assertInstanceOf
(
FilterFormatInterface
::
class
,
$entity
);
$this
->
assertSame
(
$label
,
$entity
->
label
());
// get('filters') will return enabled filters only, not all of them.
$this
->
assertSame
(
array_keys
(
$enabled_filters
),
array_keys
(
$entity
->
get
(
'filters'
)));
foreach
(
$entity
->
get
(
'filters'
)
as
$filter_id
=>
$filter
)
{
$this
->
assertSame
(
$filter
[
'weight'
],
$enabled_filters
[
$filter_id
]);
}
}
/**
* Test 'Empty input format' filter format.
*/
public
function
testEmptyFilterFormat
()
{
$filter_format
=
FilterFormat
::
load
(
'empty_input_format'
);
$this
->
assertInstanceOf
(
FilterFormatInterface
::
class
,
$filter_format
);
// Check filter status.
$filters
=
$filter_format
->
get
(
'filters'
);
$this
->
assertEmpty
(
$filters
);
$this
->
assertEntity
(
'empty_input_format'
,
'Empty input format'
,
[]);
}
/**
* Test 'Filtered HTML' filter format.
*/
public
function
testFilteredHtmlFilterFormat
()
{
$this
->
assertEntity
(
'filtered_html'
,
'Filtered HTML'
,
[
'filter_url'
=>
0
,
'filter_html'
=>
1
,
'filter_autop'
=>
2
]);
// filter_html
$filter_plugin
=
$this
->
filterPluginManager
->
createInstance
(
'filter_html'
);
$filter_config
=
FilterFormat
::
load
(
'filtered_html'
)
->
filters
(
'filter_html'
)
->
getConfiguration
();
$this
->
assertSame
(
$filter_plugin
->
getPluginDefinition
()[
'settings'
][
'allowed_html'
],
$filter_config
[
'settings'
][
'allowed_html'
]);
$this
->
assertEquals
(
TRUE
,
$filter_config
[
'settings'
][
'filter_html_help'
]);
// filter_url
$filter_plugin
=
$this
->
filterPluginManager
->
createInstance
(
'filter_url'
);
$filter_config
=
FilterFormat
::
load
(
'filtered_html'
)
->
filters
(
'filter_url'
)
->
getConfiguration
();
$this
->
assertSame
(
$filter_plugin
->
getPluginDefinition
()[
'settings'
][
'filter_url_length'
],
$filter_config
[
'settings'
][
'filter_url_length'
]);
}
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment