function AggregatorAdminTest::testOverviewPage

Same name and namespace in other branches
  1. 8.9.x core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php \Drupal\Tests\aggregator\Functional\AggregatorAdminTest::testOverviewPage()

Tests the overview page.

File

core/modules/aggregator/tests/src/Functional/AggregatorAdminTest.php, line 71

Class

AggregatorAdminTest
Tests aggregator admin pages.

Namespace

Drupal\Tests\aggregator\Functional

Code

public function testOverviewPage() {
  $feed = $this->createFeed($this->getRSS091Sample());
  $this->drupalGet('admin/config/services/aggregator');
  // Check if the amount of feeds in the overview matches the amount created.
  $this->assertSession()
    ->elementsCount('xpath', '//table/tbody/tr', 1);
  // Check if the fields in the table match with what's expected.
  $this->assertSession()
    ->elementTextContains('xpath', '//table/tbody/tr//td[1]/a', $feed->label());
  $count = $this->container
    ->get('entity_type.manager')
    ->getStorage('aggregator_item')
    ->getItemCount($feed);
  $this->assertSession()
    ->elementTextContains('xpath', '//table/tbody/tr//td[2]', \Drupal::translation()->formatPlural($count, '1 item', '@count items'));
  // Update the items of the first feed.
  $feed->refreshItems();
  $this->drupalGet('admin/config/services/aggregator');
  $this->assertSession()
    ->elementsCount('xpath', '//table/tbody/tr', 1);
  // Check if the fields in the table match with what's expected.
  $this->assertSession()
    ->elementTextContains('xpath', '//table/tbody/tr//td[1]/a', $feed->label());
  $count = $this->container
    ->get('entity_type.manager')
    ->getStorage('aggregator_item')
    ->getItemCount($feed);
  $this->assertSession()
    ->elementTextContains('xpath', '//table/tbody/tr//td[2]', \Drupal::translation()->formatPlural($count, '1 item', '@count items'));
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.