Commit 62ba47d2 authored by alexpott's avatar alexpott
Browse files

Revert "Issue #2085243 by dawehner: Rename Menu module into Menu UI module."

This reverts commit 07f63fe6.
parent f122f874
<?php
/**
* @file
* Contains Drupal\search\Tests\SearchQueryAlterTest.
*/
namespace Drupal\search\Tests;
/**
* Tests that the node search query can be altered via the query alter hook.
*/
class SearchQueryAlterTest extends SearchTestBase {
/**
* Modules to enable.
*
* @var array
*/
public static $modules = array('search_query_alter');
public static function getInfo() {
return array(
'name' => 'Search query alter',
'description' => 'Tests that the node search query can be altered via the query alter hook.',
'group' => 'Search'
);
}
/**
* Tests that the query alter works.
*/
function testQueryAlter() {
// Login with sufficient privileges.
$this->drupalLogin($this->drupalCreateUser(array('create page content', 'search content')));
// Create a node and an article with the same keyword. The query alter
// test module will alter the query so only articles should be returned.
$data = array(
'type' => 'page',
'title' => 'test page',
'body' => array(array('value' => 'pizza')),
);
$this->drupalCreateNode($data);
$data['type'] = 'article';
$data['title'] = 'test article';
$this->drupalCreateNode($data);
// Update the search index.
$this->container->get('plugin.manager.search')->createInstance('node_search')->updateIndex();
search_update_totals();
// Search for the body keyword 'pizza'.
$this->drupalPostForm('search/node', array('keys' => 'pizza'), t('Search'));
// The article should be there but not the page.
$this->assertText('article', 'Article is in search results');
$this->assertNoText('page', 'Page is not in search results');
}
}
......@@ -8,7 +8,6 @@
namespace Drupal\search\Tests;
use Drupal\simpletest\WebTestBase;
use Drupal\Component\Utility\String;
/**
* Defines the common search test code.
......@@ -31,66 +30,4 @@ function setUp() {
$this->drupalCreateContentType(array('type' => 'article', 'name' => 'Article'));
}
}
/**
* Simulates submission of a form using GET instead of POST.
*
* Forms that use the GET method cannot be submitted with
* WebTestBase::drupalPostForm(), which explicitly uses POST to submit the
* form. So this method finds the form, verifies that it has input fields and
* a submit button matching the inputs to this method, and then calls
* WebTestBase::drupalGet() to simulate the form submission to the 'action'
* URL of the form (if set, or the current URL if not).
*
* See WebTestBase::drupalPostForm() for more detailed documentation of the
* function parameters.
*
* @param string $path
* Location of the form to be submitted: either a Drupal path, absolute
* path, or NULL to use the current page.
* @param array $edit
* Form field data to submit. Unlike drupalPostForm(), this does not support
* file uploads.
* @param string $submit
* Value of the submit button to submit clicking. Unlike drupalPostForm(),
* this does not support AJAX.
* @param string $form_html_id
* (optional) HTML ID of the form, to disambiguate.
*/
protected function submitGetForm($path, $edit, $submit, $form_html_id = NULL) {
if (isset($path)) {
$this->drupalGet($path);
}
if ($this->parse()) {
// Iterate over forms to find one that matches $edit and $submit.
$edit_save = $edit;
$xpath = '//form';
if (!empty($form_html_id)) {
$xpath .= "[@id='" . $form_html_id . "']";
}
$forms = $this->xpath($xpath);
foreach ($forms as $form) {
// Try to set the fields of this form as specified in $edit.
$edit = $edit_save;
$post = array();
$upload = array();
$submit_matches = $this->handleForm($post, $edit, $upload, $submit, $form);
if (!$edit && $submit_matches) {
// Everything matched, so "submit" the form.
$action = isset($form['action']) ? $this->getAbsoluteUrl((string) $form['action']) : NULL;
$this->drupalGet($action, array('query' => $post));
return;
}
}
// We have not found a form which contained all fields of $edit and
// the submit button.
foreach ($edit as $name => $value) {
$this->fail(String::format('Failed to set field @name to @value', array('@name' => $name, '@value' => $value)));
}
$this->assertTrue($submit_matches, format_string('Found the @submit button', array('@submit' => $submit)));
$this->fail(format_string('Found the requested form fields at @path', array('@path' => $path)));
}
}
}
......@@ -18,7 +18,6 @@ class ViewsSearchQuery extends SearchQuery {
* Returns the conditions property.
*
* @return array
* The query conditions.
*/
public function &conditions() {
return $this->conditions;
......@@ -28,7 +27,6 @@ public function &conditions() {
* Returns the words property.
*
* @return array
* The positive search keywords.
*/
public function words() {
return $this->words;
......@@ -38,8 +36,6 @@ public function words() {
* Returns the simple property.
*
* @return bool
* TRUE if it is a simple query, and FALSE if it is complicated (phrases
* or LIKE).
*/
public function simple() {
return $this->simple;
......@@ -49,7 +45,6 @@ public function simple() {
* Returns the matches property.
*
* @return int
* The number of matches needed.
*/
public function matches() {
return $this->matches;
......
......@@ -815,19 +815,3 @@ function search_module_preinstall() {
// @todo Remove in https://drupal.org/node/2155635.
\Drupal::service('plugin.manager.search')->clearCachedDefinitions();
}
/**
* Implements hook_form_FORM_ID_alter() for the search_block_form form.
*
* Since the exposed form is a GET form, we don't want it to send the form
* tokens. However, you cannot make this happen in the form builder function
* itself, because the tokens are added to the form after the builder function
* is called. So, we have to do it in a form_alter.
*
* @see \Drupal\search\Form\SearchBlockForm
*/
function search_form_search_block_form_alter(&$form, &$form_state) {
$form['form_build_id']['#access'] = FALSE;
$form['form_token']['#access'] = FALSE;
$form['form_id']['#access'] = FALSE;
}
......@@ -10,7 +10,7 @@
use Drupal\search\Plugin\ConfigurableSearchPluginBase;
/**
* Executes a dummy keyword search.
* Executes a keyword search against the search index.
*
* @SearchPlugin(
* id = "search_extra_type_search",
......@@ -33,7 +33,7 @@ public function setSearch($keywords, array $parameters, array $attributes) {
* Verifies if the given parameters are valid enough to execute a search for.
*
* @return bool
* TRUE if there are keywords or search conditions in the query.
* A true or false depending on the implementation.
*/
public function isSearchExecutable() {
return (bool) ($this->keywords || !empty($this->searchParameters['search_conditions']));
......
name: 'Test Search Query Alter'
type: module
description: 'Support module for Search module testing.'
package: Testing
version: VERSION
core: 8.x
hidden: true
<?php
use Drupal\Core\Database\Query\AlterableInterface;
/**
* @file
* Test module that alters search queries.
*/
/**
* Implements hook_query_TAG_alter(): tag search_$type with $type node_search.
*/
function search_query_alter_query_search_node_search_alter(AlterableInterface $query) {
// For testing purposes, restrict the query to node type 'article' only.
$query->condition('n.type', 'article');
}
......@@ -2162,8 +2162,6 @@ protected function handleForm(&$post, &$edit, &$upload, $submit, $form) {
}
}
}
// An empty name means the value is not sent.
unset($post['']);
return $submit_matches;
}
......
......@@ -15,7 +15,7 @@
*
* @see \Drupal\system\Tests\Bootstrap\PageCacheTest
* @see \Drupal\node\Tests\NodePageCacheTest
* @see \Drupal\menu_ui\Tests\MenuTest::testMenuBlockPageCacheTags()
* @see \Drupal\menu\Tests\MenuTest::testMenuBlockPageCacheTags()
*/
class PageCacheTagsIntegrationTest extends WebTestBase {
......
......@@ -7,4 +7,4 @@ core: 8.x
hidden: true
dependencies:
- test_page_test
- menu_ui
- menu
......@@ -53,7 +53,7 @@ class ToolbarAdminMenuTest extends WebTestBase {
*
* @var array
*/
public static $modules = array('node', 'block', 'menu_ui', 'user', 'taxonomy', 'toolbar', 'language', 'test_page_test', 'locale');
public static $modules = array('node', 'block', 'menu', 'user', 'taxonomy', 'toolbar', 'language', 'test_page_test', 'locale');
public static function getInfo() {
return array(
......
......@@ -19,7 +19,7 @@ class UserAccountLinksTests extends WebTestBase {
*
* @var array
*/
public static $modules = array('menu_ui', 'block', 'test_page_test');
public static $modules = array('menu', 'block', 'test_page_test');
public static function getInfo() {
return array(
......
......@@ -34,7 +34,7 @@ function testUserSearch() {
$this->drupalLogin($user1);
$keys = $user1->getEmail();
$edit = array('keys' => $keys);
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->drupalPostForm('search/user/', $edit, t('Search'));
$this->assertNoText($keys);
$this->drupalLogout();
......@@ -42,7 +42,7 @@ function testUserSearch() {
$this->drupalLogin($user2);
$keys = $user2->getEmail();
$edit = array('keys' => $keys);
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->drupalPostForm('search/user/', $edit, t('Search'));
$this->assertText($keys);
// Create a blocked user.
......@@ -53,14 +53,14 @@ function testUserSearch() {
// Verify that users with "administer users" permissions can see blocked
// accounts in search results.
$edit = array('keys' => $blocked_user->getUsername());
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->drupalPostForm('search/user/', $edit, t('Search'));
$this->assertText($blocked_user->getUsername(), 'Blocked users are listed on the user search results for users with the "administer users" permission.');
// Verify that users without "administer users" permissions do not see
// blocked accounts in search results.
$this->drupalLogin($user1);
$edit = array('keys' => $blocked_user->getUsername());
$this->drupalPostForm('search/user', $edit, t('Search'));
$this->drupalPostForm('search/user/', $edit, t('Search'));
$this->assertNoText($blocked_user->getUsername(), 'Blocked users are hidden from the user search results.');
$this->drupalLogout();
......
......@@ -217,11 +217,11 @@ public function buildOptionsForm(&$form, &$form_state) {
);
// Only display the menu selector if menu module is enabled.
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
if (\Drupal::moduleHandler()->moduleExists('menu')) {
$form['menu']['name'] = array(
'#title' => t('Menu'),
'#type' => 'select',
'#options' => menu_ui_get_menus(),
'#options' => menu_get_menus(),
'#default_value' => $menu['name'],
'#states' => array(
'visible' => array(
......@@ -334,11 +334,11 @@ public function buildOptionsForm(&$form, &$form_state) {
),
);
// Only display the menu selector if menu module is enabled.
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
if (\Drupal::moduleHandler()->moduleExists('menu')) {
$form['tab_options']['name'] = array(
'#title' => t('Menu'),
'#type' => 'select',
'#options' => menu_ui_get_menus(),
'#options' => menu_get_menus(),
'#default_value' => $tab_options['name'],
'#description' => t('Insert item into an available menu.'),
'#states' => array(
......
......@@ -292,8 +292,8 @@ public function buildForm(array $form, array &$form_state) {
'#prefix' => '<div id="edit-page-link-properties-wrapper">',
'#suffix' => '</div>',
);
if (\Drupal::moduleHandler()->moduleExists('menu_ui')) {
$menu_options = menu_ui_get_menus();
if (\Drupal::moduleHandler()->moduleExists('menu')) {
$menu_options = menu_get_menus();
}
else {
// These are not yet translated.
......
......@@ -59,7 +59,7 @@ public function testDeleteWithNoPath() {
* Tests the menu and tab option form.
*/
public function testMenuOptions() {
$this->container->get('module_handler')->install(array('menu_ui'));
$this->container->get('module_handler')->install(array('menu'));
$this->drupalGet('admin/structure/views/view/test_view');
// Add a new page display.
......
......@@ -21,7 +21,7 @@ dependencies:
- entity_reference
- help
- image
- menu_ui
- menu
- options
- path
- taxonomy
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment