Commit 316d997e authored by heddn's avatar heddn Committed by heddn

Issue #2950084 by heddn: Add functional test to validate config schema

parent 7a526044
......@@ -6,7 +6,6 @@ migrate_plugin:
plugin:
type: string
label: 'Plugin'
migrate_destination:
type: migrate_plugin
label: 'Destination'
......@@ -25,6 +24,35 @@ migrate_source:
constants:
type: ignore
label: 'Constants'
ids:
type: ignore
label: 'Source IDs schema definition for migrate mapping table'
urls:
type: sequence
label: 'URLs from which to fetch'
sequence:
type: string
data_fetcher_plugin:
type: string
label: 'Fetcher plugin'
data_parser_plugin:
type: string
label: 'Parser plugin'
fields:
type: ignore
label: Mapping of field names to selectors
function:
type: string
label: 'Function to call on the service'
parameters:
type: ignore
label: 'Parameters to pass to function on the service'
response_type:
type: string
label: 'Type of response; XML string, object or array'
item_selector:
type: string
label: 'XPath selector'
migrate_process:
type: migrate_plugin
......
......@@ -71,9 +71,9 @@ migrate_plus.process.get:
type: string
label: 'Source key'
migrate_plus.process.iterator:
migrate_plus.process.sub_process:
type: migrate_process
label: 'Iterator process'
label: 'Sub process'
mapping:
process:
type: ignore
......
......@@ -2,6 +2,8 @@
id: beer_node
label: Beers of the world
migration_group: beer
migration_tags:
- example
source:
plugin: beer_node
destination:
......
......@@ -12,6 +12,10 @@ label: Migrate style categories from the source database to taxonomy terms
# configuration to be merged with our own configuration here).
migration_group: beer
# The category or tag for the migration.
migration_tags:
- example
# Every migration must have a source plugin, which controls the delivery of our
# source data. In this case, our source plugin has the name "beer_term", which
# Drupal resolves to the PHP class defined in
......
......@@ -4,6 +4,8 @@
id: beer_user
label: Beer Drinkers of the world
migration_group: beer
migration_tags:
- example
source:
plugin: beer_user
destination:
......
......@@ -2,13 +2,16 @@
id: weather_soap
label: SOAP service providing weather.
migration_group: wine
migration_tags:
- advanced example
source:
# We use the SOAP parser source plugin.
plugin: url
data_fetcher_plugin: http # Ignored - SoapClient does the fetching.
data_parser_plugin: soap
# URL of a WSDL endpoint.
urls: http://www.webservicex.net/globalweather.asmx?WSDL
urls:
- http://www.webservicex.net/globalweather.asmx?WSDL
# The function to call on the service, and the parameters to pass. See
# http://www.webservicex.net/New/Home/ServiceDetail/56 for the XML structure
# of this feed - how CountryName is passed within the GetCitiesByCountry
......@@ -48,3 +51,6 @@ process:
name: City
destination:
plugin: entity:taxonomy_term
migration_dependencies:
required: {}
optional: {}
......@@ -2,6 +2,8 @@
id: wine_role_json
label: JSON feed of roles (positions)
migration_group: wine
migration_tags:
- advanced example
source:
# We use the JSON source plugin.
plugin: url
......@@ -17,7 +19,8 @@ source:
# Normally, this is one or more fully-qualified URLs or file paths. Because
# we can't hardcode your local URL, we provide a relative path here which
# hook_install() will rewrite to a full URL for the current site.
urls: /migrate_example_advanced_position?_format=json
urls:
- /migrate_example_advanced_position?_format=json
# An xpath-like selector corresponding to the items to be imported.
item_selector: position
# Under 'fields', we list the data items to be imported. The first level keys
......
......@@ -2,6 +2,8 @@
id: wine_role_xml
label: XML feed of roles (positions)
migration_group: wine
migration_tags:
- advanced example
source:
# We use the XML data parser plugin.
plugin: url
......@@ -10,7 +12,8 @@ source:
# Normally, this is one or more fully-qualified URLs or file paths. Because
# we can't hardcode your local URL, we provide a relative path here which
# hook_install() will rewrite to a full URL for the current site.
urls: /migrate_example_advanced_position?_format=xml
urls:
- /migrate_example_advanced_position?_format=xml
# Visit the URL above (relative to your site root) and look at it. You can see
# that <response> is the outer element, and each item we want to import is a
# <position> element. The item_xpath value is the xpath to use to query the
......
id: wine_terms
label: Migrate all categories into Drupal taxonomy terms
migration_group: wine
migration_tags:
- advanced example
source:
plugin: wine_term
destination:
......
......@@ -3,13 +3,16 @@
id: wine_variety_list
label: XML feed of varieties
migration_group: wine
migration_tags:
- advanced example
source:
# We use the XML source plugin.
plugin: xml
# Normally, this is one or more fully-qualified URLs or file paths. Because
# we can't hardcode your local URL, we provide a relative path here which
# hook_install() will rewrite to a full URL for the current site.
urls: /migrate_example_advanced_variety_list?_format=xml
urls:
- /migrate_example_advanced_variety_list?_format=xml
item_url: /migrate_example_advanced_variety_list/:id?_format=xml
id_selector: /response/items
# Visit the URL above (relative to your site root) and look at it. You can see
......
......@@ -2,6 +2,8 @@
id: wine_variety_multi_xml
label: XML feed of varieties
migration_group: wine
migration_tags:
- advanced example
source:
# We use the XML source plugin.
plugin: url
......
......@@ -21,7 +21,11 @@ function migrate_example_advanced_install() {
if ($wine_role_xml_migration) {
$source = $wine_role_xml_migration->get('source');
$request = \Drupal::request();
$source['urls'] = 'http://' . $request->getHttpHost() . $source['urls'];
$urls = [];
foreach ($source['urls'] as $url) {
$urls[] = 'http://' . $request->getHttpHost() . $url;
}
$source['urls'] = $urls;
$wine_role_xml_migration->set('source', $source);
$wine_role_xml_migration->save();
}
......@@ -30,7 +34,11 @@ function migrate_example_advanced_install() {
if ($wine_role_json_migration) {
$source = $wine_role_json_migration->get('source');
$request = \Drupal::request();
$source['urls'] = 'http://' . $request->getHttpHost() . $source['urls'];
$urls = [];
foreach ($source['urls'] as $url) {
$urls[] = 'http://' . $request->getHttpHost() . $url;
}
$source['urls'] = $urls;
$wine_role_json_migration->set('source', $source);
$wine_role_json_migration->save();
}
......
<?php
namespace Drupal\Tests\migrate_plus\Functional;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;
/**
* Simple test to ensure that main page loads with module enabled.
*
* @group migrate_plus
*/
class LoadTest extends BrowserTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = [
'migrate_plus',
'migrate_example',
'migrate_example_advanced',
];
/**
* A user with permission to administer site configuration.
*
* @var \Drupal\user\UserInterface
*/
protected $user;
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->user = $this->drupalCreateUser(['administer site configuration']);
$this->drupalLogin($this->user);
}
/**
* Tests that the home page loads with a 200 response.
*/
public function testLoad() {
$this->drupalGet(Url::fromRoute('<front>'));
$this->assertSession()->statusCodeEquals(200);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment