Skip to content
Snippets Groups Projects
Commit ef8e66d3 authored by Angie Byron's avatar Angie Byron
Browse files

Issue #2500535 by quietone, phenaproxima: Upgrade path for Tracker 7.x

parent 191aec42
No related branches found
No related tags found
2 merge requests!7452Issue #1797438. HTML5 validation is preventing form submit and not fully...,!789Issue #3210310: Adjust Database API to remove deprecated Drupal 9 code in Drupal 10
Showing with 366 additions and 2 deletions
......@@ -63,11 +63,11 @@ public function load() {
))
->values(array(
'nid' => '1',
'uid' => '1',
'uid' => '2',
'published' => '1',
'changed' => '1421727536',
))->execute();
}
}
#6fb17f49221d202409a1298360628d70
#6439575c8ff5b85c7c87030634bf6b63
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
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
<?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;
}
}
<?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;
}
}
<?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']);
}
}
<?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']);
}
}
<?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();
}
}
<?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();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment