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
39902b80
Commit
39902b80
authored
9 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2555109
by neclimdul, phenaproxima: MigrateTests incorrectly setup mock connection
parent
78e2e8ea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!7452
Issue #1797438. HTML5 validation is preventing form submit and not fully...
,
!789
Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
core/modules/migrate/src/Tests/MigrateTestBase.php
+35
-1
35 additions, 1 deletion
core/modules/migrate/src/Tests/MigrateTestBase.php
with
35 additions
and
1 deletion
core/modules/migrate/src/Tests/MigrateTestBase.php
+
35
−
1
View file @
39902b80
...
@@ -59,7 +59,28 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
...
@@ -59,7 +59,28 @@ abstract class MigrateTestBase extends KernelTestBase implements MigrateMessageI
*/
*/
protected
function
setUp
()
{
protected
function
setUp
()
{
parent
::
setUp
();
parent
::
setUp
();
$this
->
createMigrationConnection
();
}
/**
* Changes the database connection to the prefixed one.
*
* @todo Remove when we don't use global. https://www.drupal.org/node/2552791
*/
private
function
createMigrationConnection
()
{
// If the backup already exists, something went terribly wrong.
// This case is possible, because database connection info is a static
// global state construct on the Database class, which at least persists
// for all test methods executed in one PHP process.
if
(
Database
::
getConnectionInfo
(
'simpletest_original_migrate'
))
{
throw
new
\RuntimeException
(
"Bad Database connection state: 'simpletest_original_migrate' connection key already exists. Broken test?"
);
}
// Clone the current connection and replace the current prefix.
$connection_info
=
Database
::
getConnectionInfo
(
'migrate'
);
if
(
$connection_info
)
{
Database
::
renameConnection
(
'migrate'
,
'simpletest_original_migrate'
);
}
$connection_info
=
Database
::
getConnectionInfo
(
'default'
);
$connection_info
=
Database
::
getConnectionInfo
(
'default'
);
foreach
(
$connection_info
as
$target
=>
$value
)
{
foreach
(
$connection_info
as
$target
=>
$value
)
{
$prefix
=
is_array
(
$value
[
'prefix'
])
?
$value
[
'prefix'
][
'default'
]
:
$value
[
'prefix'
];
$prefix
=
is_array
(
$value
[
'prefix'
])
?
$value
[
'prefix'
][
'default'
]
:
$value
[
'prefix'
];
...
@@ -78,13 +99,26 @@ protected function setUp() {
...
@@ -78,13 +99,26 @@ protected function setUp() {
* {@inheritdoc}
* {@inheritdoc}
*/
*/
protected
function
tearDown
()
{
protected
function
tearDown
()
{
Database
::
remov
eConnection
(
'migrate'
);
$this
->
cleanupMigrat
eConnection
();
parent
::
tearDown
();
parent
::
tearDown
();
$this
->
databaseDumpFiles
=
[];
$this
->
databaseDumpFiles
=
[];
$this
->
collectMessages
=
FALSE
;
$this
->
collectMessages
=
FALSE
;
unset
(
$this
->
migration
,
$this
->
migrateMessages
);
unset
(
$this
->
migration
,
$this
->
migrateMessages
);
}
}
/**
* Cleans up the test migrate connection.
*
* @todo Remove when we don't use global. https://www.drupal.org/node/2552791
*/
private
function
cleanupMigrateConnection
()
{
Database
::
removeConnection
(
'migrate'
);
$original_connection_info
=
Database
::
getConnectionInfo
(
'simpletest_original_migrate'
);
if
(
$original_connection_info
)
{
Database
::
renameConnection
(
'simpletest_original_migrate'
,
'migrate'
);
}
}
/**
/**
* Load Drupal 6 database dumps to be used.
* Load Drupal 6 database dumps to be used.
*
*
...
...
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