Update to drupal 8.0.0-rc1. For more information, see https://www.drupal.org/node/2582663
This commit is contained in:
parent
eb34d130a8
commit
f32e58e4b1
8476 changed files with 211648 additions and 170042 deletions
|
|
@ -9,7 +9,7 @@ namespace Drupal\aggregator\Controller;
|
|||
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Controller\ControllerBase;
|
||||
use Drupal\Core\Datetime\DateFormatter;
|
||||
use Drupal\Core\Datetime\DateFormatterInterface;
|
||||
use Drupal\aggregator\FeedInterface;
|
||||
use Drupal\Core\Url;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
|
@ -24,17 +24,17 @@ class AggregatorController extends ControllerBase {
|
|||
/**
|
||||
* The date formatter service.
|
||||
*
|
||||
* @var \Drupal\Core\Datetime\DateFormatter
|
||||
* @var \Drupal\Core\Datetime\DateFormatterInterface
|
||||
*/
|
||||
protected $dateFormatter;
|
||||
|
||||
/**
|
||||
* Constructs a \Drupal\aggregator\Controller\AggregatorController object.
|
||||
*
|
||||
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
|
||||
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
|
||||
* The date formatter service.
|
||||
*/
|
||||
public function __construct(DateFormatter $date_formatter) {
|
||||
public function __construct(DateFormatterInterface $date_formatter) {
|
||||
$this->dateFormatter = $date_formatter;
|
||||
}
|
||||
|
||||
|
|
@ -168,7 +168,7 @@ class AggregatorController extends ControllerBase {
|
|||
'#type' => 'table',
|
||||
'#header' => $header,
|
||||
'#rows' => $rows,
|
||||
'#empty' => $this->t('No feeds available. <a href="@link">Add feed</a>.', array('@link' => $this->url('aggregator.feed_add'))),
|
||||
'#empty' => $this->t('No feeds available. <a href=":link">Add feed</a>.', array(':link' => $this->url('aggregator.feed_add'))),
|
||||
);
|
||||
|
||||
return $build;
|
||||
|
|
|
|||
|
|
@ -151,7 +151,7 @@ class Feed extends ContentEntityBase implements FeedInterface {
|
|||
'weight' => -5,
|
||||
))
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->addConstraint('FeedTitle', []);
|
||||
->addConstraint('FeedTitle');
|
||||
|
||||
$fields['langcode'] = BaseFieldDefinition::create('language')
|
||||
->setLabel(t('Language code'))
|
||||
|
|
@ -173,7 +173,7 @@ class Feed extends ContentEntityBase implements FeedInterface {
|
|||
'weight' => -3,
|
||||
))
|
||||
->setDisplayConfigurable('form', TRUE)
|
||||
->addConstraint('FeedUrl', []);
|
||||
->addConstraint('FeedUrl');
|
||||
|
||||
$intervals = array(900, 1800, 3600, 7200, 10800, 21600, 32400, 43200, 64800, 86400, 172800, 259200, 604800, 1209600, 2419200);
|
||||
$period = array_map(array(\Drupal::service('date.formatter'), 'formatInterval'), array_combine($intervals, $intervals));
|
||||
|
|
@ -218,7 +218,7 @@ class Feed extends ContentEntityBase implements FeedInterface {
|
|||
|
||||
$fields['description'] = BaseFieldDefinition::create('string_long')
|
||||
->setLabel(t('Description'))
|
||||
->setDescription(t("The parent website's description that comes from the !description element in the feed.", array('!description' => '<description>')));
|
||||
->setDescription(t("The parent website's description that comes from the @description element in the feed.", array('@description' => '<description>')));
|
||||
|
||||
$fields['image'] = BaseFieldDefinition::create('uri')
|
||||
->setLabel(t('Image'))
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ class FeedAccessControlHandler extends EntityAccessControlHandler {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function checkAccess(EntityInterface $entity, $operation, $langcode, AccountInterface $account) {
|
||||
protected function checkAccess(EntityInterface $entity, $operation, AccountInterface $account) {
|
||||
switch ($operation) {
|
||||
case 'view':
|
||||
return AccessResult::allowedIfHasPermission($account, 'access news feeds');
|
||||
|
|
|
|||
|
|
@ -52,8 +52,8 @@ class FeedViewBuilder extends EntityViewBuilder {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
|
||||
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
|
||||
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
|
||||
parent::buildComponents($build, $entities, $displays, $view_mode);
|
||||
|
||||
foreach ($entities as $id => $entity) {
|
||||
$bundle = $entity->bundle();
|
||||
|
|
@ -69,7 +69,7 @@ class FeedViewBuilder extends EntityViewBuilder {
|
|||
|
||||
$build[$id]['items'] = $this->entityManager
|
||||
->getViewBuilder('aggregator_item')
|
||||
->viewMultiple($items, $view_mode, $langcode);
|
||||
->viewMultiple($items, $view_mode, $entity->language()->getId());
|
||||
|
||||
if ($view_mode == 'full') {
|
||||
// Also add the pager.
|
||||
|
|
@ -114,7 +114,7 @@ class FeedViewBuilder extends EntityViewBuilder {
|
|||
$build[$id]['feed_icon'] = array(
|
||||
'#theme' => 'feed_icon',
|
||||
'#url' => $entity->getUrl(),
|
||||
'#title' => t('!title feed', array('!title' => $entity->label())),
|
||||
'#title' => t('@title feed', array('@title' => $entity->label())),
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ class OpmlFeedAdd extends FormBase {
|
|||
'#title' => $this->t('Update interval'),
|
||||
'#default_value' => 3600,
|
||||
'#options' => $period,
|
||||
'#description' => $this->t('The length of time between feed updates. Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => $this->url('system.status'))),
|
||||
'#description' => $this->t('The length of time between feed updates. Requires a correctly configured <a href=":cron">cron maintenance task</a>.', array(':cron' => $this->url('system.status'))),
|
||||
);
|
||||
|
||||
$form['actions'] = array('#type' => 'actions');
|
||||
|
|
|
|||
|
|
@ -17,8 +17,8 @@ class ItemViewBuilder extends EntityViewBuilder {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function buildComponents(array &$build, array $entities, array $displays, $view_mode, $langcode = NULL) {
|
||||
parent::buildComponents($build, $entities, $displays, $view_mode, $langcode);
|
||||
public function buildComponents(array &$build, array $entities, array $displays, $view_mode) {
|
||||
parent::buildComponents($build, $entities, $displays, $view_mode);
|
||||
|
||||
foreach ($entities as $id => $entity) {
|
||||
$bundle = $entity->bundle();
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ class AggregatorTitleFormatter extends FormatterBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items) {
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = [];
|
||||
|
||||
if ($items->getEntity()->getEntityTypeId() == 'aggregator_feed') {
|
||||
|
|
|
|||
|
|
@ -30,7 +30,7 @@ class AggregatorXSSFormatter extends FormatterBase {
|
|||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function viewElements(FieldItemListInterface $items) {
|
||||
public function viewElements(FieldItemListInterface $items, $langcode) {
|
||||
$elements = [];
|
||||
|
||||
foreach ($items as $delta => $item) {
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\aggregator\Plugin\Validation\Constraint;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint;
|
||||
|
||||
/**
|
||||
* Supports validating feed titles.
|
||||
|
|
@ -17,15 +17,8 @@ use Symfony\Component\Validator\Constraint;
|
|||
* label = @Translation("Feed title", context = "Validation")
|
||||
* )
|
||||
*/
|
||||
class FeedTitleConstraint extends Constraint {
|
||||
class FeedTitleConstraint extends UniqueFieldConstraint {
|
||||
|
||||
public $message = 'A feed named %value already exists. Enter a unique title.';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validatedBy() {
|
||||
return '\Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldValueValidator';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,7 +7,7 @@
|
|||
|
||||
namespace Drupal\aggregator\Plugin\Validation\Constraint;
|
||||
|
||||
use Symfony\Component\Validator\Constraint;
|
||||
use Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldConstraint;
|
||||
|
||||
/**
|
||||
* Supports validating feed URLs.
|
||||
|
|
@ -17,15 +17,8 @@ use Symfony\Component\Validator\Constraint;
|
|||
* label = @Translation("Feed URL", context = "Validation")
|
||||
* )
|
||||
*/
|
||||
class FeedUrlConstraint extends Constraint {
|
||||
class FeedUrlConstraint extends UniqueFieldConstraint {
|
||||
|
||||
public $message = 'A feed with this URL %value already exists. Enter a unique URL.';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function validatedBy() {
|
||||
return '\Drupal\Core\Validation\Plugin\Validation\Constraint\UniqueFieldValueValidator';
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use Drupal\aggregator\FeedInterface;
|
|||
use Drupal\Component\Utility\Unicode;
|
||||
use Drupal\Core\Database\Database;
|
||||
use Drupal\Core\Config\ConfigFactoryInterface;
|
||||
use Drupal\Core\Datetime\DateFormatter;
|
||||
use Drupal\Core\Datetime\DateFormatterInterface;
|
||||
use Drupal\Core\Entity\Query\QueryInterface;
|
||||
use Drupal\Core\Form\ConfigFormBaseTrait;
|
||||
use Drupal\Core\Form\FormStateInterface;
|
||||
|
|
@ -61,7 +61,7 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
|
|||
/**
|
||||
* The date formatter service.
|
||||
*
|
||||
* @var \Drupal\Core\Datetime\DateFormatter
|
||||
* @var \Drupal\Core\Datetime\DateFormatterInterface
|
||||
*/
|
||||
protected $dateFormatter;
|
||||
|
||||
|
|
@ -80,10 +80,10 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
|
|||
* The entity query object for feed items.
|
||||
* @param \Drupal\aggregator\ItemStorageInterface $item_storage
|
||||
* The entity storage for feed items.
|
||||
* @param \Drupal\Core\Datetime\DateFormatter $date_formatter
|
||||
* @param \Drupal\Core\Datetime\DateFormatterInterface $date_formatter
|
||||
* The date formatter service.
|
||||
*/
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, QueryInterface $item_query, ItemStorageInterface $item_storage, DateFormatter $date_formatter) {
|
||||
public function __construct(array $configuration, $plugin_id, $plugin_definition, ConfigFactoryInterface $config, QueryInterface $item_query, ItemStorageInterface $item_storage, DateFormatterInterface $date_formatter) {
|
||||
$this->configFactory = $config;
|
||||
$this->itemStorage = $item_storage;
|
||||
$this->itemQuery = $item_query;
|
||||
|
|
@ -154,7 +154,7 @@ class DefaultProcessor extends AggregatorPluginSettingsBase implements Processor
|
|||
'#title' => t('Discard items older than'),
|
||||
'#default_value' => $config->get('items.expire'),
|
||||
'#options' => $period,
|
||||
'#description' => t('Requires a correctly configured <a href="@cron">cron maintenance task</a>.', array('@cron' => $this->url('system.status'))),
|
||||
'#description' => t('Requires a correctly configured <a href=":cron">cron maintenance task</a>.', array(':cron' => $this->url('system.status'))),
|
||||
);
|
||||
|
||||
$lengths = array(0, 200, 400, 600, 800, 1000, 1200, 1400, 1600, 1800, 2000);
|
||||
|
|
|
|||
|
|
@ -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 @@ class AggregatorFeed extends DrupalSqlBase {
|
|||
'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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -6,6 +6,7 @@
|
|||
*/
|
||||
|
||||
namespace Drupal\aggregator\Tests;
|
||||
use Drupal\Component\Utility\Html;
|
||||
|
||||
/**
|
||||
* Add feed test.
|
||||
|
|
@ -13,6 +14,13 @@ namespace Drupal\aggregator\Tests;
|
|||
* @group aggregator
|
||||
*/
|
||||
class AddFeedTest extends AggregatorTestBase {
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates and ensures that a feed is unique, checks source, and deletes feed.
|
||||
*/
|
||||
|
|
@ -44,6 +52,23 @@ class AddFeedTest extends AggregatorTestBase {
|
|||
$this->deleteFeed($feed);
|
||||
}
|
||||
|
||||
/**
|
||||
* Ensures that the feed label is escaping when rendering the feed icon.
|
||||
*/
|
||||
public function testFeedLabelEscaping() {
|
||||
$feed = $this->createFeed(NULL, ['title[0][value]' => 'Test feed title <script>alert(123);</script>']);
|
||||
$this->checkForMetaRefresh();
|
||||
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$this->assertResponse(200);
|
||||
|
||||
$result = $this->xpath('//h1');
|
||||
$this->assertEqual((string) $result[0], 'Test feed title alert(123);');
|
||||
|
||||
// Ensure the feed icon title is escaped.
|
||||
$this->assertTrue(strpos(str_replace(["\n", "\r"], '', $this->getRawContent()), 'class="feed-icon"> Subscribe to Test feed title <script>alert(123);</script> feed</a>') !== FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests feeds with very long URLs.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -23,6 +23,12 @@ class AggregatorRenderingTest extends AggregatorTestBase {
|
|||
*/
|
||||
public static $modules = array('block', 'test_page_test');
|
||||
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->drupalPlaceBlock('page_title_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds a feed block to the page and checks its links.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ abstract class AggregatorTestBase extends WebTestBase {
|
|||
public function createFeed($feed_url = NULL, array $edit = array()) {
|
||||
$edit = $this->getFeedEditArray($feed_url, $edit);
|
||||
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
|
||||
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed !name has been added.', array('!name' => $edit['title[0][value]'])));
|
||||
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
|
||||
|
||||
$fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", array(':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']))->fetchField();
|
||||
$this->assertTrue(!empty($fid), 'The feed found in database.');
|
||||
|
|
@ -185,7 +185,7 @@ abstract class AggregatorTestBase extends WebTestBase {
|
|||
|
||||
if ($expected_count !== NULL) {
|
||||
$feed->item_count = count($feed->items);
|
||||
$this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (!val1 != !val2)', array('!val1' => $expected_count, '!val2' => $feed->item_count)));
|
||||
$this->assertEqual($expected_count, $feed->item_count, format_string('Total items in feed equal to the total items in database (@val1 != @val2)', array('@val1' => $expected_count, '@val2' => $feed->item_count)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ class AggregatorTitleTest extends KernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('file', 'field', 'options', 'aggregator', 'entity_reference');
|
||||
public static $modules = ['file', 'field', 'options', 'aggregator'];
|
||||
|
||||
/**
|
||||
* The field name that is tested.
|
||||
|
|
|
|||
|
|
@ -20,11 +20,9 @@ class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase {
|
|||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = array('aggregator');
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
|||
|
|
@ -11,13 +11,16 @@ use Drupal\aggregator\Entity\Feed;
|
|||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to aggregator_feed entities.
|
||||
* Tests migration of aggregator feeds.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateAggregatorFeedTest extends MigrateDrupal6TestBase {
|
||||
|
||||
static $modules = array('aggregator');
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -32,9 +35,8 @@ class MigrateAggregatorFeedTest extends MigrateDrupal6TestBase {
|
|||
* 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,13 +11,16 @@ use Drupal\aggregator\Entity\Item;
|
|||
use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade aggregator items.
|
||||
* Tests migration of aggregator items.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateAggregatorItemTest extends MigrateDrupal6TestBase {
|
||||
|
||||
static $modules = array('aggregator');
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
@ -26,33 +29,14 @@ class MigrateAggregatorItemTest extends MigrateDrupal6TestBase {
|
|||
parent::setUp();
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
$this->installEntitySchema('aggregator_item');
|
||||
|
||||
// Add some id mappings for the dependant migrations.
|
||||
$id_mappings = array(
|
||||
'd6_aggregator_feed' => array(
|
||||
array(array(5), array(5)),
|
||||
),
|
||||
);
|
||||
$this->prepareMigrations($id_mappings);
|
||||
|
||||
$entity = entity_create('aggregator_feed', array(
|
||||
'fid' => 5,
|
||||
'title' => 'Drupal Core',
|
||||
'url' => 'https://groups.drupal.org/not_used/167169',
|
||||
'refresh' => 900,
|
||||
'checked' => 1389919932,
|
||||
'description' => 'Drupal Core Group feed',
|
||||
));
|
||||
$entity->enforceIsNew();
|
||||
$entity->save();
|
||||
$this->executeMigration('d6_aggregator_item');
|
||||
$this->executeMigrations(['d6_aggregator_feed', 'd6_aggregator_item']);
|
||||
}
|
||||
|
||||
/**
|
||||
* 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());
|
||||
|
|
|
|||
|
|
@ -0,0 +1,50 @@
|
|||
<?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);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?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());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -37,10 +37,10 @@ class UpdateFeedItemTest extends AggregatorTestBase {
|
|||
);
|
||||
|
||||
$this->drupalGet($edit['url[0][value]']);
|
||||
$this->assertResponse(array(200), format_string('URL !url is accessible', array('!url' => $edit['url[0][value]'])));
|
||||
$this->assertResponse(200);
|
||||
|
||||
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
|
||||
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed !name has been added.', array('!name' => $edit['title[0][value]'])));
|
||||
$this->assertRaw(t('The feed %name has been added.', array('%name' => $edit['title[0][value]'])), format_string('The feed @name has been added.', array('@name' => $edit['title[0][value]'])));
|
||||
|
||||
$fid = db_query("SELECT fid FROM {aggregator_feed} WHERE url = :url", array(':url' => $edit['url[0][value]']))->fetchField();
|
||||
$feed = Feed::load($fid);
|
||||
|
|
@ -62,7 +62,7 @@ class UpdateFeedItemTest extends AggregatorTestBase {
|
|||
$feed->refreshItems();
|
||||
|
||||
$after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', array(':fid' => $feed->id()))->fetchField();
|
||||
$this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (!before === !after)', array('!before' => $before, '!after' => $after)));
|
||||
$this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', array('@before' => $before, '@after' => $after)));
|
||||
|
||||
// Make sure updating items works even after uninstalling a module
|
||||
// that provides the selected plugins.
|
||||
|
|
|
|||
Reference in a new issue