composer update

This commit is contained in:
Oliver Davies 2019-01-24 08:00:03 +00:00
parent f6abc3dce2
commit 71dfaca858
1753 changed files with 45274 additions and 14619 deletions

View file

@ -70,9 +70,9 @@ abstract class AggregatorTestBase extends WebTestBase {
$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);
$fids = \Drupal::entityQuery('aggregator_feed')->condition('title', $edit['title[0][value]'])->condition('url', $edit['url[0][value]'])->execute();
$this->assertNotEmpty($fids, 'The feed found in database.');
return Feed::load(array_values($fids)[0]);
}
/**
@ -179,10 +179,10 @@ abstract class AggregatorTestBase extends WebTestBase {
$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()]);
$iids = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->execute();
$feed->items = [];
foreach ($result as $item) {
$feed->items[] = $item->iid;
foreach ($iids as $iid) {
$feed->items[] = $iid;
}
if ($expected_count !== NULL) {
@ -211,11 +211,12 @@ abstract class AggregatorTestBase extends WebTestBase {
* Expected number of feed items.
*/
public function updateAndDelete(FeedInterface $feed, $expected_count) {
$count_query = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->count();
$this->updateFeedItems($feed, $expected_count);
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$count = $count_query->execute();
$this->assertTrue($count);
$this->deleteFeedItems($feed);
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$count = $count_query->execute();
$this->assertTrue($count == 0);
}
@ -231,7 +232,7 @@ abstract class AggregatorTestBase extends WebTestBase {
* 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();
$result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed_name)->condition('url', $feed_url)->count()->execute();
return (1 == $result);
}

View file

@ -20,31 +20,23 @@ class AggregatorCronTest extends AggregatorTestBase {
// Create feed and test basic updating on cron.
$this->createSampleNodes();
$feed = $this->createFeed();
$count_query = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->count();
$this->cronRun();
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
$this->assertEqual(5, $count_query->execute());
$this->deleteFeedItems($feed);
$this->assertEqual(0, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
$this->assertEqual(0, $count_query->execute());
$this->cronRun();
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
$this->assertEqual(5, $count_query->execute());
// Test feed locking when queued for update.
$this->deleteFeedItems($feed);
db_update('aggregator_feed')
->condition('fid', $feed->id())
->fields([
'queued' => REQUEST_TIME,
])
->execute();
$feed->setQueuedTime(REQUEST_TIME)->save();
$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->assertEqual(0, $count_query->execute());
$feed->setQueuedTime(0)->save();
$this->cronRun();
$this->assertEqual(5, db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField());
$this->assertEqual(5, $count_query->execute());
}
}

View file

@ -67,9 +67,9 @@ abstract class AggregatorTestBase extends BrowserTestBase {
$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);
$fids = \Drupal::entityQuery('aggregator_feed')->condition('title', $edit['title[0][value]'])->condition('url', $edit['url[0][value]'])->execute();
$this->assertNotEmpty($fids, 'The feed found in database.');
return Feed::load(array_values($fids)[0]);
}
/**
@ -176,10 +176,10 @@ abstract class AggregatorTestBase extends BrowserTestBase {
$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()]);
$iids = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->execute();
$feed->items = [];
foreach ($result as $item) {
$feed->items[] = $item->iid;
foreach ($iids as $iid) {
$feed->items[] = $iid;
}
if ($expected_count !== NULL) {
@ -208,11 +208,12 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* Expected number of feed items.
*/
public function updateAndDelete(FeedInterface $feed, $expected_count) {
$count_query = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->count();
$this->updateFeedItems($feed, $expected_count);
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$count = $count_query->execute();
$this->assertTrue($count);
$this->deleteFeedItems($feed);
$count = db_query('SELECT COUNT(*) FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$count = $count_query->execute();
$this->assertTrue($count == 0);
}
@ -228,7 +229,7 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* 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();
$result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed_name)->condition('url', $feed_url)->count()->execute();
return (1 == $result);
}

View file

@ -43,8 +43,8 @@ class DeleteFeedTest extends AggregatorTestBase {
$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();
$this->assertFalse($result, 'Feed not found in database');
$result = \Drupal::entityQuery('aggregator_feed')->condition('title', $feed1->label())->condition('url', $feed1->getUrl())->count()->execute();
$this->assertEquals(0, $result, 'Feed not found in database');
}
}

View file

