Update Composer, update everything
This commit is contained in:
parent
ea3e94409f
commit
dda5c284b6
19527 changed files with 1135420 additions and 351004 deletions
|
|
@ -5,5 +5,5 @@ package: Testing
|
|||
version: VERSION
|
||||
core: 8.x
|
||||
dependencies:
|
||||
- aggregator
|
||||
- views
|
||||
- drupal:aggregator
|
||||
- drupal:views
|
||||
|
|
|
|||
|
|
@ -0,0 +1,95 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Add feed test.
|
||||
*
|
||||
* @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.
|
||||
*/
|
||||
public function testAddFeed() {
|
||||
$feed = $this->createFeed();
|
||||
$feed->refreshItems();
|
||||
|
||||
// Check feed data.
|
||||
$this->assertUrl(\Drupal::url('aggregator.feed_add', [], ['absolute' => TRUE]), [], 'Directed to correct URL.');
|
||||
$this->assertTrue($this->uniqueFeed($feed->label(), $feed->getUrl()), 'The feed is unique.');
|
||||
|
||||
// Check feed source.
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$this->assertResponse(200, 'Feed source exists.');
|
||||
$this->assertText($feed->label(), 'Page title');
|
||||
$this->assertRaw($feed->getWebsiteUrl());
|
||||
|
||||
// Try to add a duplicate.
|
||||
$edit = [
|
||||
'title[0][value]' => $feed->label(),
|
||||
'url[0][value]' => $feed->getUrl(),
|
||||
'refresh' => '900',
|
||||
];
|
||||
$this->drupalPostForm('aggregator/sources/add', $edit, t('Save'));
|
||||
$this->assertRaw(t('A feed named %feed already exists. Enter a unique title.', ['%feed' => $feed->label()]));
|
||||
$this->assertRaw(t('A feed with this URL %url already exists. Enter a unique URL.', ['%url' => $feed->getUrl()]));
|
||||
|
||||
// Delete feed.
|
||||
$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);
|
||||
|
||||
$this->assertEscaped('Test feed title <script>alert(123);</script>');
|
||||
$this->assertNoRaw('Test feed title <script>alert(123);</script>');
|
||||
|
||||
// Ensure the feed icon title is escaped.
|
||||
$this->assertTrue(strpos(str_replace(["\n", "\r"], '', $this->getSession()->getPage()->getContent()), 'class="feed-icon"> Subscribe to Test feed title <script>alert(123);</script> feed</a>') !== FALSE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests feeds with very long URLs.
|
||||
*/
|
||||
public function testAddLongFeed() {
|
||||
// Create a feed with a URL of > 255 characters.
|
||||
$long_url = "https://www.google.com/search?ix=heb&sourceid=chrome&ie=UTF-8&q=angie+byron#sclient=psy-ab&hl=en&safe=off&source=hp&q=angie+byron&pbx=1&oq=angie+byron&aq=f&aqi=&aql=&gs_sm=3&gs_upl=0l0l0l10534l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=a70b6b1f0abe28d8&biw=1629&bih=889&ix=heb";
|
||||
$feed = $this->createFeed($long_url);
|
||||
$feed->refreshItems();
|
||||
|
||||
// Create a second feed of > 255 characters, where the only difference is
|
||||
// after the 255th character.
|
||||
$long_url_2 = "https://www.google.com/search?ix=heb&sourceid=chrome&ie=UTF-8&q=angie+byron#sclient=psy-ab&hl=en&safe=off&source=hp&q=angie+byron&pbx=1&oq=angie+byron&aq=f&aqi=&aql=&gs_sm=3&gs_upl=0l0l0l10534l0l0l0l0l0l0l0l0ll0l0&bav=on.2,or.r_gc.r_pw.r_cp.,cf.osb&fp=a70b6b1f0abe28d8&biw=1629&bih=889";
|
||||
$feed_2 = $this->createFeed($long_url_2);
|
||||
$feed->refreshItems();
|
||||
|
||||
// Check feed data.
|
||||
$this->assertTrue($this->uniqueFeed($feed->label(), $feed->getUrl()), 'The first long URL feed is unique.');
|
||||
$this->assertTrue($this->uniqueFeed($feed_2->label(), $feed_2->getUrl()), 'The second long URL feed is unique.');
|
||||
|
||||
// Check feed source.
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$this->assertResponse(200, 'Long URL feed source exists.');
|
||||
$this->assertText($feed->label(), 'Page title');
|
||||
|
||||
// Delete feeds.
|
||||
$this->deleteFeed($feed);
|
||||
$this->deleteFeed($feed_2);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Tests aggregator admin pages.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class AggregatorAdminTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* Tests the settings form to ensure the correct default values are used.
|
||||
*/
|
||||
public function testSettingsPage() {
|
||||
$this->drupalGet('admin/config');
|
||||
$this->clickLink('Aggregator');
|
||||
$this->clickLink('Settings');
|
||||
// Make sure that test plugins are present.
|
||||
$this->assertText('Test fetcher');
|
||||
$this->assertText('Test parser');
|
||||
$this->assertText('Test processor');
|
||||
|
||||
// Set new values and enable test plugins.
|
||||
$edit = [
|
||||
'aggregator_allowed_html_tags' => '<a>',
|
||||
'aggregator_summary_items' => 10,
|
||||
'aggregator_clear' => 3600,
|
||||
'aggregator_teaser_length' => 200,
|
||||
'aggregator_fetcher' => 'aggregator_test_fetcher',
|
||||
'aggregator_parser' => 'aggregator_test_parser',
|
||||
'aggregator_processors[aggregator_test_processor]' => 'aggregator_test_processor',
|
||||
];
|
||||
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
|
||||
foreach ($edit as $name => $value) {
|
||||
$this->assertFieldByName($name, $value, format_string('"@name" has correct default value.', ['@name' => $name]));
|
||||
}
|
||||
|
||||
// Check for our test processor settings form.
|
||||
$this->assertText(t('Dummy length setting'));
|
||||
// Change its value to ensure that settingsSubmit is called.
|
||||
$edit = [
|
||||
'dummy_length' => 100,
|
||||
];
|
||||
$this->drupalPostForm('admin/config/services/aggregator/settings', $edit, t('Save configuration'));
|
||||
$this->assertText(t('The configuration options have been saved.'));
|
||||
$this->assertFieldByName('dummy_length', 100, '"dummy_length" has correct default value.');
|
||||
|
||||
// Make sure settings form is still accessible even after uninstalling a module
|
||||
// that provides the selected plugins.
|
||||
$this->container->get('module_installer')->uninstall(['aggregator_test']);
|
||||
$this->resetAll();
|
||||
$this->drupalGet('admin/config/services/aggregator/settings');
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests the overview page.
|
||||
*/
|
||||
public function testOverviewPage() {
|
||||
$feed = $this->createFeed($this->getRSS091Sample());
|
||||
$this->drupalGet('admin/config/services/aggregator');
|
||||
|
||||
$result = $this->xpath('//table/tbody/tr');
|
||||
// Check if the amount of feeds in the overview matches the amount created.
|
||||
$this->assertEqual(1, count($result), 'Created feed is found in the overview');
|
||||
// Check if the fields in the table match with what's expected.
|
||||
$link = $this->xpath('//table/tbody/tr//td[1]/a');
|
||||
$this->assertEquals($feed->label(), $link[0]->getText());
|
||||
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
|
||||
$td = $this->xpath('//table/tbody/tr//td[2]');
|
||||
$this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
|
||||
|
||||
// Update the items of the first feed.
|
||||
$feed->refreshItems();
|
||||
$this->drupalGet('admin/config/services/aggregator');
|
||||
$result = $this->xpath('//table/tbody/tr');
|
||||
// Check if the fields in the table match with what's expected.
|
||||
$link = $this->xpath('//table/tbody/tr//td[1]/a');
|
||||
$this->assertEquals($feed->label(), $link[0]->getText());
|
||||
$count = $this->container->get('entity.manager')->getStorage('aggregator_item')->getItemCount($feed);
|
||||
$td = $this->xpath('//table/tbody/tr//td[2]');
|
||||
$this->assertEquals(\Drupal::translation()->formatPlural($count, '1 item', '@count items'), $td[0]->getText());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||
|
||||
/**
|
||||
* Update feeds on cron.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class AggregatorCronTest extends AggregatorTestBase {
|
||||
|
||||
use CronRunTrait;
|
||||
|
||||
/**
|
||||
* Adds feeds and updates them via cron process.
|
||||
*/
|
||||
public function testCron() {
|
||||
// Create feed and test basic updating on cron.
|
||||
$this->createSampleNodes();
|
||||
$feed = $this->createFeed();
|
||||
$this->cronRun();
|
||||
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
|
||||
$this->deleteFeedItems($feed);
|
||||
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
|
||||
$this->cronRun();
|
||||
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
|
||||
|
||||
// Test feed locking when queued for update.
|
||||
$this->deleteFeedItems($feed);
|
||||
db_update('aggregator_feed')
|
||||
->condition('fid', $feed->id())
|
||||
->fields([
|
||||
'queued' => REQUEST_TIME,
|
||||
])
|
||||
->execute();
|
||||
$this->cronRun();
|
||||
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
|
||||
db_update('aggregator_feed')
|
||||
->condition('fid', $feed->id())
|
||||
->fields([
|
||||
'queued' => 0,
|
||||
])
|
||||
->execute();
|
||||
$this->cronRun();
|
||||
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,154 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\Component\Render\FormattableMarkup;
|
||||
use Drupal\views\Entity\View;
|
||||
|
||||
/**
|
||||
* Tests display of aggregator items on the page.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class AggregatorRenderingTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['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.
|
||||
*/
|
||||
public function testBlockLinks() {
|
||||
// Create feed.
|
||||
$this->createSampleNodes();
|
||||
$feed = $this->createFeed();
|
||||
$this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
|
||||
|
||||
// Need admin user to be able to access block admin.
|
||||
$admin_user = $this->drupalCreateUser([
|
||||
'administer blocks',
|
||||
'access administration pages',
|
||||
'administer news feeds',
|
||||
'access news feeds',
|
||||
]);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
$block = $this->drupalPlaceBlock("aggregator_feed_block", ['label' => 'feed-' . $feed->label()]);
|
||||
|
||||
// Configure the feed that should be displayed.
|
||||
$block->getPlugin()->setConfigurationValue('feed', $feed->id());
|
||||
$block->getPlugin()->setConfigurationValue('block_count', 2);
|
||||
$block->save();
|
||||
|
||||
// Confirm that the block is now being displayed on pages.
|
||||
$this->drupalGet('test-page');
|
||||
$this->assertText($block->label(), 'Feed block is displayed on the page.');
|
||||
|
||||
// Confirm items appear as links.
|
||||
$items = $this->container->get('entity.manager')->getStorage('aggregator_item')->loadByFeed($feed->id(), 1);
|
||||
$links = $this->xpath('//a[@href = :href]', [':href' => reset($items)->getLink()]);
|
||||
$this->assert(isset($links[0]), 'Item link found.');
|
||||
|
||||
// Find the expected read_more link.
|
||||
$href = $feed->url();
|
||||
$links = $this->xpath('//a[@href = :href]', [':href' => $href]);
|
||||
$this->assert(isset($links[0]), format_string('Link to href %href found.', ['%href' => $href]));
|
||||
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
|
||||
$cache_tags = explode(' ', $cache_tags_header);
|
||||
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
|
||||
|
||||
// Visit that page.
|
||||
$this->drupalGet($feed->urlInfo()->getInternalPath());
|
||||
$correct_titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => $feed->label()]);
|
||||
$this->assertFalse(empty($correct_titles), 'Aggregator feed page is available and has the correct title.');
|
||||
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
|
||||
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
|
||||
$this->assertTrue(in_array('aggregator_feed_view', $cache_tags));
|
||||
$this->assertTrue(in_array('aggregator_item_view', $cache_tags));
|
||||
|
||||
// Set the number of news items to 0 to test that the block does not show
|
||||
// up.
|
||||
$block->getPlugin()->setConfigurationValue('block_count', 0);
|
||||
$block->save();
|
||||
// Check that the block is no longer displayed.
|
||||
$this->drupalGet('test-page');
|
||||
$this->assertNoText($block->label(), 'Feed block is not displayed on the page when number of items is set to 0.');
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a feed and checks that feed's page.
|
||||
*/
|
||||
public function testFeedPage() {
|
||||
// Increase the number of items published in the rss.xml feed so we have
|
||||
// enough articles to test paging.
|
||||
$view = View::load('frontpage');
|
||||
$display = &$view->getDisplay('feed_1');
|
||||
$display['display_options']['pager']['options']['items_per_page'] = 30;
|
||||
$view->save();
|
||||
|
||||
// Create a feed with 30 items.
|
||||
$this->createSampleNodes(30);
|
||||
$feed = $this->createFeed();
|
||||
$this->updateFeedItems($feed, 30);
|
||||
|
||||
// Check for presence of an aggregator pager.
|
||||
$this->drupalGet('aggregator');
|
||||
$elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']);
|
||||
$this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
|
||||
|
||||
// Check for sources page title.
|
||||
$this->drupalGet('aggregator/sources');
|
||||
$titles = $this->xpath('//h1[normalize-space(text())=:title]', [':title' => 'Sources']);
|
||||
$this->assertTrue(!empty($titles), 'Source page contains correct title.');
|
||||
|
||||
// Find the expected read_more link on the sources page.
|
||||
$href = $feed->url();
|
||||
$links = $this->xpath('//a[@href = :href]', [':href' => $href]);
|
||||
$this->assertTrue(isset($links[0]), new FormattableMarkup('Link to href %href found.', ['%href' => $href]));
|
||||
$cache_tags_header = $this->drupalGetHeader('X-Drupal-Cache-Tags');
|
||||
$cache_tags = explode(' ', $cache_tags_header);
|
||||
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
|
||||
|
||||
// Check the rss aggregator page as anonymous user.
|
||||
$this->drupalLogout();
|
||||
$this->drupalGet('aggregator/rss');
|
||||
$this->assertResponse(403);
|
||||
|
||||
// Check the rss aggregator page as admin.
|
||||
$this->drupalLogin($this->adminUser);
|
||||
$this->drupalGet('aggregator/rss');
|
||||
$this->assertResponse(200);
|
||||
$this->assertEqual($this->drupalGetHeader('Content-type'), 'application/rss+xml; charset=utf-8');
|
||||
|
||||
// Check the opml aggregator page.
|
||||
$this->drupalGet('aggregator/opml');
|
||||
$content = $this->getSession()->getPage()->getContent();
|
||||
// We can't use Mink xpath queries here because it only supports HTML pages,
|
||||
// but we are dealing with XML here.
|
||||
$xml = simplexml_load_string($content);
|
||||
$attributes = $xml->xpath('//outline[1]')[0]->attributes();
|
||||
$this->assertEquals('rss', $attributes->type);
|
||||
$this->assertEquals($feed->label(), $attributes->text);
|
||||
$this->assertEquals($feed->getUrl(), $attributes->xmlUrl);
|
||||
|
||||
// Check for the presence of a pager.
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$elements = $this->xpath("//ul[contains(@class, :class)]", [':class' => 'pager__items']);
|
||||
$this->assertTrue(!empty($elements), 'Individual source page contains a pager.');
|
||||
$cache_tags = explode(' ', $this->drupalGetHeader('X-Drupal-Cache-Tags'));
|
||||
$this->assertTrue(in_array('aggregator_feed:' . $feed->id(), $cache_tags));
|
||||
$this->assertTrue(in_array('aggregator_feed_view', $cache_tags));
|
||||
$this->assertTrue(in_array('aggregator_item_view', $cache_tags));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -8,6 +8,7 @@ namespace Drupal\Tests\aggregator\Functional;
|
|||
* @group aggregator
|
||||
*/
|
||||
class DeleteFeedItemTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* Tests running "delete items" from 'admin/config/services/aggregator' page.
|
||||
*/
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class DeleteFeedTest extends AggregatorTestBase {
|
|||
|
||||
// Check feed source.
|
||||
$this->drupalGet('aggregator/sources/' . $feed1->id());
|
||||
$this->assertResponse(404, 'Deleted feed source does not exists.');
|
||||
$this->assertResponse(404, 'Deleted feed source does not exist.');
|
||||
|
||||
// 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();
|
||||
|
|
|
|||
|
|
@ -0,0 +1,73 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Tests the display of a feed on the 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, ['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, ['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.');
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function randomMachineName($length = 8) {
|
||||
$value = parent::randomMachineName($length);
|
||||
// See expected values in testFeedUpdateFields().
|
||||
$value = str_replace(['never', 'imminently', 'ago', 'left'], 'x', $value);
|
||||
return $value;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -3,7 +3,7 @@
|
|||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\system\Tests\Entity\EntityWithUriCacheTagsTestBase;
|
||||
use Drupal\Tests\system\Functional\Entity\EntityWithUriCacheTagsTestBase;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,88 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\language\Entity\ConfigurableLanguage;
|
||||
use Drupal\Tests\Traits\Core\CronRunTrait;
|
||||
|
||||
/**
|
||||
* Tests aggregator feeds in multiple languages.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class FeedLanguageTest extends AggregatorTestBase {
|
||||
|
||||
use CronRunTrait;
|
||||
|
||||
/**
|
||||
* Modules to install.
|
||||
*
|
||||
* @var array
|
||||
*/
|
||||
public static $modules = ['language'];
|
||||
|
||||
/**
|
||||
* List of langcodes.
|
||||
*
|
||||
* @var string[]
|
||||
*/
|
||||
protected $langcodes = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUp() {
|
||||
parent::setUp();
|
||||
|
||||
// Create test languages.
|
||||
$this->langcodes = [ConfigurableLanguage::load('en')];
|
||||
for ($i = 1; $i < 3; ++$i) {
|
||||
$language = ConfigurableLanguage::create([
|
||||
'id' => 'l' . $i,
|
||||
'label' => $this->randomString(),
|
||||
]);
|
||||
$language->save();
|
||||
$this->langcodes[$i] = $language->id();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests creation of feeds with a language.
|
||||
*/
|
||||
public function testFeedLanguage() {
|
||||
$admin_user = $this->drupalCreateUser(['administer languages', 'access administration pages', 'administer news feeds', 'access news feeds', 'create article content']);
|
||||
$this->drupalLogin($admin_user);
|
||||
|
||||
// Enable language selection for feeds.
|
||||
$edit['entity_types[aggregator_feed]'] = TRUE;
|
||||
$edit['settings[aggregator_feed][aggregator_feed][settings][language][language_alterable]'] = TRUE;
|
||||
|
||||
$this->drupalPostForm('admin/config/regional/content-language', $edit, t('Save configuration'));
|
||||
|
||||
/** @var \Drupal\aggregator\FeedInterface[] $feeds */
|
||||
$feeds = [];
|
||||
// Create feeds.
|
||||
$feeds[1] = $this->createFeed(NULL, ['langcode[0][value]' => $this->langcodes[1]]);
|
||||
$feeds[2] = $this->createFeed(NULL, ['langcode[0][value]' => $this->langcodes[2]]);
|
||||
|
||||
// Make sure that the language has been assigned.
|
||||
$this->assertEqual($feeds[1]->language()->getId(), $this->langcodes[1]);
|
||||
$this->assertEqual($feeds[2]->language()->getId(), $this->langcodes[2]);
|
||||
|
||||
// Create example nodes to create feed items from and then update the feeds.
|
||||
$this->createSampleNodes();
|
||||
$this->cronRun();
|
||||
|
||||
// Loop over the created feed items and verify that their language matches
|
||||
// the one from the feed.
|
||||
foreach ($feeds as $feed) {
|
||||
/** @var \Drupal\aggregator\ItemInterface[] $items */
|
||||
$items = entity_load_multiple_by_properties('aggregator_item', ['fid' => $feed->id()]);
|
||||
$this->assertTrue(count($items) > 0, 'Feed items were created.');
|
||||
foreach ($items as $item) {
|
||||
$this->assertEqual($item->language()->getId(), $feed->language()->getId());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class FeedHalJsonAnonTest extends FeedHalJsonTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class FeedHalJsonBasicAuthTest extends FeedHalJsonTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,19 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class FeedHalJsonCookieTest extends FeedHalJsonTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,60 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\aggregator\Functional\Rest\FeedResourceTestBase;
|
||||
use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
|
||||
|
||||
abstract class FeedHalJsonTestBase extends FeedResourceTestBase {
|
||||
|
||||
use HalEntityNormalizationTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
$default_normalization = parent::getExpectedNormalizedEntity();
|
||||
|
||||
$normalization = $this->applyHalFieldNormalization($default_normalization);
|
||||
|
||||
return $normalization + [
|
||||
'_links' => [
|
||||
'self' => [
|
||||
'href' => $this->baseUrl . '/aggregator/sources/1?_format=hal_json',
|
||||
],
|
||||
'type' => [
|
||||
'href' => $this->baseUrl . '/rest/type/aggregator_feed/aggregator_feed',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
return parent::getNormalizedPostEntity() + [
|
||||
'_links' => [
|
||||
'type' => [
|
||||
'href' => $this->baseUrl . '/rest/type/aggregator_feed/aggregator_feed',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ItemHalJsonAnonTest extends ItemHalJsonTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ItemHalJsonBasicAuthTest extends ItemHalJsonTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal', 'basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group hal
|
||||
*/
|
||||
class ItemHalJsonCookieTest extends ItemHalJsonTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,100 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Hal;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\Tests\aggregator\Functional\Rest\ItemResourceTestBase;
|
||||
use Drupal\Tests\hal\Functional\EntityResource\HalEntityNormalizationTrait;
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* ResourceTestBase for Item entity.
|
||||
*/
|
||||
abstract class ItemHalJsonTestBase extends ItemResourceTestBase {
|
||||
|
||||
use HalEntityNormalizationTrait;
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['hal'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'hal_json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/hal+json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
$default_normalization = parent::getExpectedNormalizedEntity();
|
||||
$normalization = $this->applyHalFieldNormalization($default_normalization);
|
||||
$feed = Feed::load($this->entity->getFeedId());
|
||||
|
||||
return $normalization + [
|
||||
'_embedded' => [
|
||||
$this->baseUrl . '/rest/relation/aggregator_item/aggregator_item/fid' => [
|
||||
[
|
||||
'_links' => [
|
||||
'self' => [
|
||||
'href' => $this->baseUrl . '/aggregator/sources/1?_format=hal_json',
|
||||
],
|
||||
'type' => [
|
||||
'href' => $this->baseUrl . '/rest/type/aggregator_feed/aggregator_feed',
|
||||
],
|
||||
],
|
||||
'uuid' => [
|
||||
[
|
||||
'value' => $feed->uuid(),
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
],
|
||||
'_links' => [
|
||||
'self' => [
|
||||
'href' => '',
|
||||
],
|
||||
'type' => [
|
||||
'href' => $this->baseUrl . '/rest/type/aggregator_item/aggregator_item',
|
||||
],
|
||||
$this->baseUrl . '/rest/relation/aggregator_item/aggregator_item/fid' => [
|
||||
[
|
||||
'href' => $this->baseUrl . '/aggregator/sources/' . $feed->id() . '?_format=hal_json',
|
||||
],
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
return parent::getNormalizedPostEntity() + [
|
||||
'_links' => [
|
||||
'type' => [
|
||||
'href' => $this->baseUrl . '/rest/type/aggregator_item/aggregator_item',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedCacheContexts() {
|
||||
return [
|
||||
'url.site',
|
||||
'user.permissions',
|
||||
];
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -5,7 +5,7 @@ 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\Tests\system\Functional\Entity\EntityCacheTagsTestBase;
|
||||
use Drupal\user\Entity\Role;
|
||||
use Drupal\user\RoleInterface;
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class FeedJsonAnonTest extends FeedResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class FeedJsonBasicAuthTest extends FeedResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class FeedJsonCookieTest extends FeedResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
|
||||
abstract class FeedResourceTestBase extends EntityResourceTestBase {
|
||||
|
||||
use BcTimestampNormalizerUnixTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $entityTypeId = 'aggregator_feed';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $patchProtectedFieldNames = [];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $uniqueFieldNames = ['url'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpAuthorization($method) {
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
$this->grantPermissionsToTestedRole(['access news feeds']);
|
||||
break;
|
||||
case 'POST':
|
||||
case 'PATCH':
|
||||
case 'DELETE':
|
||||
$this->grantPermissionsToTestedRole(['administer news feeds']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public function createEntity() {
|
||||
$feed = Feed::create();
|
||||
$feed->set('fid', 1)
|
||||
->set('uuid', 'abcdefg')
|
||||
->setTitle('Feed')
|
||||
->setUrl('http://example.com/rss.xml')
|
||||
->setDescription('Feed Resource Test 1')
|
||||
->setRefreshRate(900)
|
||||
->setLastCheckedTime(123456789)
|
||||
->setQueuedTime(123456789)
|
||||
->setWebsiteUrl('http://example.com')
|
||||
->setImage('http://example.com/feed_logo')
|
||||
->setHash('abcdefg')
|
||||
->setEtag('hijklmn')
|
||||
->setLastModified(123456789)
|
||||
->save();
|
||||
|
||||
return $feed;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
return [
|
||||
'uuid' => [
|
||||
[
|
||||
'value' => 'abcdefg',
|
||||
],
|
||||
],
|
||||
'fid' => [
|
||||
[
|
||||
'value' => 1,
|
||||
],
|
||||
],
|
||||
'langcode' => [
|
||||
[
|
||||
'value' => 'en',
|
||||
],
|
||||
],
|
||||
'url' => [
|
||||
[
|
||||
'value' => 'http://example.com/rss.xml',
|
||||
],
|
||||
],
|
||||
'title' => [
|
||||
[
|
||||
'value' => 'Feed',
|
||||
],
|
||||
],
|
||||
'refresh' => [
|
||||
[
|
||||
'value' => 900,
|
||||
],
|
||||
],
|
||||
'checked' => [
|
||||
$this->formatExpectedTimestampItemValues(123456789),
|
||||
],
|
||||
'queued' => [
|
||||
$this->formatExpectedTimestampItemValues(123456789),
|
||||
],
|
||||
'link' => [
|
||||
[
|
||||
'value' => 'http://example.com',
|
||||
],
|
||||
],
|
||||
'description' => [
|
||||
[
|
||||
'value' => 'Feed Resource Test 1',
|
||||
],
|
||||
],
|
||||
'image' => [
|
||||
[
|
||||
'value' => 'http://example.com/feed_logo',
|
||||
],
|
||||
],
|
||||
'hash' => [
|
||||
[
|
||||
'value' => 'abcdefg',
|
||||
],
|
||||
],
|
||||
'etag' => [
|
||||
[
|
||||
'value' => 'hijklmn',
|
||||
],
|
||||
],
|
||||
'modified' => [
|
||||
$this->formatExpectedTimestampItemValues(123456789),
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
return [
|
||||
'title' => [
|
||||
[
|
||||
'value' => 'Feed Resource Post Test',
|
||||
],
|
||||
],
|
||||
'url' => [
|
||||
[
|
||||
'value' => 'http://example.com/feed',
|
||||
],
|
||||
],
|
||||
'refresh' => [
|
||||
[
|
||||
'value' => 900,
|
||||
],
|
||||
],
|
||||
'description' => [
|
||||
[
|
||||
'value' => 'Feed Resource Post Test Description',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedUnauthorizedAccessMessage($method) {
|
||||
if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
|
||||
return parent::getExpectedUnauthorizedAccessMessage($method);
|
||||
}
|
||||
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
return "The 'access news feeds' permission is required.";
|
||||
case 'POST':
|
||||
case 'PATCH':
|
||||
case 'DELETE':
|
||||
return "The 'administer news feeds' permission is required.";
|
||||
default:
|
||||
return parent::getExpectedUnauthorizedAccessMessage($method);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class FeedXmlAnonTest extends FeedResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class FeedXmlBasicAuthTest extends FeedResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class FeedXmlCookieTest extends FeedResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,24 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ItemJsonAnonTest extends ItemResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,34 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ItemJsonBasicAuthTest extends ItemResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ItemJsonCookieTest extends ItemResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'application/json';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,192 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\Tests\rest\Functional\BcTimestampNormalizerUnixTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\EntityResourceTestBase;
|
||||
|
||||
/**
|
||||
* ResourceTestBase for Item entity.
|
||||
*/
|
||||
abstract class ItemResourceTestBase extends EntityResourceTestBase {
|
||||
|
||||
use BcTimestampNormalizerUnixTestTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['aggregator'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $entityTypeId = 'aggregator_item';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $patchProtectedFieldNames = [];
|
||||
|
||||
/**
|
||||
* The Item entity.
|
||||
*
|
||||
* @var \Drupal\aggregator\ItemInterface
|
||||
*/
|
||||
protected $entity;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setUpAuthorization($method) {
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
$this->grantPermissionsToTestedRole(['access news feeds']);
|
||||
break;
|
||||
|
||||
case 'POST':
|
||||
case 'PATCH':
|
||||
case 'DELETE':
|
||||
$this->grantPermissionsToTestedRole(['administer news feeds']);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* {@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" item.
|
||||
$item = Item::create();
|
||||
$item->setTitle('Llama')
|
||||
->setFeedId($feed->id())
|
||||
->setLink('https://www.drupal.org/')
|
||||
->setPostedTime(123456789)
|
||||
->save();
|
||||
|
||||
return $item;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function createAnotherEntity() {
|
||||
$entity = $this->entity->createDuplicate();
|
||||
$entity->setLink('https://www.example.org/');
|
||||
$label_key = $entity->getEntityType()->getKey('label');
|
||||
if ($label_key) {
|
||||
$entity->set($label_key, $entity->label() . '_dupe');
|
||||
}
|
||||
$entity->save();
|
||||
return $entity;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedNormalizedEntity() {
|
||||
$feed = Feed::load($this->entity->getFeedId());
|
||||
|
||||
return [
|
||||
'iid' => [
|
||||
[
|
||||
'value' => 1,
|
||||
],
|
||||
],
|
||||
'langcode' => [
|
||||
[
|
||||
'value' => 'en',
|
||||
],
|
||||
],
|
||||
'fid' => [
|
||||
[
|
||||
'target_id' => 1,
|
||||
'target_type' => 'aggregator_feed',
|
||||
'target_uuid' => $feed->uuid(),
|
||||
'url' => base_path() . 'aggregator/sources/1',
|
||||
],
|
||||
],
|
||||
'title' => [
|
||||
[
|
||||
'value' => 'Llama',
|
||||
],
|
||||
],
|
||||
'link' => [
|
||||
[
|
||||
'value' => 'https://www.drupal.org/',
|
||||
],
|
||||
],
|
||||
'author' => [],
|
||||
'description' => [],
|
||||
'timestamp' => [
|
||||
$this->formatExpectedTimestampItemValues(123456789),
|
||||
],
|
||||
'guid' => [],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getNormalizedPostEntity() {
|
||||
return [
|
||||
'fid' => [
|
||||
[
|
||||
'target_id' => 1,
|
||||
],
|
||||
],
|
||||
'title' => [
|
||||
[
|
||||
'value' => 'Llama',
|
||||
],
|
||||
],
|
||||
'link' => [
|
||||
[
|
||||
'value' => 'https://www.drupal.org/',
|
||||
],
|
||||
],
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedCacheContexts() {
|
||||
// @see ::createEntity()
|
||||
return ['user.permissions'];
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function getExpectedUnauthorizedAccessMessage($method) {
|
||||
if ($this->config('rest.settings')->get('bc_entity_resource_permissions')) {
|
||||
return parent::getExpectedUnauthorizedAccessMessage($method);
|
||||
}
|
||||
|
||||
switch ($method) {
|
||||
case 'GET':
|
||||
return "The 'access news feeds' permission is required.";
|
||||
|
||||
case 'POST':
|
||||
case 'PATCH':
|
||||
case 'DELETE':
|
||||
return "The 'administer news feeds' permission is required.";
|
||||
|
||||
default:
|
||||
return parent::getExpectedUnauthorizedAccessMessage($method);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,26 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\AnonResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ItemXmlAnonTest extends ItemResourceTestBase {
|
||||
|
||||
use AnonResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\BasicAuthResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ItemXmlBasicAuthTest extends ItemResourceTestBase {
|
||||
|
||||
use BasicAuthResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
public static $modules = ['basic_auth'];
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'basic_auth';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,31 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Rest;
|
||||
|
||||
use Drupal\Tests\rest\Functional\CookieResourceTestTrait;
|
||||
use Drupal\Tests\rest\Functional\EntityResource\XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* @group rest
|
||||
*/
|
||||
class ItemXmlCookieTest extends ItemResourceTestBase {
|
||||
|
||||
use CookieResourceTestTrait;
|
||||
use XmlEntityNormalizationQuirksTrait;
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $format = 'xml';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $mimeType = 'text/xml; charset=UTF-8';
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected static $auth = 'cookie';
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,59 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional\Update;
|
||||
|
||||
use Drupal\FunctionalTests\Update\UpdatePathTestBase;
|
||||
|
||||
/**
|
||||
* Tests that node settings are properly updated during database updates.
|
||||
*
|
||||
* @group aggregator
|
||||
* @group legacy
|
||||
*/
|
||||
class AggregatorUpdateTest extends UpdatePathTestBase {
|
||||
|
||||
/**
|
||||
* {@inheritdoc}
|
||||
*/
|
||||
protected function setDatabaseDumpFiles() {
|
||||
$this->databaseDumpFiles = [
|
||||
__DIR__ . '/../../../../../system/tests/fixtures/update/drupal-8.filled.standard.php.gz',
|
||||
];
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the 'Source feed' field is required.
|
||||
*
|
||||
* @see aggregator_update_8200()
|
||||
*/
|
||||
public function testSourceFeedRequired() {
|
||||
// Check that the 'fid' field is not required prior to the update.
|
||||
$field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
|
||||
$this->assertFalse($field_definition->isRequired());
|
||||
|
||||
// Run updates.
|
||||
$this->runUpdates();
|
||||
|
||||
// Check that the 'fid' field is now required.
|
||||
$field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('fid', 'aggregator_item');
|
||||
$this->assertTrue($field_definition->isRequired());
|
||||
}
|
||||
|
||||
/**
|
||||
* Tests that the 'Update interval' field has a default value.
|
||||
*/
|
||||
public function testUpdateIntervalDefaultValue() {
|
||||
// Check that the 'refresh' field does not have a default value prior to the
|
||||
// update.
|
||||
$field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('refresh', 'aggregator_feed');
|
||||
$this->assertSame([], $field_definition->getDefaultValueLiteral());
|
||||
|
||||
// Run updates.
|
||||
$this->runUpdates();
|
||||
|
||||
// Check that the 'refresh' has a default value now.
|
||||
$field_definition = \Drupal::entityDefinitionUpdateManager()->getFieldStorageDefinition('refresh', 'aggregator_feed');
|
||||
$this->assertSame([['value' => 3600]], $field_definition->getDefaultValueLiteral());
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,76 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
use Drupal\aggregator\Entity\Feed;
|
||||
|
||||
/**
|
||||
* Update feed items from a feed.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class UpdateFeedItemTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* Tests running "update items" from 'admin/config/services/aggregator' page.
|
||||
*/
|
||||
public function testUpdateFeedItem() {
|
||||
$this->createSampleNodes();
|
||||
|
||||
// Create a feed and test updating feed items if possible.
|
||||
$feed = $this->createFeed();
|
||||
if (!empty($feed)) {
|
||||
$this->updateFeedItems($feed, $this->getDefaultFeedItemCount());
|
||||
$this->deleteFeedItems($feed);
|
||||
}
|
||||
|
||||
// Delete feed.
|
||||
$this->deleteFeed($feed);
|
||||
|
||||
// Test updating feed items without valid timestamp information.
|
||||
$edit = [
|
||||
'title[0][value]' => "Feed without publish timestamp",
|
||||
'url[0][value]' => $this->getRSS091Sample(),
|
||||
];
|
||||
|
||||
$this->drupalGet($edit['url[0][value]']);
|
||||
$this->assertResponse(200);
|
||||
|
||||
$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 url = :url", [':url' => $edit['url[0][value]']])->fetchField();
|
||||
$feed = Feed::load($fid);
|
||||
|
||||
$feed->refreshItems();
|
||||
$before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
|
||||
|
||||
// Sleep for 3 second.
|
||||
sleep(3);
|
||||
db_update('aggregator_feed')
|
||||
->condition('fid', $feed->id())
|
||||
->fields([
|
||||
'checked' => 0,
|
||||
'hash' => '',
|
||||
'etag' => '',
|
||||
'modified' => 0,
|
||||
])
|
||||
->execute();
|
||||
$feed->refreshItems();
|
||||
|
||||
$after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
|
||||
$this->assertTrue($before === $after, format_string('Publish timestamp of feed item was not updated (@before === @after)', ['@before' => $before, '@after' => $after]));
|
||||
|
||||
// Make sure updating items works even after uninstalling a module
|
||||
// that provides the selected plugins.
|
||||
$this->enableTestPlugins();
|
||||
$this->container->get('module_installer')->uninstall(['aggregator_test']);
|
||||
$this->updateFeedItems($feed);
|
||||
$this->assertResponse(200);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,51 @@
|
|||
<?php
|
||||
|
||||
namespace Drupal\Tests\aggregator\Functional;
|
||||
|
||||
/**
|
||||
* Update feed test.
|
||||
*
|
||||
* @group aggregator
|
||||
*/
|
||||
class UpdateFeedTest extends AggregatorTestBase {
|
||||
|
||||
/**
|
||||
* Creates a feed and attempts to update it.
|
||||
*/
|
||||
public function testUpdateFeed() {
|
||||
$remaining_fields = ['title[0][value]', 'url[0][value]', ''];
|
||||
foreach ($remaining_fields as $same_field) {
|
||||
$feed = $this->createFeed();
|
||||
|
||||
// Get new feed data array and modify newly created feed.
|
||||
$edit = $this->getFeedEditArray();
|
||||
// Change refresh value.
|
||||
$edit['refresh'] = 1800;
|
||||
if (isset($feed->{$same_field}->value)) {
|
||||
$edit[$same_field] = $feed->{$same_field}->value;
|
||||
}
|
||||
$this->drupalPostForm('aggregator/sources/' . $feed->id() . '/configure', $edit, t('Save'));
|
||||
$this->assertText(t('The feed @name has been updated.', ['@name' => $edit['title[0][value]']]), format_string('The feed %name has been updated.', ['%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');
|
||||
|
||||
// Check feed data.
|
||||
$this->assertUrl($feed->url('canonical', ['absolute' => TRUE]));
|
||||
$this->assertTrue($this->uniqueFeed($edit['title[0][value]'], $edit['url[0][value]']), 'The feed is unique.');
|
||||
|
||||
// Check feed source.
|
||||
$this->drupalGet('aggregator/sources/' . $feed->id());
|
||||
$this->assertResponse(200, 'Feed source exists.');
|
||||
$this->assertText($edit['title[0][value]'], 'Page title');
|
||||
|
||||
// Set correct title so deleteFeed() will work.
|
||||
$feed->title = $edit['title[0][value]'];
|
||||
|
||||
// Delete feed.
|
||||
$this->deleteFeed($feed);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
@ -6,7 +6,6 @@ use Drupal\aggregator\Entity\Feed;
|
|||
use Drupal\aggregator\Entity\Item;
|
||||
use Drupal\KernelTests\KernelTestBase;
|
||||
|
||||
|
||||
/**
|
||||
* Tests the aggregator_title formatter.
|
||||
*
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
namespace Drupal\Tests\aggregator\Kernel\Migrate;
|
||||
|
||||
use Drupal\migrate\MigrateException;
|
||||
use Drupal\Tests\migrate_drupal\Kernel\MigrateDrupalTestBase;
|
||||
use Drupal\migrate_drupal\Tests\StubTestTrait;
|
||||
|
||||
|
|
@ -40,18 +39,6 @@ class MigrateAggregatorStubTest extends MigrateDrupalTestBase {
|
|||
* 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');
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ namespace Drupal\Tests\aggregator\Unit\Plugin;
|
|||
|
||||
use Drupal\aggregator\Form\SettingsForm;
|
||||
use Drupal\Core\Form\FormState;
|
||||
use Drupal\Core\Messenger\MessengerInterface;
|
||||
use Drupal\Tests\UnitTestCase;
|
||||
|
||||
/**
|
||||
|
|
@ -55,6 +56,10 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
->will($this->returnValue(['aggregator_test' => ['title' => '', 'description' => '']]));
|
||||
}
|
||||
|
||||
/** @var \Drupal\Core\Messenger\MessengerInterface|\PHPUnit_Framework_MockObject_MockBuilder $messenger */
|
||||
$messenger = $this->createMock(MessengerInterface::class);
|
||||
$messenger->expects($this->any())->method('addMessage');
|
||||
|
||||
$this->settingsForm = new SettingsForm(
|
||||
$this->configFactory,
|
||||
$this->managers['fetcher'],
|
||||
|
|
@ -62,6 +67,7 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
$this->managers['processor'],
|
||||
$this->getStringTranslationStub()
|
||||
);
|
||||
$this->settingsForm->setMessenger($messenger);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -104,10 +110,3 @@ class AggregatorPluginSettingsBaseTest extends UnitTestCase {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
// @todo Delete after https://www.drupal.org/node/2278383 is in.
|
||||
namespace Drupal\Core\Form;
|
||||
|
||||
if (!function_exists('drupal_set_message')) {
|
||||
function drupal_set_message() {}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue