From 2489667275280cd31eed3bfb0680fb68b2711c10 Mon Sep 17 00:00:00 2001 From: Alex Pott <alex.a.pott@googlemail.com> Date: Sun, 23 Oct 2016 10:28:16 -0700 Subject: [PATCH] Issue #2807919 by maijs, svendecabooter: Convert Path's Migrate source tests to new base class --- .../Plugin/migrate/source/d6/UrlAliasTest.php | 48 +++++++++++++++++++ .../Plugin/migrate/source/d7/UrlAliasTest.php | 48 +++++++++++++++++++ .../src/Unit/Migrate/UrlAliasTestBase.php | 20 -------- .../src/Unit/Migrate/d6/UrlAliasTest.php | 38 --------------- .../src/Unit/Migrate/d7/UrlAliasTest.php | 38 --------------- 5 files changed, 96 insertions(+), 96 deletions(-) create mode 100644 core/modules/path/tests/src/Kernel/Plugin/migrate/source/d6/UrlAliasTest.php create mode 100644 core/modules/path/tests/src/Kernel/Plugin/migrate/source/d7/UrlAliasTest.php delete mode 100644 core/modules/path/tests/src/Unit/Migrate/UrlAliasTestBase.php delete mode 100644 core/modules/path/tests/src/Unit/Migrate/d6/UrlAliasTest.php delete mode 100644 core/modules/path/tests/src/Unit/Migrate/d7/UrlAliasTest.php diff --git a/core/modules/path/tests/src/Kernel/Plugin/migrate/source/d6/UrlAliasTest.php b/core/modules/path/tests/src/Kernel/Plugin/migrate/source/d6/UrlAliasTest.php new file mode 100644 index 000000000000..1057dffbee66 --- /dev/null +++ b/core/modules/path/tests/src/Kernel/Plugin/migrate/source/d6/UrlAliasTest.php @@ -0,0 +1,48 @@ +<?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; + } + +} diff --git a/core/modules/path/tests/src/Kernel/Plugin/migrate/source/d7/UrlAliasTest.php b/core/modules/path/tests/src/Kernel/Plugin/migrate/source/d7/UrlAliasTest.php new file mode 100644 index 000000000000..2fdfd361d66c --- /dev/null +++ b/core/modules/path/tests/src/Kernel/Plugin/migrate/source/d7/UrlAliasTest.php @@ -0,0 +1,48 @@ +<?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; + } + +} diff --git a/core/modules/path/tests/src/Unit/Migrate/UrlAliasTestBase.php b/core/modules/path/tests/src/Unit/Migrate/UrlAliasTestBase.php deleted file mode 100644 index c929192cbd22..000000000000 --- a/core/modules/path/tests/src/Unit/Migrate/UrlAliasTestBase.php +++ /dev/null @@ -1,20 +0,0 @@ -<?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(); - } - -} diff --git a/core/modules/path/tests/src/Unit/Migrate/d6/UrlAliasTest.php b/core/modules/path/tests/src/Unit/Migrate/d6/UrlAliasTest.php deleted file mode 100644 index fa00d60c9825..000000000000 --- a/core/modules/path/tests/src/Unit/Migrate/d6/UrlAliasTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?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', - ), - ); - -} diff --git a/core/modules/path/tests/src/Unit/Migrate/d7/UrlAliasTest.php b/core/modules/path/tests/src/Unit/Migrate/d7/UrlAliasTest.php deleted file mode 100644 index d2fce564d6df..000000000000 --- a/core/modules/path/tests/src/Unit/Migrate/d7/UrlAliasTest.php +++ /dev/null @@ -1,38 +0,0 @@ -<?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', - ), - ); - -} -- GitLab