Commit 1105324a authored by catch's avatar catch

Issue #2747167 by michielnugter, dawehner, Lendude, mglaman, Mac_Weber, Jo...

Issue #2747167 by michielnugter, dawehner, Lendude, mglaman, Mac_Weber, Jo Fitzgerald, klausi: Convert first part of web tests of views_ui
parent 359663bf
<?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',
......
<?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.
......
<?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 @@ public function testFilterUI() {
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 @@ public function testFilterUI() {
$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 = [
......
<?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']);
}
......
<?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']);
}
......
......@@ -6,6 +6,9 @@
/**
* 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 @@ protected function setUp() {
'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);
}
/**
......
<?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]);
......
<?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 @@ public function testUI() {
$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');
......
<?php
namespace Drupal\views_ui\Tests;
namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
......
<?php
namespace Drupal\views_ui\Tests;
namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the user tempstore cache in the UI.
......
<?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 @@ public function testCustomOptionTemplate() {
$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);
}
}
......
<?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 @@ public function testPathDestination() {
* 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 @@ public function clickViewsOperationLink($label, $unique_href_part) {
}
$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;
......
<?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 @@ public function testAttachmentUI() {
$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 @@ public function testAttachmentUI() {
$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');
......
<?php
namespace Drupal\views_ui\Tests;
namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
......
<?php
namespace Drupal\views_ui\Tests;
namespace Drupal\Tests\views_ui\Functional;
use Drupal\views\Views;
......
<?php
namespace Drupal\views_ui\Tests;
namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the UI for feed display plugin.
......@@ -57,10 +57,9 @@ protected function checkFeedViewUi($view_name) {
$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');
}
}
......
<?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 @@
* @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 @@ public function testMenuOptions() {
$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',
......
<?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 @@ public function testAddDisplay() {
$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 @@ public function testDisableDisplay() {
$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 @@ public function testDisplayAreas() {
// 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 @@ public function testLinkDisplay() {
// 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 @@ public function testLinkDisplay() {
$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.
......@@ -186,40 +177,6 @@ public function testLinkDisplay() {
$this->assertFieldByName('link_url', 'a-custom-url');
}
/**
* 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.
*/
......
<?php
namespace Drupal\views_ui\Tests;
namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the UI for view duplicate tool.
......@@ -9,10 +9,10 @@
*/
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');
}
/**
......
<?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 @@ public function testFieldUI() {
$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 @@ public function testFieldUI() {
$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');
}
......
<?php
namespace Drupal\views_ui\Tests;
namespace Drupal\Tests\views_ui\Functional;
/**
* Tests the boolean filter UI.
......@@ -25,7 +25,7 @@ public function testFilterBooleanUI() {
// 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 @@ public function testFilterBooleanUI() {
$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);
......
<?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 @@ public function testFilterNumericUI() {
$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 @@ public function testFilterNumericUI() {
$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->asser