Update to Drupal 8.0.0-beta15. For more information, see: https://www.drupal.org/node/2563023

This commit is contained in:
Pantheon Automation 2015-09-04 13:20:09 -07:00 committed by Greg Anderson
parent 2720a9ec4b
commit f3791f1da3
1898 changed files with 54300 additions and 11481 deletions

View file

@ -7,7 +7,7 @@
namespace Drupal\aggregator\Controller;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Controller\ControllerBase;
use Drupal\Core\Datetime\DateFormatter;
use Drupal\aggregator\FeedInterface;
@ -127,8 +127,18 @@ class AggregatorController extends ControllerBase {
$row[] = $this->formatPlural($entity_manager->getStorage('aggregator_item')->getItemCount($feed), '1 item', '@count items');
$last_checked = $feed->getLastCheckedTime();
$refresh_rate = $feed->getRefreshRate();
$row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatTimeDiffSince($last_checked))) : $this->t('never'));
$row[] = ($last_checked && $refresh_rate ? $this->t('@time left', array('@time' => $this->dateFormatter->formatTimeDiffUntil($last_checked + $refresh_rate))) : $this->t('never'));
$row[] = ($last_checked ? $this->t('@time ago', array('@time' => $this->dateFormatter->formatInterval(REQUEST_TIME - $last_checked))) : $this->t('never'));
if (!$last_checked && $refresh_rate) {
$next_update = $this->t('imminently');
}
elseif ($last_checked && $refresh_rate) {
$next_update = $next = $this->t('%time left', array('%time' => $this->dateFormatter->formatInterval($last_checked + $refresh_rate - REQUEST_TIME)));
}
else {
$next_update = $this->t('never');
}
$row[] = $next_update;
$links['edit'] = [
'title' => $this->t('Edit'),
'url' => Url::fromRoute('entity.aggregator_feed.edit_form', ['aggregator_feed' => $feed->id()]),
@ -183,11 +193,11 @@ class AggregatorController extends ControllerBase {
* @param \Drupal\aggregator\FeedInterface $aggregator_feed
* The aggregator feed.
*
* @return string
* The feed label.
* @return array
* The feed label as a render array.
*/
public function feedTitle(FeedInterface $aggregator_feed) {
return SafeMarkup::xssFilter($aggregator_feed->label());
return ['#markup' => $aggregator_feed->label(), '#allowed_tags' => Xss::getHtmlTagList()];
}
}

View file

@ -79,7 +79,8 @@ class FeedViewBuilder extends EntityViewBuilder {
if ($display->getComponent('description')) {
$build[$id]['description'] = array(
'#markup' => aggregator_filter_xss($entity->getDescription()),
'#markup' => $entity->getDescription(),
'#allowed_tags' => _aggregator_allowed_tags(),
'#prefix' => '<div class="feed-description">',
'#suffix' => '</div>',
);

View file

@ -26,7 +26,8 @@ class ItemViewBuilder extends EntityViewBuilder {
if ($display->getComponent('description')) {
$build[$id]['description'] = array(
'#markup' => aggregator_filter_xss($entity->getDescription()),
'#markup' => $entity->getDescription(),
'#allowed_tags' => _aggregator_allowed_tags(),
'#prefix' => '<div class="item-description">',
'#suffix' => '</div>',
);

View file

@ -36,7 +36,8 @@ class AggregatorXSSFormatter extends FormatterBase {
foreach ($items as $delta => $item) {
$elements[$delta] = [
'#type' => 'markup',
'#markup' => aggregator_filter_xss($item->value),
'#markup' => $item->value,
'#allowed_tags' => _aggregator_allowed_tags(),
];
}
return $elements;

View file

@ -9,7 +9,6 @@ namespace Drupal\aggregator\Plugin\views\argument;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Drupal\Component\Utility\SafeMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -60,7 +59,7 @@ class Fid extends NumericArgument {
$feeds = $this->entityManager->getStorage('aggregator_feed')->loadMultiple($this->value);
foreach ($feeds as $feed) {
$titles[] = SafeMarkup::checkPlain($feed->label());
$titles[] = $feed->label();
}
return $titles;
}

View file

@ -9,7 +9,6 @@ namespace Drupal\aggregator\Plugin\views\argument;
use Drupal\Core\Entity\EntityManagerInterface;
use Drupal\views\Plugin\views\argument\NumericArgument;
use Drupal\Component\Utility\SafeMarkup;
use Symfony\Component\DependencyInjection\ContainerInterface;
/**
@ -60,7 +59,7 @@ class Iid extends NumericArgument {
$items = $this->entityManager->getStorage('aggregator_item')->loadMultiple($this->value);
foreach ($items as $feed) {
$titles[] = SafeMarkup::checkPlain($feed->label());
$titles[] = $feed->label();
}
return $titles;
}

View file

@ -8,6 +8,7 @@
namespace Drupal\aggregator\Tests;
use Drupal\aggregator\Entity\Feed;
use Drupal\Component\Utility\Html;
use Drupal\simpletest\WebTestBase;
use Drupal\aggregator\FeedInterface;
@ -28,7 +29,7 @@ abstract class AggregatorTestBase extends WebTestBase {
*
* @var array
*/
public static $modules = array('node', 'aggregator', 'aggregator_test', 'views');
public static $modules = ['block', 'node', 'aggregator', 'aggregator_test', 'views'];
/**
* {@inheritdoc}
@ -43,6 +44,7 @@ abstract class AggregatorTestBase extends WebTestBase {
$this->adminUser = $this->drupalCreateUser(array('access administration pages', 'administer news feeds', 'access news feeds', 'create article content'));
$this->drupalLogin($this->adminUser);
$this->drupalPlaceBlock('local_tasks_block');
}
/**
@ -243,7 +245,7 @@ abstract class AggregatorTestBase extends WebTestBase {
public function getValidOpml(array $feeds) {
// Properly escape URLs so that XML parsers don't choke on them.
foreach ($feeds as &$feed) {
$feed['url[0][value]'] = htmlspecialchars($feed['url[0][value]']);
$feed['url[0][value]'] = Html::escape($feed['url[0][value]']);
}
/**
* Does not have an XML declaration, must pass the parser.

View file

@ -0,0 +1,67 @@
<?php
/**
* @file
* Contains \Drupal\aggregator\Tests\FeedAdminDisplayTest.
*/
namespace Drupal\aggregator\Tests;
/**
* Tests the display of a feed on the feed aggregator list page.
*
* @group aggregator
*/
class FeedAdminDisplayTest extends AggregatorTestBase {
/**
* Tests the "Next update" and "Last update" fields.
*/
public function testFeedUpdateFields() {
// Create scheduled feed.
$scheduled_feed = $this->createFeed(NULL, array('refresh' => '900'));
$this->drupalGet('admin/config/services/aggregator');
$this->assertResponse(200, 'Aggregator feed overview page exists.');
// The scheduled feed shows that it has not been updated yet and is
// scheduled.
$this->assertText('never', 'The scheduled feed has not been updated yet. Last update shows "never".');
$this->assertText('imminently', 'The scheduled feed has not been updated yet. Next update shows "imminently".');
$this->assertNoText('ago', 'The scheduled feed has not been updated yet. Last update does not show "x x ago".');
$this->assertNoText('left', 'The scheduled feed has not been updated yet. Next update does not show "x x left".');
$this->updateFeedItems($scheduled_feed);
$this->drupalGet('admin/config/services/aggregator');
// After the update, an interval should be displayed on both last updated
// and next update.
$this->assertNoText('never', 'The scheduled feed has been updated. Last updated changed.');
$this->assertNoText('imminently', 'The scheduled feed has been updated. Next update changed.');
$this->assertText('ago', 'The scheduled feed been updated. Last update shows "x x ago".');
$this->assertText('left', 'The scheduled feed has been updated. Next update shows "x x left".');
// Delete scheduled feed.
$this->deleteFeed($scheduled_feed);
// Create non-scheduled feed.
$non_scheduled_feed = $this->createFeed(NULL, array('refresh' => '0'));
$this->drupalGet('admin/config/services/aggregator');
// The non scheduled feed shows that it has not been updated yet.
$this->assertText('never', 'The non scheduled feed has not been updated yet. Last update shows "never".');
$this->assertNoText('imminently', 'The non scheduled feed does not show "imminently" as next update.');
$this->assertNoText('ago', 'The non scheduled feed has not been updated. It does not show "x x ago" as last update.');
$this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
$this->updateFeedItems($non_scheduled_feed);
$this->drupalGet('admin/config/services/aggregator');
// After the feed update, we still need to see "never" as next update label.
// Last update will show an interval.
$this->assertNoText('imminently', 'The updated non scheduled feed does not show "imminently" as next update.');
$this->assertText('never', 'The updated non scheduled feed still shows "never" as next update.');
$this->assertText('ago', 'The non scheduled feed has been updated. It shows "x x ago" as last update.');
$this->assertNoText('left', 'The feed is not scheduled. It does not show a timeframe "x x left" for next update.');
}
}

View file

@ -47,9 +47,10 @@ class FeedProcessorPluginTest extends AggregatorTestBase {
*/
public function testDelete() {
$feed = $this->createFeed();
$description = $feed->description->value ?: '';
$this->updateAndDelete($feed, NULL);
// Make sure the feed title is changed.
$entities = entity_load_multiple_by_properties('aggregator_feed', array('description' => $feed->description->value));
$entities = entity_load_multiple_by_properties('aggregator_feed', array('description' => $description));
$this->assertTrue(empty($entities));
}

View file

@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to aggregator.settings.yml.
*
* @group aggregator
* @group migrate_drupal_6
*/
class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase {
@ -31,7 +31,6 @@ class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase {
*/
protected function setUp() {
parent::setUp();
$this->loadDumps(['Variable.php']);
$this->executeMigration('d6_aggregator_settings');
}

View file

@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade variables to aggregator_feed entities.
*
* @group aggregator
* @group migrate_drupal_6
*/
class MigrateAggregatorFeedTest extends MigrateDrupal6TestBase {
@ -25,7 +25,6 @@ class MigrateAggregatorFeedTest extends MigrateDrupal6TestBase {
protected function setUp() {
parent::setUp();
$this->installEntitySchema('aggregator_feed');
$this->loadDumps(['AggregatorFeed.php']);
$this->executeMigration('d6_aggregator_feed');
}

View file

@ -13,7 +13,7 @@ use Drupal\migrate_drupal\Tests\d6\MigrateDrupal6TestBase;
/**
* Upgrade aggregator items.
*
* @group aggregator
* @group migrate_drupal_6
*/
class MigrateAggregatorItemTest extends MigrateDrupal6TestBase {
@ -45,7 +45,6 @@ class MigrateAggregatorItemTest extends MigrateDrupal6TestBase {
));
$entity->enforceIsNew();
$entity->save();
$this->loadDumps(['AggregatorItem.php']);
$this->executeMigration('d6_aggregator_item');
}

View file

@ -24,7 +24,6 @@ class MigrateAggregatorSettingsTest extends MigrateDrupal7TestBase {
protected function setUp() {
parent::setUp();
$this->installConfig(static::$modules);
$this->loadDumps(['Variable.php']);
$this->executeMigration('d7_aggregator_settings');
}

View file

@ -7,18 +7,19 @@
namespace Drupal\aggregator\Tests\Views;
use Drupal\Component\Utility\Xss;
use Drupal\Core\Render\RenderContext;
use Drupal\Core\Url;
use Drupal\views\Views;
use Drupal\views\Tests\ViewTestData;
use Drupal\views\Tests\ViewUnitTestBase;
use Drupal\views\Tests\ViewKernelTestBase;
/**
* Tests basic integration of views data from the aggregator module.
*
* @group aggregator
*/
class IntegrationTest extends ViewUnitTestBase {
class IntegrationTest extends ViewKernelTestBase {
/**
* Modules to install.
@ -121,13 +122,13 @@ class IntegrationTest extends ViewUnitTestBase {
});
$this->assertEqual($output, $expected_link, 'Ensure the right link is generated');
$expected_author = aggregator_filter_xss($items[$iid]->getAuthor());
$expected_author = Xss::filter($items[$iid]->getAuthor(), _aggregator_allowed_tags());
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
return $view->field['author']->advancedRender($row);
});
$this->assertEqual($output, $expected_author, 'Ensure the author got filtered');
$expected_description = aggregator_filter_xss($items[$iid]->getDescription());
$expected_description = Xss::filter($items[$iid]->getDescription(), _aggregator_allowed_tags());
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
return $view->field['description']->advancedRender($row);
});