diff --git a/core/modules/migrate_drupal/src/Tests/Table/d7/TrackerUser.php b/core/modules/migrate_drupal/src/Tests/Table/d7/TrackerUser.php index e6c92e240dbe7565c891a55db4f02ded8423c02f..e4d54c35df32b93b668f2cd5dc58ab7e105fa512 100644 --- a/core/modules/migrate_drupal/src/Tests/Table/d7/TrackerUser.php +++ b/core/modules/migrate_drupal/src/Tests/Table/d7/TrackerUser.php @@ -63,11 +63,11 @@ public function load() { )) ->values(array( 'nid' => '1', - 'uid' => '1', + 'uid' => '2', 'published' => '1', 'changed' => '1421727536', ))->execute(); } } -#6fb17f49221d202409a1298360628d70 +#6439575c8ff5b85c7c87030634bf6b63 diff --git a/core/modules/tracker/migration_templates/d7_tracker_node.yml b/core/modules/tracker/migration_templates/d7_tracker_node.yml new file mode 100644 index 0000000000000000000000000000000000000000..02645d7e8a816e3f9c5469c08b726b484f3bea46 --- /dev/null +++ b/core/modules/tracker/migration_templates/d7_tracker_node.yml @@ -0,0 +1,15 @@ +id: d7_tracker_node +label: Tracker node +migration_tags: + - Drupal 7 +source: + plugin: d7_tracker_node +process: + nid: nid + published: published + changed: changed +destination: + plugin: entity:node +migration_dependencies: + required: + - d7_user diff --git a/core/modules/tracker/migration_templates/d7_tracker_user.yml b/core/modules/tracker/migration_templates/d7_tracker_user.yml new file mode 100644 index 0000000000000000000000000000000000000000..ae3c51d69e0eebc2cbb25cbbeae31626738941ed --- /dev/null +++ b/core/modules/tracker/migration_templates/d7_tracker_user.yml @@ -0,0 +1,16 @@ +id: d7_tracker_user +label: Tracker user +migration_tags: + - Drupal 7 +source: + plugin: d7_tracker_user +process: + nid: nid + uid: uid + published: published + changed: changed +destination: + plugin: entity:user +migration_dependencies: + required: + - d7_user diff --git a/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerNode.php b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerNode.php new file mode 100644 index 0000000000000000000000000000000000000000..7667732ad64418ddcb65a9385d52ddc04f61366f --- /dev/null +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerNode.php @@ -0,0 +1,47 @@ +<?php +/** + * @file + * Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerNode. + */ + +namespace Drupal\tracker\Plugin\migrate\source\d7; + +use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; + +/** + * Drupal 7 tracker node source from database. + * + * @MigrateSource( + * id = "d7_tracker_node", + * source_provider = "tracker" + * ) + */ +class TrackerNode extends DrupalSqlBase { + + /** + * {@inheritdoc} + */ + public function query() { + return $this->select('tracker_node', 'tn')->fields('tn'); + } + + /** + * {@inheritdoc} + */ + public function fields() { + return [ + 'nid' => $this->t('The {node}.nid this record tracks.'), + 'published' => $this->t('Boolean indicating whether the node is published.'), + 'changed' => $this->t('The Unix timestamp when the node was most recently saved or commented on.'), + ]; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['nid']['type'] = 'integer'; + return $ids; + } + +} diff --git a/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php new file mode 100644 index 0000000000000000000000000000000000000000..02045fcb82f28750d74d5841cc32defcaf43246b --- /dev/null +++ b/core/modules/tracker/src/Plugin/migrate/source/d7/TrackerUser.php @@ -0,0 +1,49 @@ +<?php +/** + * @file + * Contains \Drupal\tracker\Plugin\migrate\source\d7\TrackerUser. + */ + +namespace Drupal\tracker\Plugin\migrate\source\d7; + +use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase; + +/** + * Drupal 7 tracker user source from database. + * + * @MigrateSource( + * id = "d7_tracker_user", + * source_provider = "tracker" + * ) + */ +class TrackerUser extends DrupalSqlBase { + + /** + * {@inheritdoc} + */ + public function query() { + return $this->select('tracker_user', 'tu')->fields('tu'); + } + + /** + * {@inheritdoc} + */ + public function fields() { + return [ + 'nid' => $this->t('The {user}.nid this record tracks.'), + 'uid' => $this->t('The {users}.uid of the node author or commenter.'), + 'published' => $this->t('Boolean indicating whether the node is published.'), + 'changed' => $this->t('The Unix timestamp when the user was most recently saved or commented on.'), + ]; + } + + /** + * {@inheritdoc} + */ + public function getIds() { + $ids['nid']['type'] = 'integer'; + $ids['uid']['type'] = 'integer'; + return $ids; + } + +} diff --git a/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..e6d18fd15960826e11c133470bee3c117ab13a5d --- /dev/null +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerNodeTest.php @@ -0,0 +1,74 @@ +<?php + +/** + * @file + * Contains \Drupal\tracker\Tests\Migrate\d7\MigrateTrackerNodeTest. + */ + +namespace Drupal\tracker\Tests\Migrate\d7; + +use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase; +use Drupal\Core\Database\Database; + +/** + * Tests migration of tracker_node. + * + * @group tracker + */ +class MigrateTrackerNodeTest extends MigrateDrupal7TestBase { + + /** + * {@inheritdoc} + */ + public static $modules = [ + 'entity_reference', + 'node', + 'text', + 'tracker', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + $this->installEntitySchema('node'); + $this->installConfig(static::$modules); + $this->installSchema('node', ['node_access']); + $this->installSchema('tracker', ['tracker_node', 'tracker_user']); + + $this->executeMigrations([ + 'd7_user_role', + 'd7_user', + 'd7_node_type', + 'd7_node__test_content_type', + 'd7_tracker_node', + ]); + } + + /** + * Tests migration of tracker node table. + */ + public function testMigrateTrackerNode() { + $connection = Database::getConnection('default', 'migrate'); + $num_rows = $connection + ->select('tracker_node', 'tn') + ->fields('tn', ['nid', 'published', 'changed']) + ->countQuery() + ->execute() + ->fetchField(); + $this->assertIdentical('1', $num_rows); + + $tracker_nodes = $connection + ->select('tracker_node', 'tn') + ->fields('tn', ['nid', 'published', 'changed']) + ->execute(); + $row = $tracker_nodes->fetchAssoc(); + $this->assertIdentical('1', $row['nid']); + $this->assertIdentical('1', $row['published']); + $this->assertIdentical('1421727536', $row['changed']); + } + +} + diff --git a/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerUserTest.php b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerUserTest.php new file mode 100644 index 0000000000000000000000000000000000000000..3628b4c5ec8c86f3464c48b4f995f05cd2ef203a --- /dev/null +++ b/core/modules/tracker/src/Tests/Migrate/d7/MigrateTrackerUserTest.php @@ -0,0 +1,74 @@ +<?php + +/** + * @file + * Contains \Drupal\tracker\Tests\Migrate\d7\MigrateTrackerUserTest. + */ + +namespace Drupal\tracker\Tests\Migrate\d7; + +use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase; +use Drupal\Core\Database\Database; + +/** + * Tests migration of tracker_user. + * + * @group tracker + */ +class MigrateTrackerUserTest extends MigrateDrupal7TestBase { + + /** + * {@inheritdoc} + */ + public static $modules = [ + 'entity_reference', + 'node', + 'text', + 'tracker', + ]; + + /** + * {@inheritdoc} + */ + protected function setUp() { + parent::setUp(); + + $this->installEntitySchema('node'); + $this->installConfig(static::$modules); + $this->installSchema('node', ['node_access']); + $this->installSchema('tracker', ['tracker_node', 'tracker_user']); + + $this->executeMigrations([ + 'd7_user_role', + 'd7_user', + 'd7_node_type', + 'd7_node__test_content_type', + 'd7_tracker_node', + ]); + } + + /** + * Tests migration of tracker user table. + */ + public function testMigrateTrackerUser() { + $connection = Database::getConnection('default', 'migrate'); + $num_rows = $connection + ->select('tracker_user', 'tn') + ->fields('tu', ['nid', 'uid', 'published', 'changed']) + ->countQuery() + ->execute() + ->fetchField(); + $this->assertIdentical('1', $num_rows); + + $tracker_nodes = $connection + ->select('tracker_user', 'tu') + ->fields('tu', ['nid', 'uid', 'published', 'changed']) + ->execute(); + $row = $tracker_nodes->fetchAssoc(); + $this->assertIdentical('1', $row['nid']); + $this->assertIdentical('2', $row['uid']); + $this->assertIdentical('1', $row['published']); + $this->assertIdentical('1421727536', $row['changed']); + } + +} diff --git a/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerNodeTest.php b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerNodeTest.php new file mode 100644 index 0000000000000000000000000000000000000000..65411a878ea2f607cd412eb43e4ad30a5435d1a8 --- /dev/null +++ b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerNodeTest.php @@ -0,0 +1,44 @@ +<?php + +/** + * @file + * Contains \Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7\TrackerNodeTest. + */ + +namespace Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7; + +use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; + +/** + * Tests D7 tracker node source plugin. + * + * @group tracker + */ +class TrackerNodeTest extends MigrateSqlSourceTestCase { + + const PLUGIN_CLASS = 'Drupal\tracker\Plugin\migrate\source\d7\TrackerNode'; + + protected $migrationConfiguration = [ + 'id' => 'test', + 'source' => [ + 'plugin' => 'd7_tracker_node', + ], + ]; + + protected $expectedResults = [ + [ + 'nid' => '2', + 'published' => '1', + 'changed' => '1421727536', + ] + ]; + + /** + * {@inheritdoc} + */ + protected function setUp() { + $this->databaseContents['tracker_node'] = $this->expectedResults; + parent::setUp(); + } + +} diff --git a/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerUserTest.php b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerUserTest.php new file mode 100644 index 0000000000000000000000000000000000000000..1c0d05df145a9cc1810be9f5e0ff82cbb6da6b2d --- /dev/null +++ b/core/modules/tracker/tests/src/Unit/Plugin/migrate/source/d7/TrackerUserTest.php @@ -0,0 +1,45 @@ +<?php + +/** + * @file + * Contains \Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7\TrackerUserTest. + */ + +namespace Drupal\Tests\tracker\Unit\Plugin\migrate\source\d7; + +use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase; + +/** + * Tests D7 tracker user source plugin. + * + * @group tracker + */ +class TrackerUserTest extends MigrateSqlSourceTestCase { + + const PLUGIN_CLASS = 'Drupal\tracker\Plugin\migrate\source\d7\TrackerUser'; + + protected $migrationConfiguration = [ + 'id' => 'test', + 'source' => [ + 'plugin' => 'd7_tracker_user', + ], + ]; + + protected $expectedResults = [ + [ + 'nid' => '1', + 'uid' => '2', + 'published' => '1', + 'changed' => '1421727536', + ] + ]; + + /** + * {@inheritdoc} + */ + protected function setUp() { + $this->databaseContents['tracker_user'] = $this->expectedResults; + parent::setUp(); + } + +}