<?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;
$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');
}
/**
$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.');
}
// 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]));
}
}
// 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');
$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.
$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.
*/