Further Drupal 8.6.4 changes. Some core files were not committed before a commit...
[yaffs-website] / web / core / modules / aggregator / tests / src / Functional / AggregatorTestBase.php
index ddd98bb82f48fce4426fed8be7376a45e5abef8f..71c19031ac680682bcd22dd86b41cc9d965a093f 100644 (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);
   }