You are here

public function ViewsListTest::testViewsListLimit in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/views_ui/tests/src/Functional/ViewsListTest.php \Drupal\Tests\views_ui\Functional\ViewsListTest::testViewsListLimit()

Tests that the views list does not use a pager.

File

core/modules/views_ui/tests/src/Functional/ViewsListTest.php, line 49

Class

ViewsListTest
Tests the views list.

Namespace

Drupal\Tests\views_ui\Functional

Code

public function testViewsListLimit() {

  // Check if we can access the main views admin page.
  $this
    ->drupalGet('admin/structure/views');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->linkExists('Add view');

  // Check that there is a link to the content view without a destination
  // parameter.
  $this
    ->drupalGet('admin/structure/views');
  $links = $this
    ->getSession()
    ->getPage()
    ->findAll('xpath', "//a[contains(@href, 'admin/structure/views/view/content')]");
  $this
    ->assertStringEndsWith('admin/structure/views/view/content', $links[0]
    ->getAttribute('href'));
  $this
    ->assertSession()
    ->linkByHrefExists('admin/structure/views/view/content/delete?destination');

  // Count default views to be subtracted from the limit.
  $views = count(Views::getEnabledViews());

  // Create multiples views.
  $limit = 51;
  $values = $this
    ->config('views.view.test_view_storage')
    ->get();
  for ($i = 1; $i <= $limit - $views; $i++) {
    $values['id'] = 'test_view_storage_new' . $i;
    unset($values['uuid']);
    $created = View::create($values);
    $created
      ->save();
  }
  $this
    ->drupalGet('admin/structure/views');

  // Check that all the rows are listed.
  $this
    ->assertCount($limit, $this
    ->xpath('//tbody/tr[contains(@class,"views-ui-list-enabled")]'));
}