Commit ede86717 authored by webchick's avatar webchick

Issue #2500469 by svendecabooter, phenaproxima: Migration path for Aggregator 7.x

parent 2acfed87
......@@ -3,7 +3,7 @@ label: Aggregator feeds
migration_tags:
- Drupal 6
source:
plugin: d6_aggregator_feed
plugin: aggregator_feed
process:
fid: fid
title: title
......
......@@ -3,14 +3,13 @@ label: Aggregator items
migration_tags:
- Drupal 6
source:
plugin: d6_aggregator_item
plugin: aggregator_item
process:
iid: iid
fid:
plugin: migration
migration: d6_aggregator_feed
source:
- fid
source: fid
title: title
link: link
author: author
......
id: d7_aggregator_feed
label: Aggregator feeds
migration_tags:
- Drupal 7
source:
plugin: aggregator_feed
process:
fid: fid
title: title
url: url
refresh: refresh
checked: checked
queued: queued
link: link
description: description
image: image
etag: etag
modified: modified
destination:
plugin: entity:aggregator_feed
id: d7_aggregator_item
label: Aggregator items
migration_tags:
- Drupal 7
source:
plugin: aggregator_item
process:
iid: iid
fid:
plugin: migration
migration: d7_aggregator_feed
source: fid
title: title
link: link
author: author
description: description
timestamp: timestamp
guid: guid
destination:
plugin: entity:aggregator_item
migration_dependencies:
required:
- d7_aggregator_feed
......@@ -2,18 +2,18 @@
/**
* @file
* Contains \Drupal\aggregator\Plugin\migrate\source\d6\AggregatorFeed.
* Contains \Drupal\aggregator\Plugin\migrate\source\AggregatorFeed.
*/
namespace Drupal\aggregator\Plugin\migrate\source\d6;
namespace Drupal\aggregator\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 feed source from database.
* Drupal feed source from database.
*
* @MigrateSource(
* id = "d6_aggregator_feed",
* id = "aggregator_feed",
* source_provider = "aggregator"
* )
*/
......@@ -23,30 +23,15 @@ class AggregatorFeed extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
$query = $this->select('aggregator_feed', 'af')
->fields('af', array(
'fid',
'title',
'url',
'refresh',
'checked',
'link',
'description',
'image',
'etag',
'modified',
'block',
));
$query->orderBy('fid');
return $query;
return $this->select('aggregator_feed', 'af')
->fields('af');
}
/**
* {@inheritdoc}
*/
public function fields() {
return array(
$fields = array(
'fid' => $this->t('The feed ID.'),
'title' => $this->t('Title of the feed.'),
'url' => $this->t('URL to the feed.'),
......@@ -59,6 +44,10 @@ public function fields() {
'modified' => $this->t('When the feed was last modified.'),
'block' => $this->t("Number of items to display in the feed's block."),
);
if ($this->getModuleSchemaVersion('system') >= 7000) {
$fields['queued'] = $this->t('Time when this feed was queued for refresh, 0 if not queued.');
}
return $fields;
}
/**
......
......@@ -2,18 +2,18 @@
/**
* @file
* Contains \Drupal\aggregator\Plugin\migrate\source\d6\AggregatorItem.
* Contains \Drupal\aggregator\Plugin\migrate\source\AggregatorItem.
*/
namespace Drupal\aggregator\Plugin\migrate\source\d6;
namespace Drupal\aggregator\Plugin\migrate\source;
use Drupal\migrate_drupal\Plugin\migrate\source\DrupalSqlBase;
/**
* Drupal 6 aggregator item source from database.
* Drupal aggregator item source from database.
*
* @MigrateSource(
* id = "d6_aggregator_item",
* id = "aggregator_item",
* source_provider = "aggregator"
* )
*/
......@@ -23,11 +23,9 @@ class AggregatorItem extends DrupalSqlBase {
* {@inheritdoc}
*/
public function query() {
$query = $this->select('aggregator_item', 'ai')
->fields('ai', array('iid', 'fid', 'title', 'link', 'author',
'description', 'timestamp', 'guid'))
return $this->select('aggregator_item', 'ai')
->fields('ai')
->orderBy('iid');
return $query;
}
/**
......
......@@ -11,7 +11,7 @@
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to aggregator_feed entities.
* Tests migration of aggregator feeds.
*
* @group migrate_drupal_6
*/
......@@ -35,9 +35,8 @@ protected function setUp() {
* Tests migration of aggregator feeds.
*/
public function testAggregatorFeedImport() {
/** @var Feed $feed */
/** @var \Drupal\aggregator\Entity\Feed $feed */
$feed = Feed::load(5);
$this->assertNotNull($feed->uuid());
$this->assertIdentical('Know Your Meme', $feed->title->value);
$this->assertIdentical('en', $feed->language()->getId());
$this->assertIdentical('http://knowyourmeme.com/newsfeed.rss', $feed->url->value);
......
......@@ -11,7 +11,7 @@
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade aggregator items.
* Tests migration of aggregator items.
*
* @group migrate_drupal_6
*/
......@@ -36,7 +36,7 @@ protected function setUp() {
* Test Drupal 6 aggregator item migration to Drupal 8.
*/
public function testAggregatorItem() {
/** @var Item $item */
/** @var \Drupal\aggregator\Entity\Item $item */
$item = Item::load(1);
$this->assertIdentical('1', $item->id());
$this->assertIdentical('5', $item->getFeedId());
......
<?php
/**
* @file
* Contains \Drupal\aggregator\Tests\Migrate\d7\MigrateAggregatorFeedTest.
*/
namespace Drupal\aggregator\Tests\Migrate\d7;
use Drupal\aggregator\Entity\Feed;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
/**
* Test migration to aggregator_feed entities.
*
* @group aggregator
*/
class MigrateAggregatorFeedTest extends MigrateDrupal7TestBase {
public static $modules = array('aggregator');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('aggregator_feed');
$this->executeMigration('d7_aggregator_feed');
}
/**
* Tests migration of aggregator feeds.
*/
public function testAggregatorFeedImport() {
/** @var \Drupal\aggregator\Entity\Feed $feed */
$feed = Feed::load(1);
$this->assertIdentical('Know Your Meme', $feed->title->value);
$this->assertIdentical('en', $feed->language()->getId());
$this->assertIdentical('http://knowyourmeme.com/newsfeed.rss', $feed->url->value);
$this->assertIdentical('900', $feed->refresh->value);
$this->assertIdentical('1387659487', $feed->checked->value);
$this->assertIdentical('0', $feed->queued->value);
$this->assertIdentical('http://knowyourmeme.com', $feed->link->value);
$this->assertIdentical('New items added to the News Feed', $feed->description->value);
$this->assertIdentical('http://b.thumbs.redditmedia.com/harEHsUUZVajabtC.png', $feed->image->value);
$this->assertIdentical('"213cc1365b96c310e92053c5551f0504"', $feed->etag->value);
$this->assertIdentical('0', $feed->modified->value);
}
}
<?php
/**
* @file
* Contains \Drupal\aggregator\Tests\Migrate\d7\MigrateAggregatorItemTest.
*/
namespace Drupal\aggregator\Tests\Migrate\d7;
use Drupal\aggregator\Entity\Item;
use Drupal\migrate_drupal\Tests\d7\MigrateDrupal7TestBase;
/**
* Tests migration of aggregator items.
*
* @group aggregator
*/
class MigrateAggregatorItemTest extends MigrateDrupal7TestBase {
public static $modules = array('aggregator');
/**
* {@inheritdoc}
*/
protected function setUp() {
parent::setUp();
$this->installEntitySchema('aggregator_feed');
$this->installEntitySchema('aggregator_item');
$this->executeMigration('d7_aggregator_feed');
$this->executeMigration('d7_aggregator_item');
}
/**
* Test Drupal 7 aggregator item migration to Drupal 8.
*/
public function testAggregatorItem() {
/** @var \Drupal\aggregator\Entity\Item $item */
$item = Item::load(1);
$this->assertIdentical('1', $item->id());
$this->assertIdentical('1', $item->getFeedId());
$this->assertIdentical('This (three) weeks in Drupal Core - January 10th 2014', $item->label());
$this->assertIdentical('larowlan', $item->getAuthor());
$this->assertIdentical("<h2 id='new'>What's new with Drupal 8?</h2>", $item->getDescription());
$this->assertIdentical('https://groups.drupal.org/node/395218', $item->getLink());
$this->assertIdentical('1389297196', $item->getPostedTime());
$this->assertIdentical('en', $item->language()->getId());
$this->assertIdentical('395218 at https://groups.drupal.org', $item->getGuid());
}
}
......@@ -2,28 +2,26 @@
/**
* @file
* Contains \Drupal\Tests\aggregator\Unit\Plugin\migrate\source\d6\AggregatorItemTest.
* Contains \Drupal\Tests\aggregator\Unit\Plugin\migrate\source\AggregatorItemTest.
*/
namespace Drupal\Tests\aggregator\Unit\Plugin\migrate\source\d6;
namespace Drupal\Tests\aggregator\Unit\Plugin\migrate\source;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D6 aggregator item source plugin.
* Tests aggregator item source plugin.
*
* @group aggregator
*/
class AggregatorItemTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\d6\AggregatorItem';
const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\AggregatorItem';
// The fake Migration configuration entity.
protected $migrationConfiguration = array(
// The ID of the entity, can be any string.
'id' => 'test',
'source' => array(
'plugin' => 'd6_aggregator_item',
'plugin' => 'aggregator_item',
),
);
......@@ -40,16 +38,12 @@ class AggregatorItemTest extends MigrateSqlSourceTestCase {
),
);
protected $databaseContents = array('aggregator_item' => array(array(
'iid' => 1,
'fid' => 1,
'title' => 'This (three) weeks in Drupal Core - January 10th 2014',
'link' => 'https://groups.drupal.org/node/395218',
'author' => 'larowlan',
'description' => "<h2 id='new'>What's new with Drupal 8?</h2>",
'timestamp' => 1389297196,
'guid' => '395218 at https://groups.drupal.org',
),
));
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['aggregator_item'] = $this->expectedResults;
parent::setUp();
}
}
......@@ -16,7 +16,7 @@
*/
class AggregatorFeedTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\d6\AggregatorFeed';
const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\AggregatorFeed';
protected $migrationConfiguration = array(
'id' => 'test',
......@@ -58,9 +58,7 @@ class AggregatorFeedTest extends MigrateSqlSourceTestCase {
* {@inheritdoc}
*/
protected function setUp() {
foreach ($this->expectedResults as $k => $row) {
$this->databaseContents['aggregator_feed'][$k] = $row;
}
$this->databaseContents['aggregator_feed'] = $this->expectedResults;
parent::setUp();
}
......
<?php
/**
* @file
* Contains \Drupal\Tests\aggregator\Unit\Plugin\migrate\source\d7\AggregatorFeedTest.
*/
namespace Drupal\Tests\aggregator\Unit\Plugin\migrate\source\d7;
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
/**
* Tests D7 aggregator feed source plugin.
*
* @group aggregator
*/
class AggregatorFeedTest extends MigrateSqlSourceTestCase {
const PLUGIN_CLASS = 'Drupal\aggregator\Plugin\migrate\source\AggregatorFeed';
protected $migrationConfiguration = array(
'id' => 'test',
'source' => array(
'plugin' => 'd7_aggregator_feed',
),
);
protected $expectedResults = array(
array(
'fid' => 1,
'title' => 'feed title 1',
'url' => 'http://example.com/feed.rss',
'refresh' => 900,
'checked' => 0,
'queued' => 0,
'link' => 'http://example.com',
'description' => 'A vague description',
'image' => '',
'etag' => '',
'modified' => 0,
'block' => 5,
),
array(
'fid' => 2,
'title' => 'feed title 2',
'url' => 'http://example.net/news.rss',
'refresh' => 1800,
'checked' => 0,
'queued' => 0,
'link' => 'http://example.net',
'description' => 'An even more vague description',
'image' => '',
'etag' => '',
'modified' => 0,
'block' => 5,
),
);
/**
* {@inheritdoc}
*/
protected function setUp() {
$this->databaseContents['aggregator_feed'] = $this->expectedResults;
parent::setUp();
}
}
......@@ -116,8 +116,22 @@ public function load() {
'modified',
'block',
))
->execute();
->values(array(
'fid' => '1',
'title' => 'Know Your Meme',
'url' => 'http://knowyourmeme.com/newsfeed.rss',
'refresh' => '900',
'checked' => '1387659487',
'queued' => '0',
'link' => 'http://knowyourmeme.com',
'description' => 'New items added to the News Feed',
'image' => 'http://b.thumbs.redditmedia.com/harEHsUUZVajabtC.png',
'hash' => '1c1e3b6c10ce02f226882aca11709051bba61df2b8eac17ceec5bf74048f1954',
'etag' => '"213cc1365b96c310e92053c5551f0504"',
'modified' => '0',
'block' => '5',
))->execute();
}
}
#8e8447ae5f187d54c5849399ea7f0983
#82e906f4d10bd7d1d4bab524e946df94
......@@ -81,8 +81,17 @@ public function load() {
'timestamp',
'guid',
))
->execute();
->values(array(
'iid' => '1',
'fid' => '1',
'title' => 'This (three) weeks in Drupal Core - January 10th 2014',
'link' => 'https://groups.drupal.org/node/395218',
'author' => 'larowlan',
'description' => "<h2 id='new'>What's new with Drupal 8?</h2>",
'timestamp' => '1389297196',
'guid' => '395218 at https://groups.drupal.org',
))->execute();
}
}
#45d66c3443a69e4c2180a0d653725d10
#256de8124e809501854169d85111cd21
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