X-Git-Url: http://www.aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Fmodules%2Faggregator%2Ftests%2Fsrc%2FFunctional%2FAggregatorTestBase.php;h=71c19031ac680682bcd22dd86b41cc9d965a093f;hb=1c1cb0980bfa6caf0c24cce671b6bb541dc87583;hp=ddd98bb82f48fce4426fed8be7376a45e5abef8f;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php b/web/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php index ddd98bb82..71c19031a 100644 --- a/web/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php +++ b/web/core/modules/aggregator/tests/src/Functional/AggregatorTestBase.php @@ -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); }