Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
migrate_plus
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_plus
Commits
aa94a699
Commit
aa94a699
authored
2 years ago
by
Ivan Doroshenko
Committed by
Ivan Doroshenko
2 years ago
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3112571
by marvil07, Matroskeen: Support xml parsing on dom plugin
parent
ce552ed8
No related branches found
Branches containing commit
Tags
6.0.0
Tags containing commit
1 merge request
!8
Issue #3229479: Entity_lookup taxonomy_term restricted by VID
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/Plugin/migrate/process/Dom.php
+7
-2
7 additions, 2 deletions
src/Plugin/migrate/process/Dom.php
tests/src/Unit/process/DomTest.php
+14
-2
14 additions, 2 deletions
tests/src/Unit/process/DomTest.php
with
21 additions
and
4 deletions
src/Plugin/migrate/process/Dom.php
+
7
−
2
View file @
aa94a699
...
...
@@ -34,6 +34,7 @@ use Masterminds\HTML5;
* - import_method: (optional) What parser to use. Possible values:
* - 'html': (default) use dom extension parsing.
* - 'html5': use html5 parsing.
* - 'xml': use XML parsing.
*
* @codingStandardsIgnoreStart
*
...
...
@@ -100,8 +101,8 @@ class Dom extends ProcessPluginBase {
throw
new
\InvalidArgumentException
(
'The "method" must be "import" or "export".'
);
}
$configuration
[
'import_method'
]
=
$configuration
[
'import_method'
]
??
'html'
;
if
(
!
in_array
(
$configuration
[
'import_method'
],
[
'html'
,
'html5'
]))
{
throw
new
\InvalidArgumentException
(
'The "import_method" must be "html"
or
"html5".'
);
if
(
!
in_array
(
$configuration
[
'import_method'
],
[
'html'
,
'html5'
,
'xml'
]))
{
throw
new
\InvalidArgumentException
(
'The "import_method" must be "html"
,
"html5"
, or "xml"
.'
);
}
parent
::
__construct
(
$configuration
,
$plugin_id
,
$plugin_definition
);
$this
->
configuration
+=
$this
->
defaultValues
();
...
...
@@ -176,6 +177,10 @@ class Dom extends ProcessPluginBase {
$html5
->
loadHTML
(
$html
);
break
;
case
'xml'
:
$document
->
loadXML
(
$html
);
break
;
case
'html'
:
default
:
$document
->
loadHTML
(
$html
);
...
...
This diff is collapsed.
Click to expand it.
tests/src/Unit/process/DomTest.php
+
14
−
2
View file @
aa94a699
...
...
@@ -45,11 +45,11 @@ final class DomTest extends MigrateProcessTestCase {
/**
* @covers ::__construct
*/
public
function
testInvalidImportMethod
()
{
public
function
testInvalidImportMethod
()
:
void
{
$configuration
[
'method'
]
=
'import'
;
$configuration
[
'import_method'
]
=
'invalid'
;
$this
->
expectException
(
\InvalidArgumentException
::
class
);
$this
->
expectExceptionMessage
(
'The "import_method" must be "html"
or
"html5".'
);
$this
->
expectExceptionMessage
(
'The "import_method" must be "html"
,
"html5"
, or "xml"
.'
);
(
new
Dom
(
$configuration
,
'dom'
,
[]));
}
...
...
@@ -77,6 +77,18 @@ final class DomTest extends MigrateProcessTestCase {
$this
->
assertTrue
(
$document
instanceof
\DOMDocument
);
}
/**
* @covers ::import
*/
public
function
testImportMethodXml
():
void
{
$configuration
[
'method'
]
=
'import'
;
$configuration
[
'import_method'
]
=
'xml'
;
$value
=
'<item><value>A simple paragraph.</value></item>'
;
$document
=
(
new
Dom
(
$configuration
,
'dom'
,
[]))
->
transform
(
$value
,
$this
->
migrateExecutable
,
$this
->
row
,
'destinationproperty'
);
$this
->
assertTrue
(
$document
instanceof
\DOMDocument
);
}
/**
* @covers ::import
*/
...
...
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