Commit 24896672 authored by alexpott's avatar alexpott

Issue #2807919 by maijs, svendecabooter: Convert Path's Migrate source tests to new base class

parent d3078ff3
<?php
namespace Drupal\Tests\path\Kernel\Plugin\migrate\source\d6;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the d6_url_alias source plugin.
*
* @covers \Drupal\path\Plugin\migrate\source\d6\UrlAlias
* @group path
*/
class UrlAliasTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migrate_drupal', 'path'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['url_alias'] = [
[
'pid' => 1,
'src' => 'node/1',
'dst' => 'test-article',
'language' => 'en',
],
[
'pid' => 2,
'src' => 'node/2',
'dst' => 'another-alias',
'language' => 'en',
],
];
// The expected results.
$tests[0]['expected_data'] = $tests[0]['source_data']['url_alias'];
return $tests;
}
}
<?php
namespace Drupal\Tests\path\Kernel\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Kernel\MigrateSqlSourceTestBase;
/**
* Tests the d7_url_alias source plugin.
*
* @covers \Drupal\path\Plugin\migrate\source\d7\UrlAlias
* @group path
*/
class UrlAliasTest extends MigrateSqlSourceTestBase {
/**
* {@inheritdoc}
*/
public static $modules = ['migrate_drupal', 'path'];
/**
* {@inheritdoc}
*/
public function providerSource() {
$tests = [];
// The source data.
$tests[0]['source_data']['url_alias'] = [
[
'pid' => 1,
'source' => 'node/1',
'alias' => 'test-article',
'language' => 'en',
],
[
'pid' => 2,
'source' => 'node/2',
'alias' => 'another-alias',
'language' => 'en',
],
];
// The expected results.
$tests[0]['expected_data'] = $tests[0]['source_data']['url_alias'];
return $tests;
}
}
<?php
namespace Drupal\Tests\path\Unit\Migrate;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Base class for url_alias source tests.
*/
abstract class UrlAliasTestBase extends MigrateSqlSourceTestCase {
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['url_alias'] = $this->expectedResults;
parent::setUp();
}
}
<?php
namespace Drupal\Tests\path\Unit\Migrate\d6;
use Drupal\Tests\path\Unit\Migrate\UrlAliasTestBase;
/**
* Tests the d6_url_alias source plugin.
*
* @group path
*/
class UrlAliasTest extends UrlAliasTestBase {
const PLUGIN_CLASS = 'Drupal\path\Plugin\migrate\source\d6\UrlAlias';
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd6_url_alias',
),
);
protected $expectedResults = array(
array(
'pid' => 1,
'src' => 'node/1',
'dst' => 'test-article',
'language' => 'en',
),
array(
'pid' => 2,
'src' => 'node/2',
'dst' => 'another-alias',
'language' => 'en',
),
);
}
<?php
namespace Drupal\Tests\path\Unit\Migrate\d7;
use Drupal\Tests\path\Unit\Migrate\UrlAliasTestBase;
/**
* Tests the d7_url_alias source plugin.
*
* @group path
*/
class UrlAliasTest extends UrlAliasTestBase {
const PLUGIN_CLASS = 'Drupal\path\Plugin\migrate\source\d7\UrlAlias';
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd7_url_alias',
),
);
protected $expectedResults = array(
array(
'pid' => 1,
'source' => 'node/1',
'alias' => 'test-article',
'language' => 'en',
),
array(
'pid' => 2,
'source' => 'node/2',
'alias' => 'another-alias',
'language' => 'en',
),
);
}
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