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