Update core 8.3.0
This commit is contained in:
parent
da7a7918f8
commit
cd7a898e66
6144 changed files with 132297 additions and 87747 deletions
|
@ -75,20 +75,20 @@ class TestProcessor extends AggregatorPluginSettingsBase implements ProcessorInt
|
|||
$processors = $this->config('aggregator.settings')->get('processors');
|
||||
$info = $this->getPluginDefinition();
|
||||
|
||||
$form['processors'][$info['id']] = array(
|
||||
$form['processors'][$info['id']] = [
|
||||
'#type' => 'details',
|
||||
'#title' => t('Test processor settings'),
|
||||
'#description' => $info['description'],
|
||||
'#open' => in_array($info['id'], $processors),
|
||||
);
|
||||
];
|
||||
// Add some dummy settings to verify settingsForm is called.
|
||||
$form['processors'][$info['id']]['dummy_length'] = array(
|
||||
$form['processors'][$info['id']]['dummy_length'] = [
|
||||
'#title' => t('Dummy length setting'),
|
||||
'#type' => 'number',
|
||||
'#min' => 1,
|
||||
'#max' => 1000,
|
||||
'#default_value' => $this->configuration['items']['dummy_length'],
|
||||
);
|
||||
];
|
||||
return $form;
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,379 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\Component\Utility\Html;
|
||||
use Drupal\Tests\BrowserTestBase;
|
||||
use Drupal\aggregator\FeedInterface;
|
||||
|
||||
/**
|
||||
* Defines a base class for testing the Aggregator module.
|
||||
*/
|
||||
abstract class AggregatorTestBase extends BrowserTestBase {
|
||||
|
||||
/**
|
||||
* A user with permission to administer feeds and create content.
|
||||
*
|
||||
* @var \Drupal\user\Entity\User
|
||||
*/
|
||||
protected $adminUser;
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['block', 'node', 'aggregator', 'aggregator_test', 'views'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create an Article node type.
|
||||
if ($this->profile != 'standard') {
|
||||
$this->drupalCreateContentType(['type' => 'article', 'name' => 'Article']);
|
||||
}
|
||||
|
||||
$this->adminUser = $this->drupalCreateUser(['access administration pages', 'administer news feeds', 'access news feeds', 'create article content']);
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalPlaceBlock('local_tasks_block');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an aggregator feed.
|
||||
*
|
||||
* This method simulates the form submission on path aggregator/sources/add.
|
||||
*
|
||||
* @param string $feed_url
|
||||
* (optional) If given, feed will be created with this URL, otherwise
|
||||
* /rss.xml will be used. Defaults to NULL.
|
||||
* @param array $edit
|
||||
* Array with additional form fields.
|
||||
*
|
||||
* @return \Drupal\aggregator\FeedInterface
|
||||
* Full feed object if possible.
|
||||
*
|
||||
* @see getFeedEditArray()
|
||||
*/
|
||||
public function createFeed($feed_url = NULL, array $edit = []) {
|
||||
$edit = $this->getFeedEditArray($feed_url, $edit);
|
||||
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
|
||||
$this->assertText(t('The feed @name has been added.', ['@name' => $edit['title[0][value]']]), format_string('The feed @name has been added.', ['@name' => $edit['title[0][value]']]));
|
||||
|
||||
// Verify that the creation message contains a link to a feed.
|
||||
$view_link = $this->xpath('//div[@class="messages"]//a[contains(@href, :href)]', [':href' => 'aggregator/sources/']);
|
||||
$this->assert(isset($view_link), 'The message area contains a link to a feed');
|
||||
|
||||
$fid = db_query("SELECT fid FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $edit['title[0][value]'], ':url' => $edit['url[0][value]']])->fetchField();
|
||||
$this->assertTrue(!empty($fid), 'The feed found in database.');
|
||||
return Feed::load($fid);
|
||||
}
|
||||
|
||||
/**
|
||||
* Deletes an aggregator feed.
|
||||
*
|
||||
* @param \Drupal\aggregator\FeedInterface $feed
|
||||
* Feed object representing the feed.
|
||||
*/
|
||||
public function deleteFeed(FeedInterface $feed) {
|
||||
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/delete', [], t('Delete'));
|
||||
$this->assertRaw(t('The feed %title has been deleted.', ['%title' => $feed->label()]), 'Feed deleted successfully.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a randomly generated feed edit array.
|
||||
*
|
||||
* @param string $feed_url
|
||||
* (optional) If given, feed will be created with this URL, otherwise
|
||||
* /rss.xml will be used. Defaults to NULL.
|
||||
* @param array $edit
|
||||
* Array with additional form fields.
|
||||
*
|
||||
* @return array
|
||||
* A feed array.
|
||||
*/
|
||||
public function getFeedEditArray($feed_url = NULL, array $edit = []) {
|
||||
$feed_name = $this->randomMachineName(10);
|
||||
if (!$feed_url) {
|
||||
$feed_url = \Drupal::url('view.frontpage.feed_1', [], [
|
||||
'query' => ['feed' => $feed_name],
|
||||
'absolute' => TRUE,
|
||||
]);
|
||||
}
|
||||
$edit += [
|
||||
'title[0][value]' => $feed_name,
|
||||
'url[0][value]' => $feed_url,
|
||||
'refresh' => '900',
|
||||
];
|
||||
return $edit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a randomly generated feed edit object.
|
||||
*
|
||||
* @param string $feed_url
|
||||
* (optional) If given, feed will be created with this URL, otherwise
|
||||
* /rss.xml will be used. Defaults to NULL.
|
||||
* @param array $values
|
||||
* (optional) Default values to initialize object properties with.
|
||||
*
|
||||
* @return \Drupal\aggregator\FeedInterface
|
||||
* A feed object.
|
||||
*/
|
||||
public function getFeedEditObject($feed_url = NULL, array $values = []) {
|
||||
$feed_name = $this->randomMachineName(10);
|
||||
if (!$feed_url) {
|
||||
$feed_url = \Drupal::url('view.frontpage.feed_1', [
|
||||
'query' => ['feed' => $feed_name],
|
||||
'absolute' => TRUE,
|
||||
]);
|
||||
}
|
||||
$values += [
|
||||
'title' => $feed_name,
|
||||
'url' => $feed_url,
|
||||
'refresh' => '900',
|
||||
];
|
||||
return Feed::create($values);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the count of the randomly created feed array.
|
||||
*
|
||||
* @return int
|
||||
* Number of feed items on default feed created by createFeed().
|
||||
*/
|
||||
public function getDefaultFeedItemCount() {
|
||||
// Our tests are based off of rss.xml, so let's find out how many elements should be related.
|
||||
$feed_count = db_query_range('SELECT COUNT(DISTINCT nid) FROM {node_field_data} n WHERE n.promote = 1 AND n.status = 1', 0, $this->config('system.rss')->get('items.limit'))->fetchField();
|
||||
return $feed_count > 10 ? 10 : $feed_count;
|
||||
}
|
||||
|
||||
/**
|
||||
* Updates the feed items.
|
||||
*
|
||||
* This method simulates a click to
|
||||
* admin/config/services/aggregator/update/$fid.
|
||||
*
|
||||
* @param \Drupal\aggregator\FeedInterface $feed
|
||||
* Feed object representing the feed.
|
||||
* @param int|null $expected_count
|
||||
* Expected number of feed items. If omitted no check will happen.
|
||||
*/
|
||||
public function updateFeedItems(FeedInterface $feed, $expected_count = NULL) {
|
||||
// First, let's ensure we can get to the rss xml.
|
||||
$this->drupalGet($feed->getUrl());
|
||||
$this->assertResponse(200, format_string(':url is reachable.', [':url' => $feed->getUrl()]));
|
||||
|
||||
// Attempt to access the update link directly without an access token.
|
||||
$this->drupalGet('admin/config/services/aggregator/update/' . $feed->id());
|
||||
$this->assertResponse(403);
|
||||
|
||||
// Refresh the feed (simulated link click).
|
||||
$this->drupalGet('admin/config/services/aggregator');
|
||||
$this->clickLink('Update items');
|
||||
|
||||
// Ensure we have the right number of items.
|
||||
$result = db_query('SELECT iid FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()]);
|
||||
$feed->items = [];
|
||||
foreach ($result as $item) {
|
||||
$feed->items[] = $item->iid;
|
||||
}
|
||||
|
||||
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)', ['@val1' => $expected_count, '@val2' => $feed->item_count]));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Confirms an item removal from a feed.
|
||||
*
|
||||
* @param \Drupal\aggregator\FeedInterface $feed
|
||||
* Feed object representing the feed.
|
||||
*/
|
||||
public function deleteFeedItems(FeedInterface $feed) {
|
||||
$this->drupalPostForm('admin/config/services/aggregator/delete/' . $feed->id(), [], t('Delete items'));
|
||||
$this->assertRaw(t('The news items from %title have been deleted.', ['%title' => $feed->label()]), 'Feed items deleted.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Adds and deletes feed items and ensure that the count is zero.
|
||||
*
|
||||
* @param \Drupal\aggregator\FeedInterface $feed
|
||||
* Feed object representing the feed.
|
||||
* @param int $expected_count
|
||||
* Expected number of feed items.
|
||||
*/
|
||||
public function updateAndDelete(FeedInterface $feed, $expected_count) {
|
||||
$this->updateFeedItems($feed, $expected_count);
|
||||
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
|
||||
$this->assertTrue($count);
|
||||
$this->deleteFeedItems($feed);
|
||||
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
|
||||
$this->assertTrue($count == 0);
|
||||
}
|
||||
|
||||
/**
|
||||
* Checks whether the feed name and URL are unique.
|
||||
*
|
||||
* @param string $feed_name
|
||||
* String containing the feed name to check.
|
||||
* @param string $feed_url
|
||||
* String containing the feed url to check.
|
||||
*
|
||||
* @return bool
|
||||
* TRUE if feed is unique.
|
||||
*/
|
||||
public function uniqueFeed($feed_name, $feed_url) {
|
||||
$result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $feed_name, ':url' => $feed_url])->fetchField();
|
||||
return (1 == $result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a valid OPML file from an array of feeds.
|
||||
*
|
||||
* @param array $feeds
|
||||
* An array of feeds.
|
||||
*
|
||||
* @return string
|
||||
* Path to valid OPML file.
|
||||
*/
|
||||
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]'] = Html::escape($feed['url[0][value]']);
|
||||
}
|
||||
/**
|
||||
* Does not have an XML declaration, must pass the parser.
|
||||
*/
|
||||
$opml = <<<EOF
|
||||
<opml version="1.0">
|
||||
<head></head>
|
||||
<body>
|
||||
<!-- First feed to be imported. -->
|
||||
<outline text="{$feeds[0]['title[0][value]']}" xmlurl="{$feeds[0]['url[0][value]']}" />
|
||||
|
||||
<!-- Second feed. Test string delimitation and attribute order. -->
|
||||
<outline xmlurl='{$feeds[1]['url[0][value]']}' text='{$feeds[1]['title[0][value]']}'/>
|
||||
|
||||
<!-- Test for duplicate URL and title. -->
|
||||
<outline xmlurl="{$feeds[0]['url[0][value]']}" text="Duplicate URL"/>
|
||||
<outline xmlurl="http://duplicate.title" text="{$feeds[1]['title[0][value]']}"/>
|
||||
|
||||
<!-- Test that feeds are only added with required attributes. -->
|
||||
<outline text="{$feeds[2]['title[0][value]']}" />
|
||||
<outline xmlurl="{$feeds[2]['url[0][value]']}" />
|
||||
</body>
|
||||
</opml>
|
||||
EOF;
|
||||
|
||||
$path = 'public://valid-opml.xml';
|
||||
// Add the UTF-8 byte order mark.
|
||||
return file_unmanaged_save_data(chr(239) . chr(187) . chr(191) . $opml, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an invalid OPML file.
|
||||
*
|
||||
* @return string
|
||||
* Path to invalid OPML file.
|
||||
*/
|
||||
public function getInvalidOpml() {
|
||||
$opml = <<<EOF
|
||||
<opml>
|
||||
<invalid>
|
||||
</opml>
|
||||
EOF;
|
||||
|
||||
$path = 'public://invalid-opml.xml';
|
||||
return file_unmanaged_save_data($opml, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a valid but empty OPML file.
|
||||
*
|
||||
* @return string
|
||||
* Path to empty OPML file.
|
||||
*/
|
||||
public function getEmptyOpml() {
|
||||
$opml = <<<EOF
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<opml version="1.0">
|
||||
<head></head>
|
||||
<body>
|
||||
<outline text="Sample text" />
|
||||
<outline text="Sample text" url="Sample URL" />
|
||||
</body>
|
||||
</opml>
|
||||
EOF;
|
||||
|
||||
$path = 'public://empty-opml.xml';
|
||||
return file_unmanaged_save_data($opml, $path);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a example RSS091 feed.
|
||||
*
|
||||
* @return string
|
||||
* Path to the feed.
|
||||
*/
|
||||
public function getRSS091Sample() {
|
||||
return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/modules/aggregator_test/aggregator_test_rss091.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a example Atom feed.
|
||||
*
|
||||
* @return string
|
||||
* Path to the feed.
|
||||
*/
|
||||
public function getAtomSample() {
|
||||
// The content of this sample ATOM feed is based directly off of the
|
||||
// example provided in RFC 4287.
|
||||
return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/modules/aggregator_test/aggregator_test_atom.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a example feed.
|
||||
*
|
||||
* @return string
|
||||
* Path to the feed.
|
||||
*/
|
||||
public function getHtmlEntitiesSample() {
|
||||
return $GLOBALS['base_url'] . '/' . drupal_get_path('module', 'aggregator') . '/tests/modules/aggregator_test/aggregator_test_title_entities.xml';
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates sample article nodes.
|
||||
*
|
||||
* @param int $count
|
||||
* (optional) The number of nodes to generate. Defaults to five.
|
||||
*/
|
||||
public function createSampleNodes($count = 5) {
|
||||
// Post $count article nodes.
|
||||
for ($i = 0; $i < $count; $i++) {
|
||||
$edit = [];
|
||||
$edit['title[0][value]'] = $this->randomMachineName();
|
||||
$edit['body[0][value]'] = $this->randomMachineName();
|
||||
$this->drupalPostForm('node/add/article', $edit, t('Save'));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable the plugins coming with aggregator_test module.
|
||||
*/
|
||||
public function enableTestPlugins() {
|
||||
$this->config('aggregator.settings')
|
||||
->set('fetcher', 'aggregator_test_fetcher')
|
||||
->set('parser', 'aggregator_test_parser')
|
||||
->set('processors', [
|
||||
'aggregator_test_processor' => 'aggregator_test_processor',
|
||||
'aggregator' => 'aggregator',
|
||||
])
|
||||
->save();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,40 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Delete feed items from a feed.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class DeleteFeedItemTest extends AggregatorTestBase {
|
||||
/**
|
||||
* Tests running "delete items" from 'admin/config/services/aggregator' page.
|
||||
*/
|
||||
public function testDeleteFeedItem() {
|
||||
// Create a bunch of test feeds.
|
||||
$feed_urls = [];
|
||||
// No last-modified, no etag.
|
||||
$feed_urls[] = \Drupal::url('aggregator_test.feed', [], ['absolute' => TRUE]);
|
||||
// Last-modified, but no etag.
|
||||
$feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 1], ['absolute' => TRUE]);
|
||||
// No Last-modified, but etag.
|
||||
$feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 0, 'use_etag' => 1], ['absolute' => TRUE]);
|
||||
// Last-modified and etag.
|
||||
$feed_urls[] = \Drupal::url('aggregator_test.feed', ['use_last_modified' => 1, 'use_etag' => 1], ['absolute' => TRUE]);
|
||||
|
||||
foreach ($feed_urls as $feed_url) {
|
||||
$feed = $this->createFeed($feed_url);
|
||||
// Update and delete items two times in a row to make sure that removal
|
||||
// resets all 'modified' information (modified, etag, hash) and allows for
|
||||
// immediate update. There's 8 items in the feed, but one has an empty
|
||||
// title and is skipped.
|
||||
$this->updateAndDelete($feed, 7);
|
||||
$this->updateAndDelete($feed, 7);
|
||||
$this->updateAndDelete($feed, 7);
|
||||
// Delete feed.
|
||||
$this->deleteFeed($feed);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Delete feed test.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class DeleteFeedTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['block'];
|
||||
|
||||
/**
|
||||
* Deletes a feed and ensures that all of its services are deleted.
|
||||
*/
|
||||
public function testDeleteFeed() {
|
||||
$feed1 = $this->createFeed();
|
||||
$feed2 = $this->createFeed();
|
||||
|
||||
// Place a block for both feeds.
|
||||
$block = $this->drupalPlaceBlock('aggregator_feed_block');
|
||||
$block->getPlugin()->setConfigurationValue('feed', $feed1->id());
|
||||
$block->save();
|
||||
$block2 = $this->drupalPlaceBlock('aggregator_feed_block');
|
||||
$block2->getPlugin()->setConfigurationValue('feed', $feed2->id());
|
||||
$block2->save();
|
||||
|
||||
// Delete feed.
|
||||
$this->deleteFeed($feed1);
|
||||
$this->assertText($feed2->label());
|
||||
$block_storage = $this->container->get('entity.manager')->getStorage('block');
|
||||
$this->assertNull($block_storage->load($block->id()), 'Block for the deleted feed was deleted.');
|
||||
$this->assertEqual($block2->id(), $block_storage->load($block2->id())->id(), 'Block for not deleted feed still exists.');
|
||||
|
||||
// Check feed source.
|
||||
$this->drupalGet('aggregator/sources/' . $feed1->id());
|
||||
$this->assertResponse(404, 'Deleted feed source does not exists.');
|
||||
|
||||
// Check database for feed.
|
||||
$result = db_query("SELECT COUNT(*) FROM {aggregator_feed} WHERE title = :title AND url = :url", [':title' => $feed1->label(), ':url' => $feed1->getUrl()])->fetchField();
|
||||
$this->assertFalse($result, 'Feed not found in database');
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
/**
|
||||
* Tests the Feed entity's cache tags.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class FeedCacheTagsTest extends EntityWithUriCacheTagsTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Give anonymous users permission to access feeds, so that we can verify
|
||||
// the cache tags of cached versions of feeds.
|
||||
$user_role = Role::load(RoleInterface::ANONYMOUS_ID);
|
||||
$user_role->grantPermission('access news feeds');
|
||||
$user_role->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createEntity() {
|
||||
// Create a "Llama" feed.
|
||||
$feed = Feed::create([
|
||||
'title' => 'Llama',
|
||||
'url' => 'https://www.drupal.org/',
|
||||
'refresh' => 900,
|
||||
'checked' => 1389919932,
|
||||
'description' => 'Drupal.org',
|
||||
]);
|
||||
$feed->save();
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,44 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Tests the fetcher plugins functionality and discoverability.
|
||||
*
|
||||
* @group aggregator
|
||||
*
|
||||
* @see \Drupal\aggregator_test\Plugin\aggregator\fetcher\TestFetcher.
|
||||
*/
|
||||
class FeedFetcherPluginTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Enable test plugins.
|
||||
$this->enableTestPlugins();
|
||||
// Create some nodes.
|
||||
$this->createSampleNodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test fetching functionality.
|
||||
*/
|
||||
public function testfetch() {
|
||||
// Create feed with local url.
|
||||
$feed = $this->createFeed();
|
||||
$this->updateFeedItems($feed);
|
||||
$this->assertFalse(empty($feed->items));
|
||||
|
||||
// Delete items and restore checked property to 0.
|
||||
$this->deleteFeedItems($feed);
|
||||
// Change its name and try again.
|
||||
$feed->setTitle('Do not fetch');
|
||||
$feed->save();
|
||||
$this->updateFeedItems($feed);
|
||||
// Fetch should fail due to feed name.
|
||||
$this->assertTrue(empty($feed->items));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\Core\Url;
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
|
||||
/**
|
||||
* Tests the built-in feed parser with valid feed samples.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class FeedParserTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Do not delete old aggregator items during these tests, since our sample
|
||||
// feeds have hardcoded dates in them (which may be expired when this test
|
||||
// is run).
|
||||
$this->config('aggregator.settings')->set('items.expire', AGGREGATOR_CLEAR_NEVER)->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a feed that uses the RSS 0.91 format.
|
||||
*/
|
||||
public function testRSS091Sample() {
|
||||
$feed = $this->createFeed($this->getRSS091Sample());
|
||||
$feed->refreshItems();
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()]));
|
||||
$this->assertText('First example feed item title');
|
||||
$this->assertLinkByHref('http://example.com/example-turns-one');
|
||||
$this->assertText('First example feed item description.');
|
||||
$this->assertRaw('<img src="http://example.com/images/druplicon.png"');
|
||||
|
||||
// Several additional items that include elements over 255 characters.
|
||||
$this->assertRaw("Second example feed item title.");
|
||||
$this->assertText('Long link feed item title');
|
||||
$this->assertText('Long link feed item description');
|
||||
$this->assertLinkByHref('http://example.com/tomorrow/and/tomorrow/and/tomorrow/creeps/in/this/petty/pace/from/day/to/day/to/the/last/syllable/of/recorded/time/and/all/our/yesterdays/have/lighted/fools/the/way/to/dusty/death/out/out/brief/candle/life/is/but/a/walking/shadow/a/poor/player/that/struts/and/frets/his/hour/upon/the/stage/and/is/heard/no/more/it/is/a/tale/told/by/an/idiot/full/of/sound/and/fury/signifying/nothing');
|
||||
$this->assertText('Long author feed item title');
|
||||
$this->assertText('Long author feed item description');
|
||||
$this->assertLinkByHref('http://example.com/long/author');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a feed that uses the Atom format.
|
||||
*/
|
||||
public function testAtomSample() {
|
||||
$feed = $this->createFeed($this->getAtomSample());
|
||||
$feed->refreshItems();
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()]));
|
||||
$this->assertText('Atom-Powered Robots Run Amok');
|
||||
$this->assertLinkByHref('http://example.org/2003/12/13/atom03');
|
||||
$this->assertText('Some text.');
|
||||
$this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', [':link' => 'http://example.org/2003/12/13/atom03'])->fetchField(), 'Atom entry id element is parsed correctly.');
|
||||
|
||||
// Check for second feed entry.
|
||||
$this->assertText('We tried to stop them, but we failed.');
|
||||
$this->assertLinkByHref('http://example.org/2003/12/14/atom03');
|
||||
$this->assertText('Some other text.');
|
||||
$db_guid = db_query('SELECT guid FROM {aggregator_item} WHERE link = :link', [
|
||||
':link' => 'http://example.org/2003/12/14/atom03',
|
||||
])->fetchField();
|
||||
$this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-bbbb-80da344efa6a', $db_guid, 'Atom entry id element is parsed correctly.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests a feed that uses HTML entities in item titles.
|
||||
*/
|
||||
public function testHtmlEntitiesSample() {
|
||||
$feed = $this->createFeed($this->getHtmlEntitiesSample());
|
||||
$feed->refreshItems();
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$this->assertResponse(200, format_string('Feed %name exists.', ['%name' => $feed->label()]));
|
||||
$this->assertRaw("Quote" Amp&");
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that a redirected feed is tracked to its target.
|
||||
*/
|
||||
public function testRedirectFeed() {
|
||||
$redirect_url = Url::fromRoute('aggregator_test.redirect')->setAbsolute()->toString();
|
||||
$feed = Feed::create(['url' => $redirect_url, 'title' => $this->randomMachineName()]);
|
||||
$feed->save();
|
||||
$feed->refreshItems();
|
||||
|
||||
// Make sure that the feed URL was updated correctly.
|
||||
$this->assertEqual($feed->getUrl(), \Drupal::url('aggregator_test.feed', [], ['absolute' => TRUE]));
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests error handling when an invalid feed is added.
|
||||
*/
|
||||
public function testInvalidFeed() {
|
||||
// Simulate a typo in the URL to force a curl exception.
|
||||
$invalid_url = 'http:/www.drupal.org';
|
||||
$feed = Feed::create(['url' => $invalid_url, 'title' => $this->randomMachineName()]);
|
||||
$feed->save();
|
||||
|
||||
// Update the feed. Use the UI to be able to check the message easily.
|
||||
$this->drupalGet('admin/config/services/aggregator');
|
||||
$this->clickLink(t('Update items'));
|
||||
$this->assertRaw(t('The feed from %title seems to be broken because of error', ['%title' => $feed->label()]));
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,67 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
|
||||
/**
|
||||
* Tests the processor plugins functionality and discoverability.
|
||||
*
|
||||
* @group aggregator
|
||||
*
|
||||
* @see \Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor.
|
||||
*/
|
||||
class FeedProcessorPluginTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
// Enable test plugins.
|
||||
$this->enableTestPlugins();
|
||||
// Create some nodes.
|
||||
$this->createSampleNodes();
|
||||
}
|
||||
|
||||
/**
|
||||
* Test processing functionality.
|
||||
*/
|
||||
public function testProcess() {
|
||||
$feed = $this->createFeed();
|
||||
$this->updateFeedItems($feed);
|
||||
foreach ($feed->items as $iid) {
|
||||
$item = Item::load($iid);
|
||||
$this->assertTrue(strpos($item->label(), 'testProcessor') === 0);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Test deleting functionality.
|
||||
*/
|
||||
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', ['description' => $description]);
|
||||
$this->assertTrue(empty($entities));
|
||||
}
|
||||
|
||||
/**
|
||||
* Test post-processing functionality.
|
||||
*/
|
||||
public function testPostProcess() {
|
||||
$feed = $this->createFeed(NULL, ['refresh' => 1800]);
|
||||
$this->updateFeedItems($feed);
|
||||
$feed_id = $feed->id();
|
||||
// Reset entity cache manually.
|
||||
\Drupal::entityManager()->getStorage('aggregator_feed')->resetCache([$feed_id]);
|
||||
// Reload the feed to get new values.
|
||||
$feed = Feed::load($feed_id);
|
||||
// Make sure its refresh rate doubled.
|
||||
$this->assertEqual($feed->getRefreshRate(), 3600);
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,124 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Tests OPML import.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class ImportOpmlTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['block', 'help'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
$admin_user = $this->drupalCreateUser(['administer news feeds', 'access news feeds', 'create article content', 'administer blocks']);
|
||||
$this->drupalLogin($admin_user);
|
||||
}
|
||||
|
||||
/**
|
||||
* Opens OPML import form.
|
||||
*/
|
||||
public function openImportForm() {
|
||||
// Enable the help block.
|
||||
$this->drupalPlaceBlock('help_block', ['region' => 'help']);
|
||||
|
||||
$this->drupalGet('admin/config/services/aggregator/add/opml');
|
||||
$this->assertText('A single OPML document may contain many feeds.', 'Found OPML help text.');
|
||||
$this->assertField('files[upload]', 'Found file upload field.');
|
||||
$this->assertField('remote', 'Found Remote URL field.');
|
||||
$this->assertField('refresh', '', 'Found Refresh field.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits form filled with invalid fields.
|
||||
*/
|
||||
public function validateImportFormFields() {
|
||||
$before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
|
||||
|
||||
$edit = [];
|
||||
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
|
||||
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if no fields are filled.');
|
||||
|
||||
$path = $this->getEmptyOpml();
|
||||
$edit = [
|
||||
'files[upload]' => $path,
|
||||
'remote' => file_create_url($path),
|
||||
];
|
||||
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
|
||||
$this->assertRaw(t('<em>Either</em> upload a file or enter a URL.'), 'Error if both fields are filled.');
|
||||
|
||||
$edit = ['remote' => 'invalidUrl://empty'];
|
||||
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
|
||||
$this->assertText(t('The URL invalidUrl://empty is not valid.'), 'Error if the URL is invalid.');
|
||||
|
||||
$after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
|
||||
$this->assertEqual($before, $after, 'No feeds were added during the three last form submissions.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Submits form with invalid, empty, and valid OPML files.
|
||||
*/
|
||||
protected function submitImportForm() {
|
||||
$before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
|
||||
|
||||
$form['files[upload]'] = $this->getInvalidOpml();
|
||||
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import'));
|
||||
$this->assertText(t('No new feed has been added.'), 'Attempting to upload invalid XML.');
|
||||
|
||||
$edit = ['remote' => file_create_url($this->getEmptyOpml())];
|
||||
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
|
||||
$this->assertText(t('No new feed has been added.'), 'Attempting to load empty OPML from remote URL.');
|
||||
|
||||
$after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
|
||||
$this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.');
|
||||
|
||||
db_delete('aggregator_feed')->execute();
|
||||
|
||||
$feeds[0] = $this->getFeedEditArray();
|
||||
$feeds[1] = $this->getFeedEditArray();
|
||||
$feeds[2] = $this->getFeedEditArray();
|
||||
$edit = [
|
||||
'files[upload]' => $this->getValidOpml($feeds),
|
||||
'refresh' => '900',
|
||||
];
|
||||
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
|
||||
$this->assertRaw(t('A feed with the URL %url already exists.', ['%url' => $feeds[0]['url[0][value]']]), 'Verifying that a duplicate URL was identified');
|
||||
$this->assertRaw(t('A feed named %title already exists.', ['%title' => $feeds[1]['title[0][value]']]), 'Verifying that a duplicate title was identified');
|
||||
|
||||
$after = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
|
||||
$this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
|
||||
|
||||
$feeds_from_db = db_query("SELECT title, url, refresh FROM {aggregator_feed}");
|
||||
$refresh = TRUE;
|
||||
foreach ($feeds_from_db as $feed) {
|
||||
$title[$feed->url] = $feed->title;
|
||||
$url[$feed->title] = $feed->url;
|
||||
$refresh = $refresh && $feed->refresh == 900;
|
||||
}
|
||||
|
||||
$this->assertEqual($title[$feeds[0]['url[0][value]']], $feeds[0]['title[0][value]'], 'First feed was added correctly.');
|
||||
$this->assertEqual($url[$feeds[1]['title[0][value]']], $feeds[1]['url[0][value]'], 'Second feed was added correctly.');
|
||||
$this->assertTrue($refresh, 'Refresh times are correct.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the import of an OPML file.
|
||||
*/
|
||||
public function testOpmlImport() {
|
||||
$this->openImportForm();
|
||||
$this->validateImportFormFields();
|
||||
$this->submitImportForm();
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,83 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\Core\Cache\CacheBackendInterface;
|
||||
use Drupal\system\Tests\Entity\EntityCacheTagsTestBase;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
/**
|
||||
* Tests the Item entity's cache tags.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class ItemCacheTagsTest extends EntityCacheTagsTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Give anonymous users permission to access feeds, so that we can verify
|
||||
// the cache tags of cached versions of feed items.
|
||||
$user_role = Role::load(RoleInterface::ANONYMOUS_ID);
|
||||
$user_role->grantPermission('access news feeds');
|
||||
$user_role->save();
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createEntity() {
|
||||
// Create a "Camelids" feed.
|
||||
$feed = Feed::create([
|
||||
'title' => 'Camelids',
|
||||
'url' => 'https://groups.drupal.org/not_used/167169',
|
||||
'refresh' => 900,
|
||||
'checked' => 1389919932,
|
||||
'description' => 'Drupal Core Group feed',
|
||||
]);
|
||||
$feed->save();
|
||||
|
||||
// Create a "Llama" aggregator feed item.
|
||||
$item = Item::create([
|
||||
'fid' => $feed->id(),
|
||||
'title' => t('Llama'),
|
||||
'path' => 'https://www.drupal.org/',
|
||||
]);
|
||||
$item->save();
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that when creating a feed item, the feed tag is invalidated.
|
||||
*/
|
||||
public function testEntityCreation() {
|
||||
// Create a cache entry that is tagged with a feed cache tag.
|
||||
\Drupal::cache('render')->set('foo', 'bar', CacheBackendInterface::CACHE_PERMANENT, $this->entity->getCacheTags());
|
||||
|
||||
// Verify a cache hit.
|
||||
$this->verifyRenderCache('foo', ['aggregator_feed:1']);
|
||||
|
||||
// Now create a feed item in that feed.
|
||||
Item::create([
|
||||
'fid' => $this->entity->getFeedId(),
|
||||
'title' => t('Llama 2'),
|
||||
'path' => 'https://groups.drupal.org/',
|
||||
])->save();
|
||||
|
||||
// Verify a cache miss.
|
||||
$this->assertFalse(\Drupal::cache('render')->get('foo'), 'Creating a new feed item invalidates the cache tag of the feed.');
|
||||
}
|
||||
|
||||
}
|
|
@ -17,7 +17,7 @@ class FeedValidationTest extends EntityKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('aggregator', 'options');
|
||||
public static $modules = ['aggregator', 'options'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate\d6;
|
||||
|
||||
use Drupal\config\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\SchemaCheckTestTrait;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\d6\MigrateDrupal6TestBase;
|
||||
|
||||
/**
|
||||
|
@ -34,7 +34,7 @@ class MigrateAggregatorConfigsTest extends MigrateDrupal6TestBase {
|
|||
$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(['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'));
|
||||
|
|
|
@ -21,14 +21,14 @@ class IntegrationTest extends ViewsKernelTestBase {
|
|||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = array('aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user');
|
||||
public static $modules = ['aggregator', 'aggregator_test_views', 'system', 'field', 'options', 'user'];
|
||||
|
||||
/**
|
||||
* Views used by this test.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $testViews = array('test_aggregator_items');
|
||||
public static $testViews = ['test_aggregator_items'];
|
||||
|
||||
/**
|
||||
* The entity storage for aggregator items.
|
||||
|
@ -53,7 +53,7 @@ class IntegrationTest extends ViewsKernelTestBase {
|
|||
$this->installEntitySchema('aggregator_item');
|
||||
$this->installEntitySchema('aggregator_feed');
|
||||
|
||||
ViewTestData::createTestViews(get_class($this), array('aggregator_test_views'));
|
||||
ViewTestData::createTestViews(get_class($this), ['aggregator_test_views']);
|
||||
|
||||
$this->itemStorage = $this->container->get('entity.manager')->getStorage('aggregator_item');
|
||||
$this->feedStorage = $this->container->get('entity.manager')->getStorage('aggregator_feed');
|
||||
|
@ -66,19 +66,19 @@ class IntegrationTest extends ViewsKernelTestBase {
|
|||
/** @var \Drupal\Core\Render\RendererInterface $renderer */
|
||||
$renderer = \Drupal::service('renderer');
|
||||
|
||||
$feed = $this->feedStorage->create(array(
|
||||
$feed = $this->feedStorage->create([
|
||||
'title' => $this->randomMachineName(),
|
||||
'url' => 'https://www.drupal.org/',
|
||||
'refresh' => 900,
|
||||
'checked' => 123543535,
|
||||
'description' => $this->randomMachineName(),
|
||||
));
|
||||
]);
|
||||
$feed->save();
|
||||
|
||||
$items = array();
|
||||
$expected = array();
|
||||
$items = [];
|
||||
$expected = [];
|
||||
for ($i = 0; $i < 10; $i++) {
|
||||
$values = array();
|
||||
$values = [];
|
||||
$values['fid'] = $feed->id();
|
||||
$values['timestamp'] = mt_rand(REQUEST_TIME - 10, REQUEST_TIME + 10);
|
||||
$values['title'] = $this->randomMachineName();
|
||||
|
@ -99,13 +99,13 @@ class IntegrationTest extends ViewsKernelTestBase {
|
|||
$view = Views::getView('test_aggregator_items');
|
||||
$this->executeView($view);
|
||||
|
||||
$column_map = array(
|
||||
$column_map = [
|
||||
'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.
|
||||
|
|
|
@ -15,7 +15,7 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
$this->directoryList = array('aggregator' => 'core/modules/aggregator');
|
||||
$this->directoryList = ['aggregator' => 'core/modules/aggregator'];
|
||||
parent::setUp();
|
||||
}
|
||||
|
||||
|
@ -25,19 +25,19 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
* @dataProvider getAggregatorAdminRoutes
|
||||
*/
|
||||
public function testAggregatorAdminLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('aggregator.admin_overview', 'aggregator.admin_settings'),
|
||||
));
|
||||
$this->assertLocalTasks($route, [
|
||||
0 => ['aggregator.admin_overview', 'aggregator.admin_settings'],
|
||||
]);
|
||||
}
|
||||
|
||||
/**
|
||||
* Provides a list of routes to test.
|
||||
*/
|
||||
public function getAggregatorAdminRoutes() {
|
||||
return array(
|
||||
array('aggregator.admin_overview'),
|
||||
array('aggregator.admin_settings'),
|
||||
);
|
||||
return [
|
||||
['aggregator.admin_overview'],
|
||||
['aggregator.admin_settings'],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -46,9 +46,9 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
* @dataProvider getAggregatorSourceRoutes
|
||||
*/
|
||||
public function testAggregatorSourceLocalTasks($route) {
|
||||
$this->assertLocalTasks($route, array(
|
||||
0 => array('entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'),
|
||||
));
|
||||
$this->assertLocalTasks($route, [
|
||||
0 => ['entity.aggregator_feed.canonical', 'entity.aggregator_feed.edit_form', 'entity.aggregator_feed.delete_form'],
|
||||
]);
|
||||
;
|
||||
}
|
||||
|
||||
|
@ -56,10 +56,10 @@ class AggregatorLocalTasksTest extends LocalTaskIntegrationTestBase {
|
|||
* Provides a list of source routes to test.
|
||||
*/
|
||||
public function getAggregatorSourceRoutes() {
|
||||
return array(
|
||||
array('entity.aggregator_feed.canonical'),
|
||||
array('entity.aggregator_feed.edit_form'),
|
||||
);
|
||||
return [
|
||||
['entity.aggregator_feed.canonical'],
|
||||
['entity.aggregator_feed.edit_form'],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -39,20 +39,20 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
*/
|
||||
protected function setUp() {
|
||||
$this->configFactory = $this->getConfigFactoryStub(
|
||||
array(
|
||||
'aggregator.settings' => array(
|
||||
'processors' => array('aggregator_test'),
|
||||
),
|
||||
'aggregator_test.settings' => array(),
|
||||
)
|
||||
[
|
||||
'aggregator.settings' => [
|
||||
'processors' => ['aggregator_test'],
|
||||
],
|
||||
'aggregator_test.settings' => [],
|
||||
]
|
||||
);
|
||||
foreach (array('fetcher', 'parser', 'processor') as $type) {
|
||||
foreach (['fetcher', 'parser', 'processor'] as $type) {
|
||||
$this->managers[$type] = $this->getMockBuilder('Drupal\aggregator\Plugin\AggregatorPluginManager')
|
||||
->disableOriginalConstructor()
|
||||
->getMock();
|
||||
$this->managers[$type]->expects($this->once())
|
||||
->method('getDefinitions')
|
||||
->will($this->returnValue(array('aggregator_test' => array('title' => '', 'description' => ''))));
|
||||
->will($this->returnValue(['aggregator_test' => ['title' => '', 'description' => '']]));
|
||||
}
|
||||
|
||||
$this->settingsForm = new SettingsForm(
|
||||
|
@ -79,8 +79,8 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
|
||||
$test_processor = $this->getMock(
|
||||
'Drupal\aggregator_test\Plugin\aggregator\processor\TestProcessor',
|
||||
array('buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'),
|
||||
array(array(), 'aggregator_test', array('description' => ''), $this->configFactory)
|
||||
['buildConfigurationForm', 'validateConfigurationForm', 'submitConfigurationForm'],
|
||||
[[], 'aggregator_test', ['description' => ''], $this->configFactory]
|
||||
);
|
||||
$test_processor->expects($this->at(0))
|
||||
->method('buildConfigurationForm')
|
||||
|
@ -98,7 +98,7 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
->with($this->equalTo('aggregator_test'))
|
||||
->will($this->returnValue($test_processor));
|
||||
|
||||
$form = $this->settingsForm->buildForm(array(), $form_state);
|
||||
$form = $this->settingsForm->buildForm([], $form_state);
|
||||
$this->settingsForm->validateForm($form, $form_state);
|
||||
$this->settingsForm->submitForm($form, $form_state);
|
||||
}
|
||||
|
|
Reference in a new issue