Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
D
drupal
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
drupal
Commits
bb62e6c8
Commit
bb62e6c8
authored
10 months ago
by
Fran Garcia-Linares
Browse files
Options
Downloads
Patches
Plain Diff
Bring patch to 11.x
parent
717b02a8
No related branches found
No related tags found
1 merge request
!8776
Route migrate process plugin shouldn't assume that the $options variable is always an array
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
core/modules/migrate/src/Plugin/migrate/process/Route.php
+3
-1
3 additions, 1 deletion
core/modules/migrate/src/Plugin/migrate/process/Route.php
core/modules/migrate/tests/src/Kernel/process/RouteTest.php
+140
-118
140 additions, 118 deletions
core/modules/migrate/tests/src/Kernel/process/RouteTest.php
with
143 additions
and
119 deletions
core/modules/migrate/src/Plugin/migrate/process/Route.php
+
3
−
1
View file @
bb62e6c8
...
@@ -131,7 +131,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
...
@@ -131,7 +131,9 @@ public function transform($value, MigrateExecutableInterface $migrate_executable
$options
[
'query'
]
=
$route
[
'options'
][
'query'
]
+
$old_query
;
$options
[
'query'
]
=
$route
[
'options'
][
'query'
]
+
$old_query
;
unset
(
$route
[
'options'
][
'query'
]);
unset
(
$route
[
'options'
][
'query'
]);
}
}
$route
[
'options'
]
=
$route
[
'options'
]
+
$options
;
if
(
is_array
(
$options
))
{
$route
[
'options'
]
+=
$options
;
}
$route
[
'url'
]
=
NULL
;
$route
[
'url'
]
=
NULL
;
}
}
}
}
...
...
This diff is collapsed.
Click to expand it.
core/modules/migrate/tests/src/Kernel/process/RouteTest.php
+
140
−
118
View file @
bb62e6c8
...
@@ -29,6 +29,19 @@ class RouteTest extends KernelTestBase {
...
@@ -29,6 +29,19 @@ class RouteTest extends KernelTestBase {
*/
*/
protected
static
$modules
=
[
'user'
,
'system'
];
protected
static
$modules
=
[
'user'
,
'system'
];
/**
* {@inheritdoc}
*/
protected
function
setUp
():
void
{
parent
::
setUp
();
// We have to configure a front page since
// PathProcessorFront::processInbound relies on it for missing paths.
$this
->
config
(
'system.site'
)
->
set
(
'page.front'
,
'user'
)
->
save
();
}
/**
/**
* Tests Route plugin based on providerTestRoute() values.
* Tests Route plugin based on providerTestRoute() values.
*
*
...
@@ -52,141 +65,150 @@ public function testRoute($value, $expected): void {
...
@@ -52,141 +65,150 @@ public function testRoute($value, $expected): void {
* process plugin, and the second is the expected results.
* process plugin, and the second is the expected results.
*/
*/
public
static
function
providerTestRoute
()
{
public
static
function
providerTestRoute
()
{
// Internal link tests.
return
[
// Valid link path and options.
'Valid internal link path and options'
=>
[
$values
[
0
]
=
[
'data'
=>
[
'user/login'
,
'user/login'
,
[
[
'attributes'
=>
[
'attributes'
=>
[
'title'
=>
'Test menu link 1'
,
'title'
=>
'Test menu link 1'
,
],
],
],
],
],
'expected'
=>
[
];
'route_name'
=>
'user.login'
,
$expected
[
0
]
=
[
'route_parameters'
=>
[],
'route_name'
=>
'user.login'
,
'options'
=>
[
'route_parameters'
=>
[],
'query'
=>
[],
'options'
=>
[
'attributes'
=>
[
'query'
=>
[],
'title'
=>
'Test menu link 1'
,
'attributes'
=>
[
],
'title'
=>
'Test menu link 1'
,
],
'url'
=>
NULL
,
],
],
],
],
'
url'
=>
NULL
,
'
Valid internal link path and empty options'
=>
[
];
'data'
=>
[
'user/login'
,
// Valid link path and empty options.
[],
$values
[
1
]
=
[
],
'user/login'
,
'expected'
=>
[
[]
,
'route_name'
=>
'user.login'
,
];
'route_parameters'
=>
[],
$expected
[
1
]
=
[
'options'
=
>
[
'
route_name'
=>
'user.login'
,
'
query'
=>
[]
,
'route_parameters'
=>
[
],
],
'options'
=>
[
'url'
=>
NULL
,
'query'
=>
[
],
],
],
],
'
url'
=>
NULL
,
'
Valid internal link path and no options'
=>
[
];
'data'
=>
'user/login'
,
'expected'
=>
[
// Valid link path and no options.
'route_name'
=>
'user.login'
,
$values
[
2
]
=
'user/login'
;
'route_parameters'
=>
[],
$expected
[
2
]
=
[
'options'
=
>
[
'
route_name'
=>
'user.login'
,
'
query'
=>
[]
,
'route_parameters'
=>
[
],
],
'options'
=>
[
'url'
=>
NULL
,
'query'
=>
[
],
],
],
],
'url'
=>
NULL
,
'Valid internal link path and non-array options'
=>
[
];
'data'
=>
[
'user/login'
,
// Invalid link path.
'options'
,
$values
[
3
]
=
'users'
;
],
$expected
[
3
]
=
[];
'expected'
=>
[
'route_name'
=>
'user.login'
,
// Valid link path with parameter.
'route_parameters'
=>
[],
$values
[
4
]
=
[
'options'
=>
[
'system/timezone/nzdt'
,
'query'
=>
[],
[
],
'attributes'
=>
[
'url'
=>
NULL
,
'title'
=>
'Show NZDT'
,
],
],
],
],
];
'Invalid internal link path'
=>
[
$expected
[
4
]
=
[
'data'
=>
'users'
,
'route_name'
=>
'system.timezone'
,
'expected'
=>
[],
'route_parameters'
=>
[
'abbreviation'
=>
'nzdt'
,
'offset'
=>
-
1
,
'is_daylight_saving_time'
=>
NULL
,
],
],
'options'
=>
[
'Valid internal link path with parameter'
=>
[
'query'
=>
[],
'data'
=>
[
'attributes'
=>
[
'system/timezone/nzdt'
,
'title'
=>
'Show NZDT'
,
[
'attributes'
=>
[
'title'
=>
'Show NZDT'
,
],
],
],
],
],
'expected'
=>
[
'url'
=>
NULL
,
'route_name'
=>
'system.timezone'
,
];
'route_parameters'
=>
[
'abbreviation'
=>
'nzdt'
,
// External link tests.
'offset'
=>
-
1
,
// Valid external link path and options.
'is_daylight_saving_time'
=>
NULL
,
$values
[
5
]
=
[
],
'https://www.drupal.org'
,
'options'
=>
[
[
'query'
=>
[],
'attributes'
=>
[
'attributes'
=>
[
'title'
=>
'Drupal'
,
'title'
=>
'Show NZDT'
,
],
],
'url'
=>
NULL
,
],
],
],
],
];
'Valid external link path and options'
=>
[
$expected
[
5
]
=
[
'data'
=>
[
'route_name'
=>
NULL
,
'https://www.drupal.org'
,
'route_parameters'
=>
[],
[
'options'
=>
[
'attributes'
=>
[
'attributes'
=>
[
'title'
=>
'Drupal'
,
'title'
=>
'Drupal'
,
],
],
],
'expected'
=>
[
'route_name'
=>
NULL
,
'route_parameters'
=>
[],
'options'
=>
[
'attributes'
=>
[
'title'
=>
'Drupal'
,
],
],
'url'
=>
'https://www.drupal.org'
,
],
],
],
],
'url'
=>
'https://www.drupal.org'
,
'Valid external link path with query string and options'
=>
[
];
'data'
=>
[
'https://www.drupal.org/user/1/edit?pass-reset-token=QgtDKcRV4e4fjg6v2HTa6CbWx-XzMZ5XBZTufinqsM73qIhscIuU_BjZ6J2tv4dQI6N50ZJOag'
,
// Valid external link path and options.
[
$values
[
6
]
=
[
'attributes'
=>
[
'https://www.drupal.org/user/1/edit?pass-reset-token=QgtDKcRV4e4fjg6v2HTa6CbWx-XzMZ5XBZTufinqsM73qIhscIuU_BjZ6J2tv4dQI6N50ZJOag'
,
'title'
=>
'Drupal password reset'
,
[
],
'attributes'
=>
[
],
'title'
=>
'Drupal password reset'
,
],
'expected'
=>
[
'route_name'
=>
NULL
,
'route_parameters'
=>
[],
'options'
=>
[
'attributes'
=>
[
'title'
=>
'Drupal password reset'
,
],
],
'url'
=>
'https://www.drupal.org/user/1/edit?pass-reset-token=QgtDKcRV4e4fjg6v2HTa6CbWx-XzMZ5XBZTufinqsM73qIhscIuU_BjZ6J2tv4dQI6N50ZJOag'
,
],
],
],
],
];
'Null link path with options'
=>
[
$expected
[
6
]
=
[
'data'
=>
[
'route_name'
=>
NULL
,
NULL
,
'route_parameters'
=>
[],
NULL
,
'options'
=>
[
],
'attributes'
=>
[
'expected'
=>
[
'title'
=>
'Drupal password reset'
,
'route_name'
=>
'user.page'
,
'route_parameters'
=>
[],
'options'
=>
[
'query'
=>
[],
],
'url'
=>
NULL
,
],
],
],
],
'url'
=>
'https://www.drupal.org/user/1/edit?pass-reset-token=QgtDKcRV4e4fjg6v2HTa6CbWx-XzMZ5XBZTufinqsM73qIhscIuU_BjZ6J2tv4dQI6N50ZJOag'
,
];
return
[
// Test data for internal paths.
// Test with valid link path and options.
[
$values
[
0
],
$expected
[
0
]],
// Test with valid link path and empty options.
[
$values
[
1
],
$expected
[
1
]],
// Test with valid link path and no options.
[
$values
[
2
],
$expected
[
2
]],
// Test with Invalid link path.
[
$values
[
3
],
$expected
[
3
]],
// Test with Valid link path with query options and parameters.
[
$values
[
4
],
$expected
[
4
]],
// Test data for external paths.
// Test with external link path and options.
[
$values
[
5
],
$expected
[
5
]],
// Test with valid link path and query options.
[
$values
[
6
],
$expected
[
6
]],
];
];
}
}
...
...
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