@ -4,6 +4,7 @@ namespace Drupal\Tests\aggregator\Functional;
use Drupal\Core\Url;
use Drupal\aggregator\Entity\Feed;
use Drupal\aggregator\Entity\Item;
/**
* Tests the built-in feed parser with valid feed samples.
@ -57,16 +58,17 @@ class FeedParserTest extends AggregatorTestBase {
$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.');
$iids = \Drupal::entityQuery('aggregator_item')->condition('link', 'http://example.org/2003/12/13/atom03')->execute();
$item = Item::load(array_values($iids)[0]);
$this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-aaaa-80da344efa6a', $item->getGuid(), '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.');
$iids = \Drupal::entityQuery('aggregator_item')->condition('link', 'http://example.org/2003/12/14/atom03')->execute();
$item = Item::load(array_values($iids)[0]);
$this->assertEqual('urn:uuid:1225c695-cfb8-4ebb-bbbb-80da344efa6a', $item->getGuid(), 'Atom entry id element is parsed correctly.');
}
/**

View file

@ -2,6 +2,8 @@
namespace Drupal\Tests\aggregator\Functional;
use Drupal\aggregator\Entity\Feed;
/**
* Tests OPML import.
*
@ -44,7 +46,8 @@ class ImportOpmlTest extends AggregatorTestBase {
* Submits form filled with invalid fields.
*/
public function validateImportFormFields() {
$before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
$count_query = \Drupal::entityQuery('aggregator_feed')->count();
$before = $count_query->execute();
$edit = [];
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $edit, t('Import'));
@ -62,7 +65,7 @@ class ImportOpmlTest extends AggregatorTestBase {
$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();
$after = $count_query->execute();
$this->assertEqual($before, $after, 'No feeds were added during the three last form submissions.');
}
@ -70,7 +73,8 @@ class ImportOpmlTest extends AggregatorTestBase {
* Submits form with invalid, empty, and valid OPML files.
*/
protected function submitImportForm() {
$before = db_query('SELECT COUNT(*) FROM {aggregator_feed}')->fetchField();
$count_query = \Drupal::entityQuery('aggregator_feed')->count();
$before = $count_query->execute();
$form['files[upload]'] = $this->getInvalidOpml();
$this->drupalPostForm('admin/config/services/aggregator/add/opml', $form, t('Import'));
@ -80,10 +84,12 @@ class ImportOpmlTest extends AggregatorTestBase {
$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();
$after = $count_query->execute();
$this->assertEqual($before, $after, 'No feeds were added during the two last form submissions.');
db_delete('aggregator_feed')->execute();
foreach (Feed::loadMultiple() as $feed) {
$feed->delete();
}
$feeds[0] = $this->getFeedEditArray();
$feeds[1] = $this->getFeedEditArray();
@ -96,15 +102,15 @@ class ImportOpmlTest extends AggregatorTestBase {
$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();
$after = $count_query->execute();
$this->assertEqual($after, 2, 'Verifying that two distinct feeds were added.');
$feeds_from_db = db_query("SELECT title, url, refresh FROM {aggregator_feed}");
$feed_entities = Feed::loadMultiple();
$refresh = TRUE;
foreach ($feeds_from_db as $feed) {
$title[$feed->url] = $feed->title;
$url[$feed->title] = $feed->url;
$refresh = $refresh && $feed->refresh == 900;
foreach ($feed_entities as $feed_entity) {
$title[$feed_entity->getUrl()] = $feed_entity->label();
$url[$feed_entity->label()] = $feed_entity->getUrl();
$refresh = $refresh && $feed_entity->getRefreshRate() == 900;
}
$this->assertEqual($title[$feeds[0]['url[0][value]']], $feeds[0]['title[0][value]'], 'First feed was added correctly.');

View file

@ -3,6 +3,7 @@
namespace Drupal\Tests\aggregator\Functional;
use Drupal\aggregator\Entity\Feed;
use Drupal\aggregator\Entity\Item;
/**
* Update feed items from a feed.
@ -43,26 +44,24 @@ class UpdateFeedItemTest extends AggregatorTestBase {
$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);
$fids = \Drupal::entityQuery('aggregator_feed')->condition('url', $edit['url[0][value]'])->execute();
$feed = Feed::load(array_values($fids)[0]);
$feed->refreshItems();
$before = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$iids = \Drupal::entityQuery('aggregator_item')->condition('fid', $feed->id())->execute();
$before = Item::load(array_values($iids)[0])->getPostedTime();
// Sleep for 3 second.
sleep(3);
db_update('aggregator_feed')
->condition('fid', $feed->id())
->fields([
'checked' => 0,
'hash' => '',
'etag' => '',
'modified' => 0,
])
->execute();
$feed
->setLastCheckedTime(0)
->setHash('')
->setEtag('')
->setLastModified(0)
->save();
$feed->refreshItems();
$after = db_query('SELECT timestamp FROM {aggregator_item} WHERE fid = :fid', [':fid' => $feed->id()])->fetchField();
$after = Item::load(array_values($iids)[0])->getPostedTime();
$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