Update to Drupal 8.1.0. For more information, see https://www.drupal.org/drupal-8.1.0-release-notes
This commit is contained in:
parent
b11a755ba8
commit
c0a0d5a94c
6920 changed files with 64395 additions and 57312 deletions
|
@ -1,8 +1,4 @@
|
|||
<?php
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\aggregator_test\Controller\AggregatorTestRssController.
|
||||
*/
|
||||
|
||||
namespace Drupal\aggregator_test\Controller;
|
||||
|
||||
|
@ -59,7 +55,7 @@ class AggregatorTestRssController extends ControllerBase {
|
|||
$response->headers->set('Content-Type', 'application/rss+xml; charset=utf-8');
|
||||
|
||||
// Read actual feed from file.
|
||||
$file_name = drupal_get_path('module', 'aggregator_test') . '/aggregator_test_rss091.xml';
|
||||
$file_name = __DIR__ . '/../../aggregator_test_rss091.xml';
|
||||
$handle = fopen($file_name, 'r');
|
||||
$feed = fread($handle, filesize($file_name));
|
||||
fclose($handle);
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\aggregator_test\Plugin\aggregator\fetcher\TestFetcher.
|
||||
*/
|
||||
|
||||
namespace Drupal\aggregator_test\Plugin\aggregator\fetcher;
|
||||
|
||||
use Drupal\aggregator\Plugin\FetcherInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\aggregator_test\Plugin\aggregator\parser\TestParser.
|
||||
*/
|
||||
|
||||
namespace Drupal\aggregator_test\Plugin\aggregator\parser;
|
||||
|
||||
use Drupal\aggregator\Plugin\ParserInterface;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor.
|
||||
*/
|
||||
|
||||
namespace Drupal\aggregator_test\Plugin\aggregator\processor;
|
||||
|
||||
use Drupal\aggregator\Plugin\AggregatorPluginSettingsBase;
|
||||
|
|
|
@ -0,0 +1,90 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
|
||||
/**
|
||||
* Tests the aggregator_title formatter.
|
||||
*
|
||||
* @group field
|
||||
*/
|
||||
class AggregatorTitleTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to enable.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['file', 'field', 'options', 'aggregator', 'system'];
|
||||
|
||||
/**
|
||||
* The field name that is tested.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $fieldName;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$this->installConfig(['field']);
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
$this->installEntitySchema('aggregator_item');
|
||||
|
||||
\Drupal::service('router.builder')->rebuild();
|
||||
|
||||
$this->fieldName = 'title';
|
||||
}
|
||||
|
||||
/*
|
||||
* Tests the formatter output.
|
||||
*/
|
||||
public function testStringFormatter() {
|
||||
// Create an aggregator feed.
|
||||
$aggregator_feed = Feed::create([
|
||||
'title' => 'testing title',
|
||||
'url' => 'http://www.example.com',
|
||||
]);
|
||||
$aggregator_feed->save();
|
||||
|
||||
// Create an aggregator feed item.
|
||||
$aggregator_item = Item::create([
|
||||
'title' => 'test title',
|
||||
'fid' => $aggregator_feed->id(),
|
||||
'link' => 'http://www.example.com',
|
||||
]);
|
||||
$aggregator_item->save();
|
||||
|
||||
// Verify aggregator feed title with and without links.
|
||||
$build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => TRUE]]);
|
||||
$result = $this->render($build);
|
||||
|
||||
$this->assertContains('testing title', $result);
|
||||
$this->assertContains('href="' . $aggregator_feed->getUrl() . '"', $result);
|
||||
|
||||
$build = $aggregator_feed->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]);
|
||||
$result = $this->render($build);
|
||||
$this->assertContains('testing title', $result);
|
||||
$this->assertNotContains($aggregator_feed->getUrl(), $result);
|
||||
|
||||
// Verify aggregator item title with and without links.
|
||||
$build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' =>TRUE]]);
|
||||
$result = $this->render($build);
|
||||
|
||||
$this->assertContains('test title', $result);
|
||||
$this->assertContains('href="' . $aggregator_item->getLink() . '"', $result);
|
||||
|
||||
$build = $aggregator_item->{$this->fieldName}->view(['type' => 'aggregator_title', 'settings' => ['display_as_link' => FALSE]]);
|
||||
$result = $this->render($build);
|
||||
$this->assertContains('test title', $result);
|
||||
$this->assertNotContains($aggregator_item->getLink(), $result);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\KernelTests\Core\Entity\EntityKernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests feed validation constraints.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class FeedValidationTest extends EntityKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('aggregator', 'options');
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the feed validation constraints.
|
||||
*/
|
||||
public function testValidation() {
|
||||
// Add feed.
|
||||
$feed = Feed::create([
|
||||
'title' => 'Feed 1',
|
||||
'url' => 'https://www.drupal.org/planet/rss.xml',
|
||||
'refresh' => 900,
|
||||
]);
|
||||
|
||||
$violations = $feed->validate();
|
||||
$this->assertEqual(count($violations), 0);
|
||||
|
||||
$feed->save();
|
||||
|
||||
// Add another feed.
|
||||
/* @var \Drupal\aggregator\FeedInterface $feed */
|
||||
$feed = Feed::create([
|
||||
'title' => 'Feed 1',
|
||||
'url' => 'https://www.drupal.org/planet/rss.xml',
|
||||
'refresh' => 900,
|
||||
]);
|
||||
|
||||
$violations = $feed->validate();
|
||||
|
||||
$this->assertEqual(count($violations), 2);
|
||||
$this->assertEqual($violations[0]->getPropertyPath(), 'title');
|
||||
$this->assertEqual($violations[0]->getMessage(), t('A feed named %value already exists. Enter a unique title.', [
|
||||
'%value' => $feed->label(),
|
||||
]));
|
||||
$this->assertEqual($violations[1]->getPropertyPath(), 'url');
|
||||
$this->assertEqual($violations[1]->getMessage(), t('A feed with this URL %value already exists. Enter a unique URL.', [
|
||||
'%value' => $feed->getUrl(),
|
||||
]));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,41 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel;
|
||||
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
/**
|
||||
* Tests clean handling of an item with a missing feed ID.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class ItemWithoutFeedTest extends KernelTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator', 'options'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
$this->installEntitySchema('aggregator_item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests attempting to create a feed item without a feed.
|
||||
*/
|
||||
public function testEntityCreation() {
|
||||
$entity = Item::create([
|
||||
'title' => t('Llama 2'),
|
||||
'path' => 'https://groups.drupal.org/',
|
||||
]);
|
||||
$violations = $entity->validate();
|
||||
$this->assertCount(1, $violations);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\tests\aggregator\Kernel\Migrate;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
use Drupal\migrate_drupal\Tests\StubTestTrait;
|
||||
|
||||
/**
|
||||
* Test stub creation for aggregator feeds and items.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class MigrateAggregatorStubTest extends MigrateDrupalTestBase {
|
||||
|
||||
use StubTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
$this->installEntitySchema('aggregator_item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creation of aggregator feed stubs.
|
||||
*/
|
||||
public function testFeedStub() {
|
||||
$this->performStubTest('aggregator_feed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creation of aggregator feed items.
|
||||
*/
|
||||
public function testItemStub() {
|
||||
try {
|
||||
// We expect an exception, because there's no feed to reference.
|
||||
$this->performStubTest('aggregator_item');
|
||||
$this->fail('Expected exception has not been thrown.');
|
||||
}
|
||||
catch (MigrateException $e) {
|
||||
$this->assertIdentical($e->getMessage(),
|
||||
'Stubbing failed, unable to generate value for field fid');
|
||||
}
|
||||
|
||||
// The stub should pass when there's a feed to point to.
|
||||
$this->createStub('aggregator_feed');
|
||||
$this->performStubTest('aggregator_item');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,45 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Upgrade variables to aggregator.settings.yml.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase {
|
||||
|
||||
use SchemaCheckTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->executeMigration('d6_aggregator_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of aggregator variables to aggregator.settings.yml.
|
||||
*/
|
||||
public function testAggregatorSettings() {
|
||||
$config = $this->config('aggregator.settings');
|
||||
$this->assertIdentical('aggregator', $config->get('fetcher'));
|
||||
$this->assertIdentical('aggregator', $config->get('parser'));
|
||||
$this->assertIdentical(array('aggregator'), $config->get('processors'));
|
||||
$this->assertIdentical(600, $config->get('items.teaser_length'));
|
||||
$this->assertIdentical('<a> <b> <br /> <dd> <dl> <dt> <em> <i> <li> <ol> <p> <strong> <u> <ul>', $config->get('items.allowed_html'));
|
||||
$this->assertIdentical(9676800, $config->get('items.expire'));
|
||||
$this->assertIdentical(3, $config->get('source.list_max'));
|
||||
$this->assertConfigSchema(\Drupal::service('config.typed'), 'aggregator.settings', $config->get());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of aggregator feeds.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateAggregatorFeedTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
$this->executeMigration('d6_aggregator_feed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of aggregator feeds.
|
||||
*/
|
||||
public function testAggregatorFeedImport() {
|
||||
/** @var \Drupal\aggregator\Entity\Feed $feed */
|
||||
$feed = Feed::load(5);
|
||||
$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,48 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of aggregator items.
|
||||
*
|
||||
* @group migrate_drupal_6
|
||||
*/
|
||||
class MigrateAggregatorItemTest extends MigrateDrupal6TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
$this->installEntitySchema('aggregator_item');
|
||||
$this->executeMigrations(['d6_aggregator_feed', 'd6_aggregator_item']);
|
||||
}
|
||||
|
||||
/**
|
||||
* Test Drupal 6 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('5', $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());
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,54 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Test migration to aggregator_feed entities.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateAggregatorFeedTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['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\FeedInterface $feed */
|
||||
$feed = Feed::load(1);
|
||||
$this->assertIdentical('Know Your Meme', $feed->label());
|
||||
$this->assertIdentical('en', $feed->language()->getId());
|
||||
$this->assertIdentical('http://knowyourmeme.com/newsfeed.rss', $feed->getUrl());
|
||||
$this->assertIdentical('900', $feed->getRefreshRate());
|
||||
// The feed's last checked time can change as the fixture is updated, so
|
||||
// assert that its format is correct.
|
||||
$checked_time = $feed->getLastCheckedTime();
|
||||
$this->assertTrue(is_numeric($checked_time));
|
||||
$this->assertTrue($checked_time > 1000000000);
|
||||
$this->assertIdentical('0', $feed->getQueuedTime());
|
||||
$this->assertIdentical('http://knowyourmeme.com', $feed->link->value);
|
||||
$this->assertIdentical('New items added to the News Feed', $feed->getDescription());
|
||||
$this->assertNull($feed->getImage());
|
||||
// As with getLastCheckedTime(), the etag can change as the fixture is
|
||||
// updated normally, so assert that its format is correct.
|
||||
$this->assertTrue(preg_match('/^"[a-z0-9]{32}"$/', $feed->getEtag()));
|
||||
$this->assertIdentical('0', $feed->getLastModified());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,58 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of aggregator items.
|
||||
*
|
||||
* @group migrate_drupal_7
|
||||
*/
|
||||
class MigrateAggregatorItemTest extends MigrateDrupal7TestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['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() {
|
||||
// Since the feed items can change as the fixture is updated normally,
|
||||
// assert all migrated feed items against the values in the fixture.
|
||||
$items = $this->sourceDatabase
|
||||
->select('aggregator_item', 'ai')
|
||||
->fields('ai')
|
||||
->execute();
|
||||
|
||||
foreach ($items as $original) {
|
||||
/** @var \Drupal\aggregator\ItemInterface $item */
|
||||
$item = Item::load($original->iid);
|
||||
$this->assertIdentical($original->fid, $item->getFeedId());
|
||||
$this->assertIdentical($original->title, $item->label());
|
||||
// If $original->author is an empty string, getAuthor() returns NULL so
|
||||
// we need to use assertEqual() here.
|
||||
$this->assertEqual($original->author, $item->getAuthor());
|
||||
$this->assertIdentical($original->description, $item->getDescription());
|
||||
$this->assertIdentical($original->link, $item->getLink());
|
||||
$this->assertIdentical($original->timestamp, $item->getPostedTime());
|
||||
$this->assertIdentical('en', $item->language()->getId());
|
||||
$this->assertIdentical($original->guid, $item->getGuid());
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate\d7;
|
||||
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d7\MigrateDrupal7TestBase;
|
||||
|
||||
/**
|
||||
* Tests migration of Aggregator's variables to configuration.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class MigrateAggregatorSettingsTest extends MigrateDrupal7TestBase {
|
||||
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
$this->installConfig(static::$modules);
|
||||
$this->executeMigration('d7_aggregator_settings');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests migration of Aggregator variables to configuration.
|
||||
*/
|
||||
public function testMigration() {
|
||||
$config = \Drupal::config('aggregator.settings')->get();
|
||||
$this->assertIdentical('aggregator', $config['fetcher']);
|
||||
$this->assertIdentical('aggregator', $config['parser']);
|
||||
$this->assertIdentical(['aggregator'], $config['processors']);
|
||||
$this->assertIdentical('<p> <div> <a>', $config['items']['allowed_html']);
|
||||
$this->assertIdentical(500, $config['items']['teaser_length']);
|
||||
$this->assertIdentical(86400, $config['items']['expire']);
|
||||
$this->assertIdentical(6, $config['source']['list_max']);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,47 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Views;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase;
|
||||
|
||||
/**
|
||||
* Tests base field access in Views for the aggregator_feed entity.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class AggregatorFeedViewsFieldAccessTest extends FieldFieldAccessTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator', 'entity_test', 'options'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks access for aggregator_feed fields.
|
||||
*/
|
||||
public function testAggregatorFeedFields() {
|
||||
$feed = Feed::create([
|
||||
'title' => 'Drupal org',
|
||||
'url' => 'https://www.drupal.org/rss.xml',
|
||||
'link' => 'https://www.drupal.org/rss.xml',
|
||||
]);
|
||||
$feed->save();
|
||||
|
||||
// @todo Expand the test coverage in https://www.drupal.org/node/2464635
|
||||
|
||||
// $this->assertFieldAccess('aggregator_feed', 'title', $feed->label());
|
||||
$this->assertFieldAccess('aggregator_feed', 'langcode', $feed->language()->getName());
|
||||
$this->assertFieldAccess('aggregator_feed', 'url', $feed->getUrl());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Views;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\Tests\views\Kernel\Handler\FieldFieldAccessTestBase;
|
||||
|
||||
/**
|
||||
* Tests base field access in Views for the aggregator_item entity.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class AggregatorItemViewsFieldAccessTest extends FieldFieldAccessTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator', 'entity_test', 'options'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp($import_test_views);
|
||||
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
$this->installEntitySchema('aggregator_item');
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks access for aggregator_item fields.
|
||||
*/
|
||||
public function testAggregatorItemFields() {
|
||||
$feed = Feed::create([
|
||||
'title' => 'Drupal org',
|
||||
'url' => 'https://www.drupal.org/rss.xml',
|
||||
]);
|
||||
$feed->save();
|
||||
$item = Item::create([
|
||||
'title' => 'Test title',
|
||||
'fid' => $feed->id(),
|
||||
'description' => 'Test description',
|
||||
]);
|
||||
|
||||
$item->save();
|
||||
|
||||
// @todo Expand the test coverage in https://www.drupal.org/node/2464635
|
||||
|
||||
$this->assertFieldAccess('aggregator_item', 'title', $item->getTitle());
|
||||
$this->assertFieldAccess('aggregator_item', 'langcode', $item->language()->getName());
|
||||
$this->assertFieldAccess('aggregator_item', 'description', $item->getDescription());
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,134 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Views;
|
||||
|
||||
use Drupal\Component\Utility\Xss;
|
||||
use Drupal\Core\Render\RenderContext;
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\Tests\views\Kernel\ViewsKernelTestBase;
|
||||
use Drupal\views\Views;
|
||||
use Drupal\views\Tests\ViewTestData;
|
||||
|
||||
/**
|
||||
* Tests basic integration of views data from the aggregator module.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class IntegrationTest extends ViewsKernelTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user');
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_aggregator_items');
|
||||
|
||||
/**
|
||||
* The entity storage for aggregator items.
|
||||
*
|
||||
* @var \Drupal\aggregator\ItemStorage
|
||||
*/
|
||||
protected $itemStorage;
|
||||
|
||||
/**
|
||||
* The entity storage for aggregator feeds.
|
||||
*
|
||||
* @var \Drupal\aggregator\FeedStorage
|
||||
*/
|
||||
protected $feedStorage;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp($import_test_views = TRUE) {
|
||||
parent::setUp();
|
||||
|
||||
$this->installEntitySchema('aggregator_item');
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('aggregator_test_views'));
|
||||
|
||||
$this->itemStorage = $this->container->get('entity.manager')->getStorage('aggregator_item');
|
||||
$this->feedStorage = $this->container->get('entity.manager')->getStorage('aggregator_feed');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests basic aggregator_item view.
|
||||
*/
|
||||
public function testAggregatorItemView() {
|
||||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = \Drupal::service('renderer');
|
||||
|
||||
$feed = $this->feedStorage->create(array(
|
||||
'title' => $this->randomMachineName(),
|
||||
'url' => 'https://www.drupal.org/',
|
||||
'refresh' => 900,
|
||||
'checked' => 123543535,
|
||||
'description' => $this->randomMachineName(),
|
||||
));
|
||||
$feed->save();
|
||||
|
||||
$items = array();
|
||||
$expected = array();
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$values = array();
|
||||
$values['fid'] = $feed->id();
|
||||
$values['timestamp'] = mt_rand(REQUEST_TIME - 10, REQUEST_TIME + 10);
|
||||
$values['title'] = $this->randomMachineName();
|
||||
$values['description'] = $this->randomMachineName();
|
||||
// Add a image to ensure that the sanitizing can be tested below.
|
||||
$values['author'] = $this->randomMachineName() . '<img src="http://example.com/example.png" \>"';
|
||||
$values['link'] = 'https://www.drupal.org/node/' . mt_rand(1000, 10000);
|
||||
$values['guid'] = $this->randomString();
|
||||
|
||||
$aggregator_item = $this->itemStorage->create($values);
|
||||
$aggregator_item->save();
|
||||
$items[$aggregator_item->id()] = $aggregator_item;
|
||||
|
||||
$values['iid'] = $aggregator_item->id();
|
||||
$expected[] = $values;
|
||||
}
|
||||
|
||||
$view = Views::getView('test_aggregator_items');
|
||||
$this->executeView($view);
|
||||
|
||||
$column_map = array(
|
||||
'iid' => 'iid',
|
||||
'title' => 'title',
|
||||
'aggregator_item_timestamp' => 'timestamp',
|
||||
'description' => 'description',
|
||||
'aggregator_item_author' => 'author',
|
||||
);
|
||||
$this->assertIdenticalResultset($view, $expected, $column_map);
|
||||
|
||||
// Ensure that the rendering of the linked title works as expected.
|
||||
foreach ($view->result as $row) {
|
||||
$iid = $view->field['iid']->getValue($row);
|
||||
$expected_link = \Drupal::l($items[$iid]->getTitle(), Url::fromUri($items[$iid]->getLink(), ['absolute' => TRUE]));
|
||||
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
|
||||
return $view->field['title']->advancedRender($row);
|
||||
});
|
||||
$this->assertEqual($output, $expected_link->getGeneratedLink(), 'Ensure the right link is generated');
|
||||
|
||||
$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 = Xss::filter($items[$iid]->getDescription(), _aggregator_allowed_tags());
|
||||
$output = $renderer->executeInRenderContext(new RenderContext(), function () use ($view, $row) {
|
||||
return $view->field['description']->advancedRender($row);
|
||||
});
|
||||
$this->assertEqual($output, $expected_description, 'Ensure the author got filtered');
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\aggregator\Unit\Menu\AggregatorLocalTasksTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\aggregator\Unit\Menu;
|
||||
|
||||
use Drupal\Tests\Core\Menu\LocalTaskIntegrationTestBase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\aggregator\Unit\Plugin\AggregatorPluginSettingsBaseTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\aggregator\Unit\Plugin {
|
||||
|
||||
use Drupal\aggregator\Form\SettingsForm;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\aggregator\Unit\Plugin\migrate\source\AggregatorItemTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\aggregator\Unit\Plugin\migrate\source;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Contains \Drupal\Tests\aggregator\Unit\Plugin\migrate\source\d6\AggregatorFeedTest.
|
||||
*/
|
||||
|
||||
namespace Drupal\Tests\aggregator\Unit\Plugin\migrate\source\d6;
|
||||
|
||||
use Drupal\Tests\migrate\Unit\MigrateSqlSourceTestCase;
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<?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;
|
||||
|
|
Reference in a new issue