Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
single_content_sync
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
single_content_sync
Commits
13f36eb6
Commit
13f36eb6
authored
1 year ago
by
Vadym Abramchuk
Browse files
Options
Downloads
Patches
Plain Diff
Issue
#3404115
: Add address_zone field type import/export tests
parent
fedd76c0
No related branches found
Branches containing commit
Tags
1.4.5
Tags containing commit
1 merge request
!100
Issue #3404115: Support address_zone field type
Pipeline
#162454
passed with warnings
9 months ago
Stage: build
Stage: validate
Stage: test
Changes
1
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
tests/src/Kernel/FieldProcessor/AddressZoneTest.php
+137
-0
137 additions, 0 deletions
tests/src/Kernel/FieldProcessor/AddressZoneTest.php
with
137 additions
and
0 deletions
tests/src/Kernel/FieldProcessor/AddressZoneTest.php
0 → 100644
+
137
−
0
View file @
13f36eb6
<?php
namespace
Drupal\Tests\single_content_sync\Kernel\FieldProcessor
;
use
CommerceGuys\Addressing\Zone\Zone
;
/**
* @coversDefaultClass \Drupal\single_content_sync\Plugin\SingleContentSyncFieldProcessor\AddressZone
*/
class
AddressZoneTest
extends
FieldProcessorTestBase
{
/**
* {@inheritdoc}
*/
protected
function
importFieldValueDataProvider
():
array
{
return
[
'address_zone'
=>
[
[
'type'
=>
'address_zone'
,
'settings'
=>
[
'available_countries'
=>
[],
],
],
[
0
=>
[
'id'
=>
'field_zone'
,
'label'
=>
'zone'
,
'territories'
=>
[
0
=>
[
'country_code'
=>
'UA'
,
'administrative_area'
=>
'07'
,
'locality'
=>
NULL
,
'dependent_locality'
=>
NULL
,
'included_postal_codes'
=>
NULL
,
'excluded_postal_codes'
=>
NULL
,
],
],
],
],
[
0
=>
[
'id'
=>
'field_zone'
,
'label'
=>
'zone'
,
'territories'
=>
[
0
=>
[
'country_code'
=>
'UA'
,
'administrative_area'
=>
'07'
,
'locality'
=>
NULL
,
'dependent_locality'
=>
NULL
,
'included_postal_codes'
=>
NULL
,
'excluded_postal_codes'
=>
NULL
,
],
],
],
],
[
'address'
],
],
];
}
/**
* {@inheritdoc}
*/
protected
function
exportFieldValueDataProvider
():
array
{
return
[
'address_zone'
=>
[
[
'type'
=>
'address_zone'
,
'settings'
=>
[
'available_countries'
=>
[],
],
],
new
Zone
([
'id'
=>
'field_zone'
,
'label'
=>
'zone'
,
'territories'
=>
[
[
'country_code'
=>
'UA'
,
'administrative_area'
=>
'07'
,
'locality'
=>
NULL
,
'dependent_locality'
=>
NULL
,
'included_postal_codes'
=>
NULL
,
'excluded_postal_codes'
=>
NULL
,
],
],
]),
[
0
=>
[
'id'
=>
'field_zone'
,
'label'
=>
'zone'
,
'territories'
=>
[
0
=>
[
'country_code'
=>
'UA'
,
'administrative_area'
=>
'07'
,
'locality'
=>
NULL
,
'dependent_locality'
=>
NULL
,
'included_postal_codes'
=>
NULL
,
'excluded_postal_codes'
=>
NULL
,
],
],
],
],
[
'address'
],
],
];
}
/**
* {@inheritdoc}
*/
protected
function
assertImportedValueEquals
(
mixed
$expectedFieldValue
,
mixed
$actualImportedFieldValue
):
void
{
foreach
(
$expectedFieldValue
as
$delta
=>
$expectedValue
)
{
/** @var \CommerceGuys\Addressing\Zone\Zone $zone */
$zone
=
$actualImportedFieldValue
[
$delta
][
'value'
];
$this
->
assertInstanceOf
(
Zone
::
class
,
$zone
);
$this
->
assertEquals
(
$expectedValue
[
'id'
],
$zone
->
getId
());
$this
->
assertEquals
(
$expectedValue
[
'label'
],
$zone
->
getLabel
());
$expectedTerritories
=
$expectedValue
[
'territories'
];
$importedTerritories
=
$zone
->
getTerritories
();
$this
->
assertCount
(
count
(
$expectedTerritories
),
$importedTerritories
);
$this
->
assertEquals
(
array_keys
(
$expectedTerritories
),
array_keys
(
$importedTerritories
));
foreach
(
$expectedTerritories
as
$territoryDelta
=>
$expectedTerritory
)
{
$importedTerritory
=
$importedTerritories
[
$territoryDelta
];
$this
->
assertEquals
(
$expectedTerritory
[
'country_code'
],
$importedTerritory
->
getCountryCode
());
$this
->
assertEquals
(
$expectedTerritory
[
'administrative_area'
],
$importedTerritory
->
getAdministrativeArea
());
$this
->
assertEquals
(
$expectedTerritory
[
'locality'
],
$importedTerritory
->
getLocality
());
$this
->
assertEquals
(
$expectedTerritory
[
'dependent_locality'
],
$importedTerritory
->
getDependentLocality
());
$this
->
assertEquals
(
$expectedTerritory
[
'included_postal_codes'
],
$importedTerritory
->
getIncludedPostalCodes
());
$this
->
assertEquals
(
$expectedTerritory
[
'excluded_postal_codes'
],
$importedTerritory
->
getExcludedPostalCodes
());
}
}
}
}
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