summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNathaniel Catchpole2017-06-07 10:37:34 (GMT)
committerNathaniel Catchpole2017-06-07 10:37:34 (GMT)
commit1105324af30beef55d9d5efb90c20f252588fd93 (patch)
treed429887464e28af06194c04d8b95701973272e03
parent359663bfdba1c82c0212a2e9362fc4317f2d62d2 (diff)
Issue #2747167 by michielnugter, dawehner, Lendude, mglaman, Mac_Weber, Jo Fitzgerald, klausi: Convert first part of web tests of views_ui
-rw-r--r--core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php (renamed from core/modules/config_translation/src/Tests/ConfigTranslationViewListUiTest.php)8
-rw-r--r--core/modules/content_translation/tests/src/Functional/Views/ContentTranslationViewsUITest.php (renamed from core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php)4
-rw-r--r--core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php (renamed from core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php)15
-rw-r--r--core/modules/taxonomy/tests/src/Functional/Views/TaxonomyParentUITest.php (renamed from core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php)8
-rw-r--r--core/modules/user/tests/src/Functional/AccessRoleUITest.php (renamed from core/modules/user/src/Tests/Views/AccessRoleUITest.php)10
-rw-r--r--core/modules/views_ui/src/Tests/UITestBase.php5
-rw-r--r--core/modules/views_ui/tests/src/Functional/AnalyzeTest.php (renamed from core/modules/views_ui/src/Tests/AnalyzeTest.php)19
-rw-r--r--core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php (renamed from core/modules/views_ui/src/Tests/AreaEntityUITest.php)8
-rw-r--r--core/modules/views_ui/tests/src/Functional/ArgumentValidatorTest.php (renamed from core/modules/views_ui/src/Tests/ArgumentValidatorTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/CachedDataUITest.php (renamed from core/modules/views_ui/src/Tests/CachedDataUITest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php (renamed from core/modules/views_ui/src/Tests/CustomBooleanTest.php)5
-rw-r--r--core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php (renamed from core/modules/views_ui/src/Tests/DefaultViewsTest.php)15
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php (renamed from core/modules/views_ui/src/Tests/DisplayAttachmentTest.php)7
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php (renamed from core/modules/views_ui/src/Tests/DisplayCRUDTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayExtenderUITest.php (renamed from core/modules/views_ui/src/Tests/DisplayExtenderUITest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php (renamed from core/modules/views_ui/src/Tests/DisplayFeedTest.php)9
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayPathTest.php (renamed from core/modules/views_ui/src/Tests/DisplayPathTest.php)18
-rw-r--r--core/modules/views_ui/tests/src/Functional/DisplayTest.php (renamed from core/modules/views_ui/src/Tests/DisplayTest.php)59
-rw-r--r--core/modules/views_ui/tests/src/Functional/DuplicateTest.php (renamed from core/modules/views_ui/src/Tests/DuplicateTest.php)8
-rw-r--r--core/modules/views_ui/tests/src/Functional/FieldUITest.php (renamed from core/modules/views_ui/src/Tests/FieldUITest.php)16
-rw-r--r--core/modules/views_ui/tests/src/Functional/FilterBooleanWebTest.php (renamed from core/modules/views_ui/src/Tests/FilterBooleanWebTest.php)10
-rw-r--r--core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php (renamed from core/modules/views_ui/src/Tests/FilterNumericWebTest.php)18
-rw-r--r--core/modules/views_ui/tests/src/Functional/FilterUITest.php (renamed from core/modules/views_ui/src/Tests/FilterUITest.php)11
-rw-r--r--core/modules/views_ui/tests/src/Functional/GroupByTest.php (renamed from core/modules/views_ui/src/Tests/GroupByTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/HandlerTest.php (renamed from core/modules/views_ui/src/Tests/HandlerTest.php)12
-rw-r--r--core/modules/views_ui/tests/src/Functional/NewViewConfigSchemaTest.php (renamed from core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php)6
-rw-r--r--core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php (renamed from core/modules/views_ui/src/Tests/OverrideDisplaysTest.php)10
-rw-r--r--core/modules/views_ui/tests/src/Functional/QueryTest.php (renamed from core/modules/views_ui/src/Tests/QueryTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php (renamed from core/modules/views_ui/src/Tests/RearrangeFieldsTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/RedirectTest.php (renamed from core/modules/views_ui/src/Tests/RedirectTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php (renamed from core/modules/views_ui/src/Tests/ReportFieldsTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/ReportTest.php (renamed from core/modules/views_ui/src/Tests/ReportTest.php)10
-rw-r--r--core/modules/views_ui/tests/src/Functional/SettingsTest.php (renamed from core/modules/views_ui/src/Tests/SettingsTest.php)12
-rw-r--r--core/modules/views_ui/tests/src/Functional/StorageTest.php (renamed from core/modules/views_ui/src/Tests/StorageTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/StyleTableTest.php (renamed from core/modules/views_ui/src/Tests/StyleTableTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/StyleUITest.php (renamed from core/modules/views_ui/src/Tests/StyleUITest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/TokenizeAreaUITest.php (renamed from core/modules/views_ui/src/Tests/TokenizeAreaUITest.php)2
-rw-r--r--core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php (renamed from core/modules/views_ui/src/Tests/TranslatedViewTest.php)9
-rw-r--r--core/modules/views_ui/tests/src/Functional/UITestBase.php90
-rw-r--r--core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php (renamed from core/modules/views_ui/src/Tests/UnsavedPreviewTest.php)8
-rw-r--r--core/modules/views_ui/tests/src/Functional/ViewsListTest.php (renamed from core/modules/views_ui/src/Tests/ViewsListTest.php)9
-rw-r--r--core/modules/views_ui/tests/src/Functional/WizardTest.php (renamed from core/modules/views_ui/src/Tests/WizardTest.php)4
-rw-r--r--core/modules/views_ui/tests/src/Functional/XssTest.php (renamed from core/modules/views_ui/src/Tests/XssTest.php)2
-rw-r--r--core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php125
44 files changed, 369 insertions, 207 deletions
diff --git a/core/modules/config_translation/src/Tests/ConfigTranslationViewListUiTest.php b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
index b259a18..edb41f9 100644
--- a/core/modules/config_translation/src/Tests/ConfigTranslationViewListUiTest.php
+++ b/core/modules/config_translation/tests/src/Functional/ConfigTranslationViewListUiTest.php
@@ -1,8 +1,8 @@
<?php
-namespace Drupal\config_translation\Tests;
+namespace Drupal\Tests\config_translation\Functional;
-use Drupal\views_ui\Tests\UITestBase;
+use Drupal\Tests\views_ui\Functional\UITestBase;
/**
* Visit view list and test if translate is available.
@@ -25,8 +25,8 @@ class ConfigTranslationViewListUiTest extends UITestBase {
*/
public static $modules = ['config_translation', 'views_ui'];
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$permissions = [
'administer views',
diff --git a/core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php b/core/modules/content_translation/tests/src/Functional/Views/ContentTranslationViewsUITest.php
index 07b5d00..4b4d53a 100644
--- a/core/modules/content_translation/src/Tests/Views/ContentTranslationViewsUITest.php
+++ b/core/modules/content_translation/tests/src/Functional/Views/ContentTranslationViewsUITest.php
@@ -1,8 +1,8 @@
<?php
-namespace Drupal\content_translation\Tests\Views;
+namespace Drupal\Tests\content_translation\Functional\Views;
-use Drupal\views_ui\Tests\UITestBase;
+use Drupal\Tests\views_ui\Functional\UITestBase;
/**
* Tests the views UI when content_translation is enabled.
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
index efa5191..4de7370 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyIndexTidUiTest.php
+++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyIndexTidUiTest.php
@@ -1,12 +1,12 @@
<?php
-namespace Drupal\taxonomy\Tests\Views;
+namespace Drupal\Tests\taxonomy\Functional\Views;
use Drupal\field\Tests\EntityReference\EntityReferenceTestTrait;
use Drupal\taxonomy\Entity\Term;
use Drupal\taxonomy\Entity\Vocabulary;
+use Drupal\Tests\views_ui\Functional\UITestBase;
use Drupal\views\Tests\ViewTestData;
-use Drupal\views_ui\Tests\UITestBase;
use Drupal\views\Entity\View;
/**
@@ -43,8 +43,8 @@ class TaxonomyIndexTidUiTest extends UITestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->adminUser = $this->drupalCreateUser(['administer taxonomy', 'administer views']);
$this->drupalLogin($this->adminUser);
@@ -93,10 +93,9 @@ class TaxonomyIndexTidUiTest extends UITestBase {
for ($j = 0; $j <= $i; $j++) {
$option = $result[$counter++];
$prefix = $this->terms[$i][$j]->parent->target_id ? '-' : '';
- $attributes = $option->attributes();
- $tid = (string) $attributes->value;
+ $tid = $option->getAttribute('value');
- $this->assertEqual($prefix . $this->terms[$i][$j]->getName(), (string) $option);
+ $this->assertEqual($prefix . $this->terms[$i][$j]->getName(), $option->getText());
$this->assertEqual($this->terms[$i][$j]->id(), $tid);
}
}
@@ -108,7 +107,7 @@ class TaxonomyIndexTidUiTest extends UITestBase {
$display['display_options']['filters']['tid']['type'] = 'textfield';
$view->save();
$this->drupalGet('admin/structure/views/nojs/handler/test_filter_taxonomy_index_tid/default/filter/tid');
- $this->assertFieldByXPath('//input[@id="edit-options-value"]');
+ $this->assertFieldById('edit-options-value', NULL);
// Tests \Drupal\taxonomy\Plugin\views\filter\TaxonomyIndexTid::calculateDependencies().
$expected = [
diff --git a/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyParentUITest.php
index a57a09a..d8ab8ea 100644
--- a/core/modules/taxonomy/src/Tests/Views/TaxonomyParentUITest.php
+++ b/core/modules/taxonomy/tests/src/Functional/Views/TaxonomyParentUITest.php
@@ -1,9 +1,9 @@
<?php
-namespace Drupal\taxonomy\Tests\Views;
+namespace Drupal\Tests\taxonomy\Functional\Views;
use Drupal\views\Tests\ViewTestData;
-use Drupal\views_ui\Tests\UITestBase;
+use Drupal\Tests\views_ui\Functional\UITestBase;
/**
* Tests views taxonomy parent plugin UI.
@@ -30,8 +30,8 @@ class TaxonomyParentUITest extends UITestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), ['taxonomy_test_views']);
}
diff --git a/core/modules/user/src/Tests/Views/AccessRoleUITest.php b/core/modules/user/tests/src/Functional/AccessRoleUITest.php
index bea8c53..6c1004c 100644
--- a/core/modules/user/src/Tests/Views/AccessRoleUITest.php
+++ b/core/modules/user/tests/src/Functional/AccessRoleUITest.php
@@ -1,15 +1,15 @@
<?php
-namespace Drupal\user\Tests\Views;
+namespace Drupal\Tests\user\Functional;
+use Drupal\Tests\views_ui\Functional\UITestBase;
use Drupal\views\Tests\ViewTestData;
-use Drupal\views_ui\Tests\UITestBase;
/**
* Tests views role access plugin UI.
*
* @group user
- * @see Drupal\user\Plugin\views\access\Role
+ * @see \Drupal\user\Plugin\views\access\Role
*/
class AccessRoleUITest extends UITestBase {
@@ -30,8 +30,8 @@ class AccessRoleUITest extends UITestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
ViewTestData::createTestViews(get_class($this), ['user_test_views']);
}
diff --git a/core/modules/views_ui/src/Tests/UITestBase.php b/core/modules/views_ui/src/Tests/UITestBase.php
index 0b90e04..83f2f85 100644
--- a/core/modules/views_ui/src/Tests/UITestBase.php
+++ b/core/modules/views_ui/src/Tests/UITestBase.php
@@ -6,6 +6,9 @@ use Drupal\views\Tests\ViewTestBase;
/**
* Provides a base class for testing the Views UI.
+ *
+ * @deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.x.
+ * Use \Drupal\Tests\views_ui\Functional\UITestBase.
*/
abstract class UITestBase extends ViewTestBase {
@@ -48,6 +51,8 @@ abstract class UITestBase extends ViewTestBase {
'administer permissions',
]);
$this->drupalLogin($this->fullAdminUser);
+
+ @trigger_error('\Drupal\views_ui\Tests\UITestBase is deprecated in Drupal 8.4.0 and will be removed before Drupal 9.0.x. Instead, use \Drupal\Tests\views_ui\Functional\UITestBase', E_USER_DEPRECATED);
}
/**
diff --git a/core/modules/views_ui/src/Tests/AnalyzeTest.php b/core/modules/views_ui/tests/src/Functional/AnalyzeTest.php
index 83e2531..32d1ae9 100644
--- a/core/modules/views_ui/src/Tests/AnalyzeTest.php
+++ b/core/modules/views_ui/tests/src/Functional/AnalyzeTest.php
@@ -1,15 +1,13 @@
<?php
-namespace Drupal\views_ui\Tests;
-
-use Drupal\views\Tests\ViewTestBase;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the views analyze system.
*
* @group views_ui
*/
-class AnalyzeTest extends ViewTestBase {
+class AnalyzeTest extends UITestBase {
/**
* Modules to enable.
@@ -25,27 +23,18 @@ class AnalyzeTest extends ViewTestBase {
*/
public static $testViews = ['test_view'];
- protected function setUp() {
- parent::setUp();
-
- $this->enableViewsTestModule();
-
- // Add an admin user will full rights;
- $this->admin = $this->drupalCreateUser(['administer views']);
- }
-
/**
* Tests that analyze works in general.
*/
public function testAnalyzeBasic() {
- $this->drupalLogin($this->admin);
+ $this->drupalLogin($this->adminUser);
$this->drupalGet('admin/structure/views/view/test_view/edit');
$this->assertLink(t('Analyze view'));
// This redirects the user to the analyze form.
$this->clickLink(t('Analyze view'));
- $this->assertText(t('View analysis'));
+ $this->assertSession()->titleEquals('View analysis | Drupal');
foreach (['ok', 'warning', 'error'] as $type) {
$xpath = $this->xpath('//div[contains(@class, :class)]', [':class' => $type]);
diff --git a/core/modules/views_ui/src/Tests/AreaEntityUITest.php b/core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php
index ffe895a..d74575f 100644
--- a/core/modules/views_ui/src/Tests/AreaEntityUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/AreaEntityUITest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\block\Entity\Block;
use Drupal\entity_test\Entity\EntityTest;
@@ -34,15 +34,15 @@ class AreaEntityUITest extends UITestBase {
$this->drupalGet($view->urlInfo('edit-form'));
// Add a global NULL argument to the view for testing argument placeholders.
- $this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/argument", ['name[views.null]' => 1], 'Add and configure contextual filters');
+ $this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/argument", ['name[views.null]' => TRUE], 'Add and configure contextual filters');
$this->drupalPostForm(NULL, [], 'Apply');
// Configure both the entity_test area header and the block header to
// reference the given entities.
- $this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_block]' => 1], 'Add and configure header');
+ $this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_block]' => TRUE], 'Add and configure header');
$this->drupalPostForm(NULL, ['options[target]' => $block->id()], 'Apply');
- $this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_entity_test]' => 1], 'Add and configure header');
+ $this->drupalPostForm("admin/structure/views/nojs/add-handler/$id/page_1/header", ['name[views.entity_entity_test]' => TRUE], 'Add and configure header');
$this->drupalPostForm(NULL, ['options[target]' => $entity_test->id()], 'Apply');
$this->drupalPostForm(NULL, [], 'Save');
diff --git a/core/modules/views_ui/src/Tests/ArgumentValidatorTest.php b/core/modules/views_ui/tests/src/Functional/ArgumentValidatorTest.php
index d94e682..5a33970 100644
--- a/core/modules/views_ui/src/Tests/ArgumentValidatorTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ArgumentValidatorTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
diff --git a/core/modules/views_ui/src/Tests/CachedDataUITest.php b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
index a605d0f..51e489d 100644
--- a/core/modules/views_ui/src/Tests/CachedDataUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/CachedDataUITest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the user tempstore cache in the UI.
diff --git a/core/modules/views_ui/src/Tests/CustomBooleanTest.php b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php
index adae59a..95f6d56 100644
--- a/core/modules/views_ui/src/Tests/CustomBooleanTest.php
+++ b/core/modules/views_ui/tests/src/Functional/CustomBooleanTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\views\Views;
@@ -173,8 +173,7 @@ class CustomBooleanTest extends UITestBase {
$this->{$values['test']}(strpos($output, $values['false']), SafeMarkup::format('Expected custom boolean FALSE value %value in output for %type', ['%value' => $values['false'], '%type' => $type]));
// Assert that we are using the correct template.
- $this->setRawContent($output);
- $this->assertText('llama', 'Loaded the correct views-view-field.html.twig template');
+ $this->assertContains('llama', (string) $output);
}
}
diff --git a/core/modules/views_ui/src/Tests/DefaultViewsTest.php b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
index a709d1f..91ee05b 100644
--- a/core/modules/views_ui/src/Tests/DefaultViewsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DefaultViewsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\Core\Url;
use Drupal\user\Entity\Role;
@@ -20,11 +20,10 @@ class DefaultViewsTest extends UITestBase {
*/
public static $testViews = ['test_view_status', 'test_page_display_menu', 'test_page_display_arguments'];
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
- protected function setUp() {
- parent::setUp();
-
- $this->drupalPlaceBlock('page_title_block');
+ $this->placeBlock('page_title_block');
}
/**
@@ -228,9 +227,9 @@ class DefaultViewsTest extends UITestBase {
* failure. Failure also results in a failed assertion.
*/
public function clickViewsOperationLink($label, $unique_href_part) {
- $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => $label]);
+ $links = $this->xpath('//a[normalize-space(text())=:label]', [':label' => (string) $label]);
foreach ($links as $link_index => $link) {
- $position = strpos($link['href'], $unique_href_part);
+ $position = strpos($link->getAttribute('href'), $unique_href_part);
if ($position !== FALSE) {
$index = $link_index;
break;
@@ -238,7 +237,7 @@ class DefaultViewsTest extends UITestBase {
}
$this->assertTrue(isset($index), format_string('Link to "@label" containing @part found.', ['@label' => $label, '@part' => $unique_href_part]));
if (isset($index)) {
- return $this->clickLink($label, $index);
+ return $this->clickLink((string) $label, $index);
}
else {
return FALSE;
diff --git a/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php
index 480172b..057a785 100644
--- a/core/modules/views_ui/src/Tests/DisplayAttachmentTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayAttachmentTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
@@ -16,6 +16,7 @@ class DisplayAttachmentTest extends UITestBase {
* Views used by this test.
*
* @var array
+ * .
*/
public static $testViews = ['test_attachment_ui'];
@@ -41,7 +42,7 @@ class DisplayAttachmentTest extends UITestBase {
$this->assertEscaped('<em>Page</em>');
$this->assertNoRaw('<em>Page</em>');
$result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
- $this->assertEqual($result[0]->attributes()->title, t('Page'));
+ $this->assertEqual($result[0]->getAttribute('title'), t('Page'));
$this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView('test_attachment_ui');
@@ -50,7 +51,7 @@ class DisplayAttachmentTest extends UITestBase {
$this->drupalPostForm($attachment_display_url, ['displays[default]' => 1, 'displays[page_1]' => 1], t('Apply'));
$result = $this->xpath('//a[@id = :id]', [':id' => 'views-attachment-1-displays']);
- $this->assertEqual($result[0]->attributes()->title, t('Multiple displays'));
+ $this->assertEqual($result[0]->getAttribute('title'), t('Multiple displays'));
$this->drupalPostForm(NULL, [], t('Save'));
$view = Views::getView('test_attachment_ui');
diff --git a/core/modules/views_ui/src/Tests/DisplayCRUDTest.php b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php
index e29f0a9..1e53c71 100644
--- a/core/modules/views_ui/src/Tests/DisplayCRUDTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayCRUDTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
diff --git a/core/modules/views_ui/src/Tests/DisplayExtenderUITest.php b/core/modules/views_ui/tests/src/Functional/DisplayExtenderUITest.php
index e8eff0a..b222f15 100644
--- a/core/modules/views_ui/src/Tests/DisplayExtenderUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayExtenderUITest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
diff --git a/core/modules/views_ui/src/Tests/DisplayFeedTest.php b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php
index d8d0031..9dba450 100644
--- a/core/modules/views_ui/src/Tests/DisplayFeedTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayFeedTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the UI for feed display plugin.
@@ -57,10 +57,9 @@ class DisplayFeedTest extends UITestBase {
$result = $this->xpath('//div[@id="edit-displays"]/div');
$options = [];
foreach ($result as $item) {
- foreach ($item->input->attributes() as $attribute => $value) {
- if ($attribute == 'value') {
- $options[] = (string) $value;
- }
+ $input_node = $item->find('css', 'input');
+ if ($input_node->hasAttribute('value')) {
+ $options[] = $input_node->getAttribute('value');
}
}
diff --git a/core/modules/views_ui/src/Tests/DisplayPathTest.php b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
index d1d1732..f8e58e7 100644
--- a/core/modules/views_ui/src/Tests/DisplayPathTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayPathTest.php
@@ -1,8 +1,10 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
+
use Drupal\Core\Menu\MenuTreeParameters;
use Drupal\menu_link_content\Entity\MenuLinkContent;
+use Drupal\system\Tests\Cache\AssertPageCacheContextsAndTagsTrait;
/**
* Tests the UI of generic display path plugin.
@@ -11,11 +13,12 @@ use Drupal\menu_link_content\Entity\MenuLinkContent;
* @see \Drupal\views\Plugin\views\display\PathPluginBase
*/
class DisplayPathTest extends UITestBase {
+ use AssertPageCacheContextsAndTagsTrait;
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
- $this->drupalPlaceBlock('page_title_block');
+ $this->placeBlock('page_title_block');
}
/**
@@ -158,9 +161,14 @@ class DisplayPathTest extends UITestBase {
$this->drupalGet('admin/structure/views/nojs/display/test_page_display_menu/page_5/menu');
$this->assertResponse(200);
$menu_parent = $this->xpath('//select[@id="edit-menu-parent"]');
- $menu_options = (array) $menu_parent[0]->option;
+ $menu_options = (array) $menu_parent[0]->findAll('css', 'option');
unset($menu_options['@attributes']);
+ // Convert array to make the next assertion possible.
+ $menu_options = array_map(function($element) {
+ return $element->getText();
+ }, $menu_options);
+
$this->assertEqual([
'<User account menu>',
'-- My account',
diff --git a/core/modules/views_ui/src/Tests/DisplayTest.php b/core/modules/views_ui/tests/src/Functional/DisplayTest.php
index afb2c7f..44724b4 100644
--- a/core/modules/views_ui/src/Tests/DisplayTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DisplayTest.php
@@ -1,10 +1,8 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
-use Drupal\Component\Serialization\Json;
use Drupal\Component\Utility\SafeMarkup;
-use Drupal\Core\Template\Attribute;
use Drupal\views\Entity\View;
use Drupal\views\Views;
@@ -40,13 +38,6 @@ class DisplayTest extends UITestBase {
$this->drupalPostForm(NULL, [], t('Add @display', ['@display' => 'Block']));
$this->assertText('Block');
$this->assertNoText('Block 2');
-
- // Views has special form handling in views_ui_form_button_was_clicked()
- // to be able to change the submit button text via JS, this simulates what
- // the JS is doing.
- $this->drupalPostForm(NULL, [], NULL, [], [], NULL, '&op=Block');
- $this->assertText('Block');
- $this->assertText('Block 2');
}
/**
@@ -94,13 +85,13 @@ class DisplayTest extends UITestBase {
$this->drupalGet($path_prefix);
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appear after initial adding of a view.');
- $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is visible.');
- $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is not visible.');
+ $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is visible.');
+ $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is not visible.');
$this->drupalPostForm(NULL, [], 'Disable Page');
$this->assertTrue($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class appears once the display is marked as such.');
- $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', '', 'Make sure the disable button is not visible.');
- $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', '', 'Make sure the enable button is visible.');
+ $this->assertNoFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-disable', NULL, 'Make sure the disable button is not visible.');
+ $this->assertFieldById('edit-displays-settings-settings-content-tab-content-details-top-actions-enable', NULL, 'Make sure the enable button is visible.');
$this->drupalPostForm(NULL, [], 'Enable Page');
$this->assertFalse($this->xpath('//div[contains(@class, :class)]', [':class' => 'views-display-disabled']), 'Make sure the disabled display css class does not appears once the display is enabled again.');
}
@@ -145,7 +136,7 @@ class DisplayTest extends UITestBase {
// Assert that the expected text is found in each area category.
foreach ($areas as $type) {
$element = $this->xpath('//div[contains(@class, :class)]/div', [':class' => $type]);
- $this->assertEqual((string) $element[0], SafeMarkup::format('The selected display type does not use @type plugins', ['@type' => $type]));
+ $this->assertEqual($element[0]->getHtml(), SafeMarkup::format('The selected display type does not use @type plugins', ['@type' => $type]));
}
}
@@ -160,7 +151,7 @@ class DisplayTest extends UITestBase {
// Test the link text displays 'None' and not 'Block 1'
$this->drupalGet($path);
$result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
- $this->assertEqual($result[0], t('None'), 'Make sure that the link option summary shows "None" by default.');
+ $this->assertEqual($result[0]->getHtml(), t('None'), 'Make sure that the link option summary shows "None" by default.');
$this->drupalGet($link_display_path);
$this->assertFieldChecked('edit-link-display-0');
@@ -171,7 +162,7 @@ class DisplayTest extends UITestBase {
$this->drupalGet($path);
$result = $this->xpath("//a[contains(@href, :path)]", [':path' => $link_display_path]);
- $this->assertEqual($result[0], 'Page', 'Make sure that the link option summary shows the right linked display.');
+ $this->assertEqual($result[0]->getHtml(), 'Page', 'Make sure that the link option summary shows the right linked display.');
$this->drupalPostForm($link_display_path, ['link_display' => 'custom_url', 'link_url' => 'a-custom-url'], t('Apply'));
// The form redirects to the master display.
@@ -187,40 +178,6 @@ class DisplayTest extends UITestBase {
}
/**
- * Tests contextual links on Views page displays.
- */
- public function testPageContextualLinks() {
- $this->drupalLogin($this->drupalCreateUser(['administer views', 'access contextual links']));
- $view = View::load('test_display');
- $view->enable()->save();
- $this->container->get('router.builder')->rebuildIfNeeded();
-
- // When no "main content" block is placed, we find a contextual link
- // placeholder for editing just the view.
- $this->drupalGet('test-display');
- $id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
- // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
- $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
-
- // Get server-rendered contextual links.
- // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:renderContextualLinks()
- $post = ['ids[0]' => $id];
- $response = $this->drupalPostWithFormat('contextual/render', 'json', $post, ['query' => ['destination' => 'test-display']]);
- $this->assertResponse(200);
- $json = Json::decode($response);
- $this->assertIdentical($json[$id], '<ul class="contextual-links"><li class="entityviewedit-form"><a href="' . base_path() . 'admin/structure/views/view/test_display/edit/page_1">Edit view</a></li></ul>');
-
- // When a "main content" is placed, we still find a contextual link
- // placeholder for editing just the view (not the main content block).
- // @see system_block_view_system_main_block_alter()
- $this->drupalPlaceBlock('system_main_block', ['id' => 'main_content']);
- $this->drupalGet('test-display');
- $id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
- // @see \Drupal\contextual\Tests\ContextualDynamicContextTest:assertContextualLinkPlaceHolder()
- $this->assertRaw('<div' . new Attribute(['data-contextual-id' => $id]) . '></div>', format_string('Contextual link placeholder with id @id exists.', ['@id' => $id]));
- }
-
- /**
* Tests that the view status is correctly reflected on the edit form.
*/
public function testViewStatus() {
diff --git a/core/modules/views_ui/src/Tests/DuplicateTest.php b/core/modules/views_ui/tests/src/Functional/DuplicateTest.php
index 1096ab4..91d88fa 100644
--- a/core/modules/views_ui/src/Tests/DuplicateTest.php
+++ b/core/modules/views_ui/tests/src/Functional/DuplicateTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the UI for view duplicate tool.
@@ -9,10 +9,10 @@ namespace Drupal\views_ui\Tests;
*/
class DuplicateTest extends UITestBase {
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
- $this->drupalPlaceBlock('page_title_block');
+ $this->placeBlock('page_title_block');
}
/**
diff --git a/core/modules/views_ui/src/Tests/FieldUITest.php b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
index 4e87323..dc3081f 100644
--- a/core/modules/views_ui/src/Tests/FieldUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/FieldUITest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\Component\Serialization\Json;
use Drupal\views\Views;
@@ -39,20 +39,20 @@ class FieldUITest extends UITestBase {
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/age';
$this->drupalGet($edit_handler_url);
$result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
- $this->assertEqual((string) $result[0], '{{ age }} == Age');
+ $this->assertEqual($result[0]->getHtml(), '{{ age }} == Age');
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/id';
$this->drupalGet($edit_handler_url);
$result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
- $this->assertEqual((string) $result[0], '{{ age }} == Age');
- $this->assertEqual((string) $result[1], '{{ id }} == ID');
+ $this->assertEqual(trim($result[0]->getHtml()), '{{ age }} == Age');
+ $this->assertEqual(trim($result[1]->getHtml()), '{{ id }} == ID');
$edit_handler_url = 'admin/structure/views/nojs/handler/test_view/default/field/name';
$this->drupalGet($edit_handler_url);
$result = $this->xpath('//details[@id="edit-options-alter-help"]/div[@class="details-wrapper"]/div[@class="item-list"]/ul/li');
- $this->assertEqual((string) $result[0], '{{ age }} == Age');
- $this->assertEqual((string) $result[1], '{{ id }} == ID');
- $this->assertEqual((string) $result[2], '{{ name }} == Name');
+ $this->assertEqual(trim($result[0]->getHtml()), '{{ age }} == Age');
+ $this->assertEqual(trim($result[1]->getHtml()), '{{ id }} == ID');
+ $this->assertEqual(trim($result[2]->getHtml()), '{{ name }} == Name');
$result = $this->xpath('//details[@id="edit-options-more"]');
$this->assertEqual(empty($result), TRUE, "Container 'more' is empty and should not be displayed.");
@@ -71,7 +71,7 @@ class FieldUITest extends UITestBase {
$edit_handler_url = '/admin/structure/views/ajax/handler-group/test_view/default/field/name';
$this->drupalGet($edit_handler_url);
- $data = Json::decode($this->getRawContent());
+ $data = Json::decode($this->getSession()->getPage()->getContent());
$this->assertEqual($data[3]['dialogOptions']['title'], 'Configure aggregation settings for field Views test: Name');
}
diff --git a/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php b/core/modules/views_ui/tests/src/Functional/FilterBooleanWebTest.php
index a3e58d7..e6adfee 100644
--- a/core/modules/views_ui/src/Tests/FilterBooleanWebTest.php
+++ b/core/modules/views_ui/tests/src/Functional/FilterBooleanWebTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the boolean filter UI.
@@ -25,7 +25,7 @@ class FilterBooleanWebTest extends UITestBase {
// Check the field widget label. 'title' should be used as a fallback.
$result = $this->cssSelect('#edit-options-value--wrapper legend span');
- $this->assertEqual((string) $result[0], 'Status');
+ $this->assertEqual($result[0]->getHtml(), 'Status');
$this->drupalPostForm(NULL, [], t('Expose filter'));
$this->drupalPostForm(NULL, [], t('Grouped filters'));
@@ -46,11 +46,11 @@ class FilterBooleanWebTest extends UITestBase {
$this->drupalGet('admin/structure/views/nojs/handler/test_view/default/filter/status');
$result = $this->xpath('//input[@name="options[group_info][group_items][1][value]"]');
- $this->assertEqual((int) $result[1]->attributes()->checked, 'checked');
+ $this->assertEqual($result[1]->getAttribute('checked'), 'checked');
$result = $this->xpath('//input[@name="options[group_info][group_items][2][value]"]');
- $this->assertEqual((int) $result[2]->attributes()->checked, 'checked');
+ $this->assertEqual($result[2]->getAttribute('checked'), 'checked');
$result = $this->xpath('//input[@name="options[group_info][group_items][3][value]"]');
- $this->assertEqual((int) $result[1]->attributes()->checked, 'checked');
+ $this->assertEqual($result[1]->getAttribute('checked'), 'checked');
// Test that there is a remove link for each group.
$this->assertEqual(count($this->cssSelect('a.views-remove-link')), 3);
diff --git a/core/modules/views_ui/src/Tests/FilterNumericWebTest.php b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
index 104d62f..8dc568d 100644
--- a/core/modules/views_ui/src/Tests/FilterNumericWebTest.php
+++ b/core/modules/views_ui/tests/src/Functional/FilterNumericWebTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\Tests\SchemaCheckTestTrait;
@@ -24,6 +24,12 @@ class FilterNumericWebTest extends UITestBase {
* Tests the filter numeric UI.
*/
public function testFilterNumericUI() {
+ // Add a page display to the test_view to be able to test the filtering.
+ $path = 'test_view-path';
+ $this->drupalPostForm('admin/structure/views/view/test_view/edit', [], 'Add Page');
+ $this->drupalPostForm('admin/structure/views/nojs/display/test_view/page_1/path', ['path' => $path], 'Apply');
+ $this->drupalPostForm(NULL, [], t('Save'));
+
$this->drupalPostForm('admin/structure/views/nojs/add-handler/test_view/default/filter', ['name[views_test_data.age]' => TRUE], t('Add and configure @handler', ['@handler' => t('filter criteria')]));
$this->drupalPostForm(NULL, [], t('Expose filter'));
@@ -52,13 +58,13 @@ class FilterNumericWebTest extends UITestBase {
$this->assertConfigSchemaByName('views.view.test_view');
// Test that the exposed filter works as expected.
- $this->drupalPostForm(NULL, [], t('Update preview'));
+ $this->drupalGet('test_view-path');
$this->assertText('John');
$this->assertText('Paul');
$this->assertText('Ringo');
$this->assertText('George');
$this->assertText('Meredith');
- $this->drupalPostForm(NULL, ['age' => '2'], t('Update preview'));
+ $this->drupalPostForm(NULL, ['age' => '2'], 'Apply');
$this->assertText('John');
$this->assertText('Paul');
$this->assertNoText('Ringo');
@@ -75,13 +81,13 @@ class FilterNumericWebTest extends UITestBase {
$this->assertConfigSchemaByName('views.view.test_view');
// Test that the filter works as expected.
- $this->drupalPostForm(NULL, [], t('Update preview'));
+ $this->drupalGet('test_view-path');
$this->assertText('John');
$this->assertNoText('Paul');
$this->assertNoText('Ringo');
$this->assertNoText('George');
$this->assertNoText('Meredith');
- $this->drupalPostForm(NULL, ['age' => '26'], t('Update preview'));
+ $this->drupalPostForm(NULL, ['age' => '26'], t('Apply'));
$this->assertNoText('John');
$this->assertText('Paul');
$this->assertNoText('Ringo');
@@ -106,7 +112,7 @@ class FilterNumericWebTest extends UITestBase {
$this->assertRaw('<label for="edit-age-max">And</label>', 'Max field label found');
$this->assertRaw('<label for="edit-age-min">Age between</label>', 'Min field label found');
// Check that the description is shown in the right place.
- $this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]), 'Description of the exposed filter');
+ $this->assertEqual(trim($this->cssSelect('.form-item-age-min .description')[0]->getText()), 'Description of the exposed filter');
}
}
diff --git a/core/modules/views_ui/src/Tests/FilterUITest.php b/core/modules/views_ui/tests/src/Functional/FilterUITest.php
index 1197fc6..18ada1b 100644
--- a/core/modules/views_ui/src/Tests/FilterUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/FilterUITest.php
@@ -1,15 +1,13 @@
<?php
-namespace Drupal\views_ui\Tests;
-
-use Drupal\views\Tests\ViewTestBase;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests for the filters from the UI.
*
* @group views_ui
*/
-class FilterUITest extends ViewTestBase {
+class FilterUITest extends UITestBase {
/**
@@ -29,10 +27,9 @@ class FilterUITest extends ViewTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->drupalCreateContentType(['type' => 'page']);
- $this->enableViewsTestModule();
}
/**
diff --git a/core/modules/views_ui/src/Tests/GroupByTest.php b/core/modules/views_ui/tests/src/Functional/GroupByTest.php
index 4b564c5..4a45d85 100644
--- a/core/modules/views_ui/src/Tests/GroupByTest.php
+++ b/core/modules/views_ui/tests/src/Functional/GroupByTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests UI of aggregate functionality..
diff --git a/core/modules/views_ui/src/Tests/HandlerTest.php b/core/modules/views_ui/tests/src/Functional/HandlerTest.php
index 8fb29f9..826cdc2 100644
--- a/core/modules/views_ui/src/Tests/HandlerTest.php
+++ b/core/modules/views_ui/tests/src/Functional/HandlerTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\Component\Utility\SafeMarkup;
use Drupal\field\Entity\FieldConfig;
@@ -31,10 +31,10 @@ class HandlerTest extends UITestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
- $this->drupalPlaceBlock('page_title_block');
+ $this->placeBlock('page_title_block');
ViewTestData::createTestViews(get_class($this), ['node_test_views']);
}
@@ -208,11 +208,11 @@ class HandlerTest extends UITestBase {
$text = 'Broken/missing handler';
- $this->assertIdentical((string) $result[0], $text, 'Ensure the broken handler text was found.');
+ $this->assertIdentical($result[0]->getText(), $text, 'Ensure the broken handler text was found.');
$this->drupalGet($href);
$result = $this->xpath('//h1[@class="page-title"]');
- $this->assertTrue(strpos((string) $result[0], $text) !== FALSE, 'Ensure the broken handler text was found.');
+ $this->assertContains($text, $result[0]->getText(), 'Ensure the broken handler text was found.');
$original_configuration = [
'field' => 'id_broken',
diff --git a/core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php b/core/modules/views_ui/tests/src/Functional/NewViewConfigSchemaTest.php
index 3318f0b..ef493ff 100644
--- a/core/modules/views_ui/src/Tests/NewViewConfigSchemaTest.php
+++ b/core/modules/views_ui/tests/src/Functional/NewViewConfigSchemaTest.php
@@ -1,15 +1,13 @@
<?php
-namespace Drupal\views_ui\Tests;
-
-use Drupal\simpletest\WebTestBase;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests configuration schema against new views.
*
* @group views_ui
*/
-class NewViewConfigSchemaTest extends WebTestBase {
+class NewViewConfigSchemaTest extends UITestBase {
/**
* Modules to enable.
diff --git a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php b/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php
index ba42542..24116d9 100644
--- a/core/modules/views_ui/src/Tests/OverrideDisplaysTest.php
+++ b/core/modules/views_ui/tests/src/Functional/OverrideDisplaysTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests that displays can be correctly overridden via the user interface.
@@ -9,8 +9,8 @@ namespace Drupal\views_ui\Tests;
*/
class OverrideDisplaysTest extends UITestBase {
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->drupalPlaceBlock('page_title_block');
}
@@ -51,7 +51,7 @@ class OverrideDisplaysTest extends UITestBase {
// Confirm that the view block is available in the block administration UI.
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
- $this->clickLinkPartialName('Place block');
+ $this->clickLink('Place block');
$this->assertText($view['label']);
// Place the block.
@@ -111,7 +111,7 @@ class OverrideDisplaysTest extends UITestBase {
// Confirm that the block is available in the block administration UI.
$this->drupalGet('admin/structure/block/list/' . $this->config('system.theme')->get('default'));
- $this->clickLinkPartialName('Place block');
+ $this->clickLink('Place block');
$this->assertText($view['label']);
// Put the block into the first sidebar region, and make sure it will not
diff --git a/core/modules/views_ui/src/Tests/QueryTest.php b/core/modules/views_ui/tests/src/Functional/QueryTest.php
index 066be3e..0eb58ce 100644
--- a/core/modules/views_ui/src/Tests/QueryTest.php
+++ b/core/modules/views_ui/tests/src/Functional/QueryTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
use Drupal\views\Entity\View;
diff --git a/core/modules/views_ui/src/Tests/RearrangeFieldsTest.php b/core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php
index 7d5eddf..125a7e9 100644
--- a/core/modules/views_ui/src/Tests/RearrangeFieldsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/RearrangeFieldsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
diff --git a/core/modules/views_ui/src/Tests/RedirectTest.php b/core/modules/views_ui/tests/src/Functional/RedirectTest.php
index cc5d246..4df38ce 100644
--- a/core/modules/views_ui/src/Tests/RedirectTest.php
+++ b/core/modules/views_ui/tests/src/Functional/RedirectTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the redirecting after saving a views.
diff --git a/core/modules/views_ui/src/Tests/ReportFieldsTest.php b/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php
index 9b2245e..d2527d0 100644
--- a/core/modules/views_ui/src/Tests/ReportFieldsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ReportFieldsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
diff --git a/core/modules/views_ui/src/Tests/ReportTest.php b/core/modules/views_ui/tests/src/Functional/ReportTest.php
index 0162519..e797993 100644
--- a/core/modules/views_ui/src/Tests/ReportTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ReportTest.php
@@ -1,14 +1,13 @@
<?php
-namespace Drupal\views_ui\Tests;
-use Drupal\simpletest\WebTestBase;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests existence of the views plugin report.
*
* @group views_ui
*/
-class ReportTest extends WebTestBase {
+class ReportTest extends UITestBase {
/**
* Modules to enable.
@@ -24,11 +23,6 @@ class ReportTest extends WebTestBase {
*/
protected $adminUser;
- protected function setUp() {
- parent::setUp();
- $this->adminUser = $this->drupalCreateUser(['administer views']);
- }
-
/**
* Tests the existence of the views plugin report.
*/
diff --git a/core/modules/views_ui/src/Tests/SettingsTest.php b/core/modules/views_ui/tests/src/Functional/SettingsTest.php
index f583185..1ac98c6 100644
--- a/core/modules/views_ui/src/Tests/SettingsTest.php
+++ b/core/modules/views_ui/tests/src/Functional/SettingsTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests all ui related settings under admin/structure/views/settings.
@@ -19,8 +19,8 @@ class SettingsTest extends UITestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->drupalPlaceBlock('local_tasks_block');
}
@@ -82,7 +82,7 @@ class SettingsTest extends UITestBase {
$view['id'] = strtolower($this->randomMachineName());
$this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
- $this->assertFieldById('edit-displays-top-add-display-embed');
+ $this->assertFieldById('edit-displays-top-add-display-embed', NULL);
$edit = [
'ui_show_display_embed' => FALSE,
@@ -116,8 +116,8 @@ class SettingsTest extends UITestBase {
$this->drupalPostForm(NULL, [], t('Update preview'));
$xpath = $this->xpath('//div[@class="views-query-info"]//pre');
$this->assertEqual(count($xpath), 1, 'The views sql is shown.');
- $this->assertFalse(strpos($xpath[0], 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
- $this->assertTrue(strpos($xpath[0], "node_field_data.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.');
+ $this->assertFalse(strpos($xpath[0]->getText(), 'db_condition_placeholder') !== FALSE, 'No placeholders are shown in the views sql.');
+ $this->assertTrue(strpos($xpath[0]->getText(), "node_field_data.status = '1'") !== FALSE, 'The placeholders in the views sql is replace by the actual value.');
// Test the advanced settings form.
diff --git a/core/modules/views_ui/src/Tests/StorageTest.php b/core/modules/views_ui/tests/src/Functional/StorageTest.php
index fa33b8f..df3d030 100644
--- a/core/modules/views_ui/src/Tests/StorageTest.php
+++ b/core/modules/views_ui/tests/src/Functional/StorageTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
use Drupal\views\Views;
diff --git a/core/modules/views_ui/src/Tests/StyleTableTest.php b/core/modules/views_ui/tests/src/Functional/StyleTableTest.php
index d6b757e..d00df33 100644
--- a/core/modules/views_ui/src/Tests/StyleTableTest.php
+++ b/core/modules/views_ui/tests/src/Functional/StyleTableTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
diff --git a/core/modules/views_ui/src/Tests/StyleUITest.php b/core/modules/views_ui/tests/src/Functional/StyleUITest.php
index 3fc2ae0..1eb9c78 100644
--- a/core/modules/views_ui/src/Tests/StyleUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/StyleUITest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
diff --git a/core/modules/views_ui/src/Tests/TokenizeAreaUITest.php b/core/modules/views_ui/tests/src/Functional/TokenizeAreaUITest.php
index 38eb475..df42d8e 100644
--- a/core/modules/views_ui/src/Tests/TokenizeAreaUITest.php
+++ b/core/modules/views_ui/tests/src/Functional/TokenizeAreaUITest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\entity_test\Entity\EntityTest;
use Drupal\views\Entity\View;
diff --git a/core/modules/views_ui/src/Tests/TranslatedViewTest.php b/core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php
index beaf5f1..7238ffa 100644
--- a/core/modules/views_ui/src/Tests/TranslatedViewTest.php
+++ b/core/modules/views_ui/tests/src/Functional/TranslatedViewTest.php
@@ -1,16 +1,15 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
use Drupal\language\Entity\ConfigurableLanguage;
-use Drupal\simpletest\WebTestBase;
/**
* Tests that translated strings in views UI don't override original strings.
*
* @group views_ui
*/
-class TranslatedViewTest extends WebTestBase {
+class TranslatedViewTest extends UITestBase {
/**
* Modules to enable.
@@ -38,8 +37,8 @@ class TranslatedViewTest extends WebTestBase {
*/
protected $adminUser;
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$permissions = [
'administer site configuration',
diff --git a/core/modules/views_ui/tests/src/Functional/UITestBase.php b/core/modules/views_ui/tests/src/Functional/UITestBase.php
new file mode 100644
index 0000000..684b91f
--- /dev/null
+++ b/core/modules/views_ui/tests/src/Functional/UITestBase.php
@@ -0,0 +1,90 @@
+<?php
+
+namespace Drupal\Tests\views_ui\Functional;
+
+use Drupal\Tests\views\Functional\ViewTestBase;
+
+/**
+ * Provides a base class for testing the Views UI.
+ */
+abstract class UITestBase extends ViewTestBase {
+
+ /**
+ * An admin user with the 'administer views' permission.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $adminUser;
+
+ /**
+ * An admin user with administrative permissions for views, blocks, and nodes.
+ *
+ * @var \Drupal\user\UserInterface
+ */
+ protected $fullAdminUser;
+
+ /**
+ * Modules to enable.
+ *
+ * @var array
+ */
+ public static $modules = ['node', 'views_ui', 'block', 'taxonomy'];
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
+
+ $this->enableViewsTestModule();
+
+ $this->adminUser = $this->drupalCreateUser(['administer views']);
+
+ $this->fullAdminUser = $this->drupalCreateUser(['administer views',
+ 'administer blocks',
+ 'bypass node access',
+ 'access user profiles',
+ 'view all revisions',
+ 'administer permissions',
+ ]);
+ $this->drupalLogin($this->fullAdminUser);
+ }
+
+ /**
+ * A helper method which creates a random view.
+ */
+ public function randomView(array $view = []) {
+ // Create a new view in the UI.
+ $default = [];
+ $default['label'] = $this->randomMachineName(16);
+ $default['id'] = strtolower($this->randomMachineName(16));
+ $default['description'] = $this->randomMachineName(16);
+ $default['page[create]'] = TRUE;
+ $default['page[path]'] = $default['id'];
+
+ $view += $default;
+
+ $this->drupalPostForm('admin/structure/views/add', $view, t('Save and edit'));
+
+ return $default;
+ }
+
+ /**
+ * {@inheritdoc}
+ */
+ protected function drupalGet($path, array $options = [], array $headers = []) {
+ $url = $this->buildUrl($path, $options);
+
+ // Ensure that each nojs page is accessible via ajax as well.
+ if (strpos($url, 'nojs') !== FALSE) {
+ $url = str_replace('nojs', 'ajax', $url);
+ $result = $this->drupalGet($url, $options);
+ $this->assertSession()->statusCodeEquals(200);
+ $this->assertEquals('application/json', $this->getSession()->getResponseHeader('Content-Type'));
+ $this->assertTrue(json_decode($result), 'Ensure that the AJAX request returned valid content.');
+ }
+
+ return parent::drupalGet($path, $options, $headers);
+ }
+
+}
diff --git a/core/modules/views_ui/src/Tests/UnsavedPreviewTest.php b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php
index 6418fc0..3265e1a 100644
--- a/core/modules/views_ui/src/Tests/UnsavedPreviewTest.php
+++ b/core/modules/views_ui/tests/src/Functional/UnsavedPreviewTest.php
@@ -1,15 +1,13 @@
<?php
-namespace Drupal\views_ui\Tests;
-
-use Drupal\views\Tests\ViewTestBase;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests covering Preview of unsaved Views.
*
* @group views_ui
*/
-class UnsavedPreviewTest extends ViewTestBase {
+class UnsavedPreviewTest extends UITestBase {
/**
* Views used by this test.
@@ -33,7 +31,7 @@ class UnsavedPreviewTest extends ViewTestBase {
/**
* Sets up a Drupal site for running functional and integration tests.
*/
- protected function setUp() {
+ protected function setUp($import_test_views = TRUE) {
parent::setUp(FALSE);
$this->adminUser = $this->drupalCreateUser(['administer views']);
diff --git a/core/modules/views_ui/src/Tests/ViewsListTest.php b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php
index 5178674..956ab9b 100644
--- a/core/modules/views_ui/src/Tests/ViewsListTest.php
+++ b/core/modules/views_ui/tests/src/Functional/ViewsListTest.php
@@ -1,8 +1,7 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
-use Drupal\simpletest\WebTestBase;
use Drupal\views\Entity\View;
use Drupal\views\Views;
@@ -11,7 +10,7 @@ use Drupal\views\Views;
*
* @group views_ui
*/
-class ViewsListTest extends WebTestBase {
+class ViewsListTest extends UITestBase {
/**
* Modules to enable.
@@ -30,8 +29,8 @@ class ViewsListTest extends WebTestBase {
/**
* {@inheritdoc}
*/
- protected function setUp() {
- parent::setUp();
+ protected function setUp($import_test_views = TRUE) {
+ parent::setUp($import_test_views);
$this->drupalPlaceBlock('local_tasks_block');
$this->drupalPlaceBlock('local_actions_block');
diff --git a/core/modules/views_ui/src/Tests/WizardTest.php b/core/modules/views_ui/tests/src/Functional/WizardTest.php
index 4e57e8f..8115481 100644
--- a/core/modules/views_ui/src/Tests/WizardTest.php
+++ b/core/modules/views_ui/tests/src/Functional/WizardTest.php
@@ -1,8 +1,8 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
-use Drupal\views\Tests\Wizard\WizardTestBase;
+use Drupal\Tests\views\Functional\Wizard\WizardTestBase;
/**
* Tests the wizard.
diff --git a/core/modules/views_ui/src/Tests/XssTest.php b/core/modules/views_ui/tests/src/Functional/XssTest.php
index 1c3cef6..cabb48e 100644
--- a/core/modules/views_ui/src/Tests/XssTest.php
+++ b/core/modules/views_ui/tests/src/Functional/XssTest.php
@@ -1,6 +1,6 @@
<?php
-namespace Drupal\views_ui\Tests;
+namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the Xss vulnerability.
diff --git a/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php b/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php
new file mode 100644
index 0000000..c8d37f2
--- /dev/null
+++ b/core/modules/views_ui/tests/src/FunctionalJavascript/DisplayTest.php
@@ -0,0 +1,125 @@
+<?php
+
+namespace Drupal\Tests\views_ui\FunctionalJavascript;
+
+use Drupal\FunctionalJavascriptTests\JavascriptTestBase;
+use Drupal\simpletest\NodeCreationTrait;
+use Drupal\views\Entity\View;
+use Drupal\views\Tests\ViewTestData;
+
+/**
+ * Tests the display UI.
+ *
+ * @group views_ui
+ */
+class DisplayTest extends JavascriptTestBase {
+
+ use NodeCreationTrait;
+
+ /**
+ * {@inheritdoc}
+ */
+ public static $modules = [
+ 'block',
+ 'contextual',
+ 'node',
+ 'views',
+ 'views_ui',
+ 'views_test_config',
+ ];
+
+ public static $testViews = ['test_content_ajax', 'test_display'];
+
+ /**
+ * {@inheritdoc}
+ */
+ public function setUp() {
+ parent::setUp();
+
+ ViewTestData::createTestViews(self::class, ['views_test_config']);
+
+ $admin_user = $this->drupalCreateUser([
+ 'administer site configuration',
+ 'administer views',
+ 'administer nodes',
+ 'access content overview',
+ 'access contextual links',
+ ]);
+
+ // Disable automatic live preview to make the sequence of calls clearer.
+ \Drupal::configFactory()->getEditable('views.settings')->set('ui.always_live_preview', FALSE)->save();
+ $this->drupalLogin($admin_user);
+ }
+
+ /**
+ * Tests adding a display.
+ */
+ public function testAddDisplay() {
+ $this->drupalGet('admin/structure/views/view/test_content_ajax');
+ $page = $this->getSession()->getPage();
+
+ $page->find('css', '#views-display-menu-tabs .add')->click();
+
+ // Wait for the animation to complete.
+ $this->assertSession()->assertWaitOnAjaxRequest();
+
+ // Add the diplay.
+ $page->find('css', '#edit-displays-top-add-display-block')->click();
+
+ $element = $page->findById('views-display-menu-tabs')->findLink('Block');
+ $this->assertNotEmpty($element);
+ }
+
+ /**
+ * Tests contextual links on Views page displays.
+ */
+ public function testPageContextualLinks() {
+ $view = View::load('test_display');
+ $view->enable()->save();
+ $this->container->get('router.builder')->rebuildIfNeeded();
+
+ // Create node so the view has content and the contextual area is higher
+ // than 0 pixels.
+ $this->drupalCreateContentType(['type' => 'page']);
+ $this->createNode();
+
+ // When no "main content" block is placed, we find a contextual link
+ // placeholder for editing just the view.
+ $this->drupalGet('test-display');
+ $page = $this->getSession()->getPage();
+ $this->assertSession()->assertWaitOnAjaxRequest();
+
+ $selector = '.view-test-display';
+ $this->toggleContextualTriggerVisibility($selector);
+
+ $element = $this->getSession()->getPage()->find('css', $selector);
+ $element->find('css', '.contextual button')->press();
+
+ $contextual_container_id = 'entity.view.edit_form:view=test_display:location=page&name=test_display&display_id=page_1&langcode=en';
+ $contextual_container = $page->find('css', '[data-contextual-id="' . $contextual_container_id . '"]');
+ $this->assertNotEmpty($contextual_container);
+
+ $edit_link = $contextual_container->findLink('Edit view');
+ $this->assertNotEmpty($edit_link);
+
+ // When a "main content" is placed, we still find a contextual link
+ // placeholder for editing just the view (not the main content block).
+ // @see system_block_view_system_main_block_alter()
+ $this->drupalPlaceBlock('system_main_block', ['id' => 'main_content']);
+ $contextual_container = $page->find('css', '[data-contextual-id="' . $contextual_container_id . '"]');
+ $this->assertNotEmpty($contextual_container);
+ }
+
+ /**
+ * Toggles the visibility of a contextual trigger.
+ *
+ * @param string $selector
+ * The selector for the element that contains the contextual Rink.
+ */
+ protected function toggleContextualTriggerVisibility($selector) {
+ // Hovering over the element itself with should be enough, but does not
+ // work. Manually remove the visually-hidden class.
+ $this->getSession()->executeScript("jQuery('{$selector} .contextual .trigger').toggleClass('visually-hidden');");
+ }
+
+}