3 namespace Drupal\views_ui\Tests;
5 use Drupal\views\Tests\ViewTestBase;
8 * Tests the views analyze system.
12 class AnalyzeTest extends ViewTestBase {
19 public static $modules = ['views_ui'];
22 * Views used by this test.
26 public static $testViews = ['test_view'];
28 protected function setUp() {
31 $this->enableViewsTestModule();
33 // Add an admin user will full rights;
34 $this->admin = $this->drupalCreateUser(['administer views']);
38 * Tests that analyze works in general.
40 public function testAnalyzeBasic() {
41 $this->drupalLogin($this->admin);
43 $this->drupalGet('admin/structure/views/view/test_view/edit');
44 $this->assertLink(t('Analyze view'));
46 // This redirects the user to the analyze form.
47 $this->clickLink(t('Analyze view'));
48 $this->assertText(t('View analysis'));
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]));
55 // This redirects the user back to the main views edit page.
56 $this->drupalPostForm(NULL, [], t('Ok'));