Backup of db before drupal security update
[yaffs-website] / web / core / modules / views_ui / src / Tests / AnalyzeTest.php
1 <?php
2
3 namespace Drupal\views_ui\Tests;
4
5 use Drupal\views\Tests\ViewTestBase;
6
7 /**
8  * Tests the views analyze system.
9  *
10  * @group views_ui
11  */
12 class AnalyzeTest extends ViewTestBase {
13
14   /**
15    * Modules to enable.
16    *
17    * @var array
18    */
19   public static $modules = ['views_ui'];
20
21   /**
22    * Views used by this test.
23    *
24    * @var array
25    */
26   public static $testViews = ['test_view'];
27
28   protected function setUp() {
29     parent::setUp();
30
31     $this->enableViewsTestModule();
32
33     // Add an admin user will full rights;
34     $this->admin = $this->drupalCreateUser(['administer views']);
35   }
36
37   /**
38    * Tests that analyze works in general.
39    */
40   public function testAnalyzeBasic() {
41     $this->drupalLogin($this->admin);
42
43     $this->drupalGet('admin/structure/views/view/test_view/edit');
44     $this->assertLink(t('Analyze view'));
45
46     // This redirects the user to the analyze form.
47     $this->clickLink(t('Analyze view'));
48     $this->assertText(t('View analysis'));
49
50     foreach (['ok', 'warning', 'error'] as $type) {
51       $xpath = $this->xpath('//div[contains(@class, :class)]', [':class' => $type]);
52       $this->assertTrue(count($xpath), format_string('Analyse messages with @type found', ['@type' => $type]));
53     }
54
55     // This redirects the user back to the main views edit page.
56     $this->drupalPostForm(NULL, [], t('Ok'));
57   }
58
59 }