Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / tests / src / Functional / ViewsListTest.php
1 <?php
2
3 namespace Drupal\Tests\views_ui\Functional;
4
5 use Drupal\views\Entity\View;
6 use Drupal\views\Views;
7
8 /**
9  * Tests the views list.
10  *
11  * @group views_ui
12  */
13 class ViewsListTest extends UITestBase {
14
15   /**
16    * Modules to enable.
17    *
18    * @var array
19    */
20   public static $modules = ['block', 'views_ui'];
21
22   /**
23    * A user with permission to administer views.
24    *
25    * @var \Drupal\user\Entity\User
26    */
27   protected $adminUser;
28
29   /**
30    * {@inheritdoc}
31    */
32   protected function setUp($import_test_views = TRUE) {
33     parent::setUp($import_test_views);
34
35     $this->drupalPlaceBlock('local_tasks_block');
36     $this->drupalPlaceBlock('local_actions_block');
37     $this->adminUser = $this->drupalCreateUser(['administer views']);
38     $this->drupalLogin($this->adminUser);
39   }
40
41   /**
42    * Tests that the views list does not use a pager.
43    */
44   public function testViewsListLimit() {
45     // Check if we can access the main views admin page.
46     $this->drupalGet('admin/structure/views');
47     $this->assertResponse(200);
48     $this->assertLink(t('Add view'));
49
50     // Count default views to be subtracted from the limit.
51     $views = count(Views::getEnabledViews());
52
53     // Create multiples views.
54     $limit = 51;
55     $values = $this->config('views.view.test_view_storage')->get();
56     for ($i = 1; $i <= $limit - $views; $i++) {
57       $values['id'] = 'test_view_storage_new' . $i;
58       unset($values['uuid']);
59       $created = View::create($values);
60       $created->save();
61     }
62     $this->drupalGet('admin/structure/views');
63
64     // Check that all the rows are listed.
65     $this->assertEqual(count($this->xpath('//tbody/tr[contains(@class,"views-ui-list-enabled")]')), $limit);
66   }
67
68 }