Issue #3014771 by anya_m, voleger, andypost, mondrake, goodboy: Replace queryRange call in AggregatorTestBase classes

8.7.x
Nathaniel Catchpole 2018-11-29 15:35:24 +00:00
parent 10722cd872
commit 8471aac3db
2 changed files with 22 additions and 8 deletions

View File

@ -6,7 +6,7 @@ namespace Drupal\aggregator\Tests;
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 @@ abstract class AggregatorTestBase extends WebTestBase {
* 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);
}
/**

View File

@ -4,7 +4,7 @@ namespace Drupal\Tests\aggregator\Functional;
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 @@ abstract class AggregatorTestBase extends BrowserTestBase {
* 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);
}
/**