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
27a94ebd
Commit
27a94ebd
authored
11 years ago
by
Angie Byron
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#2152355
by chx: Refactor the entity dedupe test to use dataProvider.
parent
d5efc596
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/tests/Drupal/migrate/Tests/process/DedupeEntityTest.php
+28
-46
28 additions, 46 deletions
...e/tests/Drupal/migrate/Tests/process/DedupeEntityTest.php
with
28 additions
and
46 deletions
core/modules/migrate/tests/Drupal/migrate/Tests/process/DedupeEntityTest.php
+
28
−
46
View file @
27a94ebd
...
...
@@ -10,8 +10,12 @@
use
Drupal\migrate\Plugin\migrate\process\DedupeEntity
;
/**
* Test the deduplication entity process plugin.
*
* @group migrate
* @group Drupal
*
* @see \Drupal\migrate\Plugin\migrate\process\DedupeEntity
*/
class
DedupeEntityTest
extends
MigrateProcessTestCase
{
...
...
@@ -44,65 +48,43 @@ public function setUp() {
}
/**
* Tests the entity deduplication plugin when there is no duplication.
*/
public
function
testDedupeEntityNoDuplication
()
{
$configuration
=
array
(
'entity_type'
=>
'test_entity_type'
,
'field'
=>
'test_field'
,
);
$plugin
=
new
TestDedupeEntity
(
$configuration
,
'dedupe_entity'
,
array
());
$this
->
entityQueryExpects
(
0
);
$plugin
->
setEntityQuery
(
$this
->
entityQuery
);
$return
=
$plugin
->
transform
(
'test'
,
$this
->
migrateExecutable
,
$this
->
row
,
'testpropertty'
);
$this
->
assertSame
(
$return
,
'test'
);
}
/**
* Tests the entity deduplication plugin when there is duplication.
*/
public
function
testDedupeEntityDuplication
()
{
$configuration
=
array
(
'entity_type'
=>
'test_entity_type'
,
'field'
=>
'test_field'
,
);
$plugin
=
new
TestDedupeEntity
(
$configuration
,
'dedupe_entity'
,
array
());
$this
->
entityQueryExpects
(
3
);
$plugin
->
setEntityQuery
(
$this
->
entityQuery
);
$return
=
$plugin
->
transform
(
'test'
,
$this
->
migrateExecutable
,
$this
->
row
,
'testpropertty'
);
$this
->
assertSame
(
$return
,
'test3'
);
}
/**
* Tests the entity deduplication plugin when there is no duplication.
* Tests entity based deduplication based on providerTestDedupe() values.
*
* @dataProvider providerTestDedupe
*/
public
function
testDedupe
EntityNoDuplicationWithP
ostfix
(
)
{
public
function
testDedupe
(
$count
,
$p
ostfix
=
''
)
{
$configuration
=
array
(
'entity_type'
=>
'test_entity_type'
,
'field'
=>
'test_field'
,
'postfix'
=>
'_'
,
);
if
(
$postfix
)
{
$configuration
[
'postfix'
]
=
$postfix
;
}
$plugin
=
new
TestDedupeEntity
(
$configuration
,
'dedupe_entity'
,
array
());
$this
->
entityQueryExpects
(
0
);
$this
->
entityQueryExpects
(
$count
);
$plugin
->
setEntityQuery
(
$this
->
entityQuery
);
$return
=
$plugin
->
transform
(
'test'
,
$this
->
migrateExecutable
,
$this
->
row
,
'testpropertty'
);
$this
->
assertSame
(
$return
,
'test'
);
$this
->
assertSame
(
$return
,
'test'
.
(
$count
?
$postfix
.
$count
:
''
)
);
}
/**
*
Tests the entity deduplication plugin when there is duplication
.
*
Data provider for testDedupe()
.
*/
public
function
testDedupeEntityDuplicationWithPostfix
()
{
$configuration
=
array
(
'entity_type'
=>
'test_entity_type'
,
'field'
=>
'test_field'
,
'postfix'
=>
'_'
,
public
function
providerTestDedupe
()
{
return
array
(
// Tests the entity deduplication plugin when there is no duplication
// and no postfix.
array
(
0
),
// Tests the entity deduplication plugin when there is duplication but
// no postfix.
array
(
3
),
// Tests the entity deduplication plugin when there is no duplication
// but there is a postfix.
array
(
0
,
'_'
),
// Tests the entity deduplication plugin when there is duplication and
// there is a postfix.
array
(
2
,
'_'
),
);
$plugin
=
new
TestDedupeEntity
(
$configuration
,
'dedupe_entity'
,
array
());
$this
->
entityQueryExpects
(
2
);
$plugin
->
setEntityQuery
(
$this
->
entityQuery
);
$return
=
$plugin
->
transform
(
'test'
,
$this
->
migrateExecutable
,
$this
->
row
,
'testpropertty'
);
$this
->
assertSame
(
$return
,
'test_2'
);
}
/**
...
...
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