Commit 8471aac3 authored by catch's avatar catch

Issue #3014771 by anya_m, voleger, andypost, mondrake, goodboy: Replace...

Issue #3014771 by anya_m, voleger, andypost, mondrake, goodboy: Replace queryRange call in AggregatorTestBase classes
parent 10722cd8
......@@ -6,7 +6,7 @@
use Drupal\aggregator\Entity\Feed;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Database;
use Drupal\node\NodeInterface;
use Drupal\simpletest\WebTestBase;
use Drupal\aggregator\FeedInterface;
......@@ -154,9 +154,16 @@ public function getFeedEditObject($feed_url = NULL, array $values = []) {
* 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 = Database::getConnection()->queryRange('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;
// Our tests are based off of rss.xml, so let's find out how many elements
// should be related.
$feed_count = \Drupal::entityQuery('node')
->condition('promote', NodeInterface::PROMOTED)
->condition('status', NodeInterface::PUBLISHED)
->accessCheck(FALSE)
->range(0, $this->config('system.rss')->get('items.limit'))
->count()
->execute();
return min($feed_count, 10);
}
/**
......
......@@ -4,7 +4,7 @@
use Drupal\aggregator\Entity\Feed;
use Drupal\Component\Utility\Html;
use Drupal\Core\Database\Database;
use Drupal\node\NodeInterface;
use Drupal\Tests\BrowserTestBase;
use Drupal\aggregator\FeedInterface;
......@@ -147,9 +147,16 @@ public function getFeedEditObject($feed_url = NULL, array $values = []) {
* 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 = Database::getConnection()->queryRange('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;
// Our tests are based off of rss.xml, so let's find out how many elements
// should be related.
$feed_count = \Drupal::entityQuery('node')
->condition('promote', NodeInterface::PROMOTED)
->condition('status', NodeInterface::PUBLISHED)
->accessCheck(FALSE)
->range(0, $this->config('system.rss')->get('items.limit'))
->count()
->execute();
return min($feed_count, 10);
}
/**
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment