Commit 981941ff authored by borisson_'s avatar borisson_ Committed by borisson_
Browse files

Issue #2638330 by borisson_: Enable testing on drupal.org for patches

parent 3875fa23
......@@ -16,10 +16,22 @@ use Drupal\facets\Tests\WebTestBase as FacetWebTestBase;
*/
class FacetSourceTest extends FacetWebTestBase {
/**
* {@inheritdoc}
*/
public static $modules = [
'views',
'search_api',
'search_api_test_backend',
'facets',
'facets_search_api_dependency',
'facets_query_processor',
];
/**
* Test the facet source editing.
*/
public function testFacetSource() {
public function testEditFilterKey() {
// Make sure we're logged in with a user that has sufficient permissions.
$this->drupalLogin($this->adminUser);
......@@ -31,16 +43,44 @@ class FacetSourceTest extends FacetWebTestBase {
// Test the edit page.
$edit = array(
'filterKey' => 'fq',
'urlProcessor' => 'query_string',
);
$this->assertField('filterKey');
$this->assertField('urlProcessor');
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
$this->assertResponse(200);
// Test that saving worked.
// Test that saving worked filterkey has the new value
$this->assertField('filterKey');
$this->assertField('urlProcessor');
$this->assertRaw('fq');
}
/**
* Tests editing the url processor.
*/
public function testEditUrlProcessor() {
// Make sure we're logged in with a user that has sufficient permissions.
$this->drupalLogin($this->adminUser);
// Test the overview.
$this->drupalGet('admin/config/search/facets');
$this->assertLink($this->t('Configure'));
$this->clickLink($this->t('Configure'));
// Test the edit page.
$edit = array(
'urlProcessor' => 'dummy_query',
);
$this->assertField('filterKey');
$this->assertField('urlProcessor');
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
$this->assertResponse(200);
// Test that saving worked and that the url processor has the new value.
$this->assertField('filterKey');
$this->assertField('urlProcessor');
$elements = $this->xpath('//input[@id=:id]', [':id' => 'edit-urlprocessor-dummy-query']);
$this->assertEqual('dummy_query', $elements[0]['value']);
}
}
......@@ -7,7 +7,10 @@
namespace Drupal\facets\Tests;
use Drupal\Core\Url;
use Drupal\facets\Tests\WebTestBase as FacetWebTestBase;
use Drupal\facets\Entity\Facet;
use Drupal\facets\FacetSourceInterface;
/**
* Tests the overall functionality of the Facets admin UI.
......@@ -25,7 +28,6 @@ class UrlIntegrationTest extends FacetWebTestBase {
'search_api',
'search_api_test_backend',
'facets',
'search_api_test_views',
'block',
'facets_search_api_dependency',
'facets_query_processor',
......@@ -65,25 +67,80 @@ class UrlIntegrationTest extends FacetWebTestBase {
$this->drupalPostForm(NULL, ['facet_source_id' => 'search_api_views:search_api_test_view:page_1'], $this->t('Configure facet source'));
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
// Go to the only enabled facet source's config.
$block_values = [
'plugin_id' => 'facet_block:' . $id,
'settings' => [
'region' => 'footer',
'id' => str_replace('_', '-', $id),
]
];
$this->drupalPlaceBlock($block_values['plugin_id'], $block_values['settings']);
$url = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['f[0]' => 'facet:item']]);
$this->checkClickedFacetUrl($url);
/** @var \Drupal\facets\FacetInterface $facet */
$facet = Facet::load($id);
$config = $facet->getFacetSourceConfig();
$this->assertTrue($config instanceof FacetSourceInterface);
$this->assertEqual(NULL, $config->getFilterKey());
$facet = NULL;
$config = NULL;
// Go to the only enabled facet source's config and change the filter key.
$this->drupalGet('admin/config/search/facets');
$this->clickLink($this->t('Configure'));
$edit = [
'filterKey' => 'y',
'urlProcessor' => 'dummy_query',
'urlProcessor' => 'query_string',
];
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
$block_values = [
'plugin_id' => 'facet_block:' . $id,
'settings' => [
'region' => 'footer',
'id' => str_replace('_', '-', $id),
]
/** @var \Drupal\facets\FacetInterface $facet */
$facet = Facet::load($id);
$config = $facet->getFacetSourceConfig();
$this->assertTrue($config instanceof FacetSourceInterface);
$this->assertEqual('y', $config->getFilterKey());
$facet = NULL;
$config = NULL;
$url_2 = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['y[0]' => 'facet:item']]);
$this->checkClickedFacetUrl($url_2);
// Go to the only enabled facet source's config and change the url
// processor.
$this->drupalGet('admin/config/search/facets');
$this->clickLink($this->t('Configure'));
$edit = [
'filterKey' => 'y',
'urlProcessor' => 'dummy_query',
];
$this->drupalPlaceBlock($block_values['plugin_id'], $block_values['settings']);
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
/** @var \Drupal\facets\FacetInterface $facet */
$facet = Facet::load($id);
$config = $facet->getFacetSourceConfig();
$this->assertTrue($config instanceof FacetSourceInterface);
$this->assertEqual('y', $config->getFilterKey());
$facet = NULL;
$config = NULL;
$url_3 = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['y[0]' => 'facet||item']]);
$this->checkClickedFacetUrl($url_3);
}
/**
* Checks that the url after clicking a facet is as expected.
*
* @param \Drupal\Core\Url $url
* The expected url we end on.
*/
protected function checkClickedFacetUrl(Url $url) {
$this->drupalGet('search-api-test-fulltext');
$this->assertResponse(200);
$this->assertLink('item');
......@@ -94,7 +151,7 @@ class UrlIntegrationTest extends FacetWebTestBase {
$this->assertResponse(200);
$this->assertLink('(-) item');
$this->assertNoLink('article');
$this->assertUrl('search-api-test-fulltext', ['query' => ['y[0]' => 'facet||item']]);
$this->assertUrl($url);
}
}
......@@ -40,7 +40,6 @@ abstract class WebTestBase extends SimpletestWebTestBase {
'search_api',
'search_api_test_backend',
'facets',
'search_api_test_views',
'block',
'facets_search_api_dependency',
];
......
......@@ -25,7 +25,6 @@ class WidgetIntegrationTest extends FacetWebTestBase {
'search_api',
'search_api_test_backend',
'facets',
'search_api_test_views',
'block',
'facets_search_api_dependency',
'facets_query_processor',
......
base_field: search_api_id
base_table: search_api_index_database_search_index
core: 8.x
description: ''
status: true
display:
default:
display_plugin: default
id: default
display_title: Master
position: 0
display_options:
access:
type: none
options: { }
cache:
type: none
options: { }
query:
type: search_api_query
options:
search_api_bypass_access: false
entity_access: false
parse_mode: terms
exposed_form:
type: basic
options:
submit_button: Search
reset_button: false
reset_button_label: Reset
exposed_sorts_label: 'Sort by'
expose_sort_order: true
sort_asc_label: Asc
sort_desc_label: Desc
pager:
type: full
options:
items_per_page: 10
offset: 0
id: 0
total_pages: null
expose:
items_per_page: false
items_per_page_label: 'Items per page'
items_per_page_options: '5, 10, 20, 40, 60'
items_per_page_options_all: false
items_per_page_options_all_label: '- All -'
offset: false
offset_label: Offset
tags:
previous: ' previous'
next: 'next ›'
first: '« first'
last: 'last »'
quantity: 9
style:
type: default
row:
type: search_api
options:
view_modes:
bundle:
'article': default
'page': default
datasource:
'entity:entity_test': default
fields:
search_api_id:
table: search_api_index_database_search_index
field: search_api_id
id: search_api_id
plugin_id: numeric
relationship: none
group_type: group
admin_label: ''
label: 'Entity ID'
exclude: false
alter:
alter_text: false
text: ''
make_link: false
path: ''
absolute: false
external: false
replace_spaces: false
path_case: none
trim_whitespace: false
alt: ''
rel: ''
link_class: ''
prefix: ''
suffix: ''
target: ''
nl2br: false
max_length: 0
word_boundary: true
ellipsis: true
more_link: false
more_link_text: ''
more_link_path: ''
strip_tags: false
trim: false
preserve_tags: ''
html: false
element_type: ''
element_class: ''
element_label_type: ''
element_label_class: ''
element_label_colon: true
element_wrapper_type: ''
element_wrapper_class: ''
element_default_classes: true
empty: ''
hide_empty: false
empty_zero: false
hide_alter_empty: true
set_precision: false
precision: 0
decimal: .
separator: ','
format_plural: false
format_plural_string: "1\x03@count"
prefix: ''
suffix: ''
filters:
search_api_fulltext:
id: search_api_fulltext
table: search_api_index_database_search_index
field: search_api_fulltext
relationship: none
group_type: group
admin_label: ''
operator: and
value: ''
group: 1
exposed: true
expose:
operator_id: search_api_fulltext_op
label: 'Fulltext search'
description: ''
use_operator: false
operator: search_api_fulltext_op
identifier: search_api_fulltext
required: false
remember: false
multiple: false
remember_roles:
authenticated: authenticated
anonymous: '0'
administrator: '0'
is_grouped: false
group_info:
label: ''
description: ''
identifier: ''
optional: true
widget: select
multiple: false
remember: false
default_group: All
default_group_multiple: { }
group_items: { }
min_length: 0
fields: { }
plugin_id: search_api_fulltext
sorts: { }
title: 'Fulltext test index'
header:
result:
id: result
table: views
field: result
relationship: none
group_type: group
admin_label: ''
empty: false
content: 'Displaying @total search results'
plugin_id: result
footer: { }
empty: { }
relationships: { }
arguments: { }
page_1:
display_plugin: page
id: page_1
display_title: Page
position: 1
display_options:
path: search-api-test-fulltext
label: 'Search API Test Fulltext search view'
module: views
id: search_api_test_view
tag: ''
langcode: en
dependencies:
module:
- search_api
- facets_search_api_dependency
......@@ -5,4 +5,6 @@ package: 'Search'
core: 8.x
hidden: true
dependencies:
- search_api
- search_api:search_api
- search_api:search_api_test_db
- drupal:views
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