Newer
Older
* Contains \Drupal\facets\Tests\IntegrationTest.
namespace Drupal\facets\Tests;
use Drupal\facets\Tests\WebTestBase as FacetWebTestBase;
* Tests the overall functionality of the Facets admin UI.
* @group facets
*/
class IntegrationTest extends FacetWebTestBase {
/**
* The block entities used by this test.
*
* @var \Drupal\block\BlockInterface[]
*/
protected $blocks;
/**
* {@inheritdoc}
*/
public function setUp() {
parent::setUp();
$this->drupalLogin($this->adminUser);
$this->setUpExampleStructure();
$this->insertExampleContent();
$this->assertEqual($this->indexItems($this->indexId), 5, '5 items were indexed.');
// Make absolutely sure the ::$blocks variable doesn't pass information
// along between tests.
$this->blocks = NULL;
*/
public function testOverviewPermissions() {
$facet_overview = '/admin/config/search/facets';
// Login with a user that is not authorized to administer facets and test
// that we're correctly getting a 403 HTTP response code.
$this->drupalLogin($this->unauthorizedUser);
$this->drupalGet($facet_overview);
$this->assertResponse(403);
$this->assertText('You are not authorized to access this page');
// Login with a user that has the correct permissions and test for the
// correct HTTP response code.
$this->drupalLogin($this->adminUser);
$this->drupalGet($facet_overview);
$this->assertResponse(200);
}
* Tests various operations via the Facets' admin UI.
$facet_name = "Test Facet name";
$facet_id = 'test_facet_name';
// Check if the overview is empty.
// Add a new facet and edit it.
$this->addFacet($facet_name);
$this->editFacet($facet_name);
Joris Vercammen
committed
// By default, the view should show all entities.
$this->drupalGet('search-api-test-fulltext');
$this->assertText('Displaying 5 search results', 'The search view displays the correct number of results.');
José Manuel Rodríguez Vélez
committed
// Create and place a block for "Test Facet name" facet.
$this->createFacetBlock($facet_id);
// Verify that the facet results are correct.
$this->drupalGet('search-api-test-fulltext');
Joris Vercammen
committed
$this->assertText('item');
$this->assertText('article');
José Manuel Rodríguez Vélez
committed
// Verify that facet blocks appear as expected.
$this->assertFacetBlocksAppear();
José Manuel Rodríguez Vélez
committed
// Show the facet only when the facet source is visible.
// @TODO Only for SearchApiViewsPage for the moment.
$this->setOptionShowOnlyWhenFacetSourceVisible($facet_name);
$this->goToDeleteFacetPage($facet_name);
Joris Vercammen
committed
$this->assertNoText('item');
$this->assertNoText('article');
José Manuel Rodríguez Vélez
committed
// Do not show the block on empty behaviors.
// Remove data from index.
$this->clearIndex();
$this->drupalGet('search-api-test-fulltext');
José Manuel Rodríguez Vélez
committed
// Verify that no facet blocks appear. Empty behavior "None" is selected by
// default.
$this->assertNoFacetBlocksAppear();
// Verify that the "empty_text" appears as expected.
$this->setEmptyBehaviorFacetText($facet_name);
$this->drupalGet('search-api-test-fulltext');
$this->assertRaw('block-test-facet-name');
José Manuel Rodríguez Vélez
committed
$this->assertRaw('No results found for this block!');
// Delete the block.
$this->deleteBlock($facet_id);
// Delete the facet and make sure the overview is empty again.
$this->deleteUnusedFacet($facet_name);
$this->checkEmptyOverview();
Joris Vercammen
committed
/**
* Tests renaming of a facet.
*
* @see https://www.drupal.org/node/2629504
*/
public function testRenameFacet() {
// Set names.
$facet_id = 'ab_facet';
$new_facet_id = 'facet__ab';
$facet_name = 'ab>Facet';
// Make sure we're logged in with a user that has sufficient permissions.
$this->drupalLogin($this->adminUser);
// Add a new facet.
$this->addFacet($facet_name);
$facet_edit_page = '/admin/config/search/facets/' . $facet_id . '/edit';
Joris Vercammen
committed
// Go to the facet edit page and make sure "edit facet %facet" is present.
$this->drupalGet($facet_edit_page);
$this->assertResponse(200);
$this->assertRaw($this->t('Edit facet @facet', ['@facet' => $facet_name]));
// Change the machine name to a new name and check that the redirected page
// is the correct url.
$form = ['id' => $new_facet_id];
$this->drupalPostForm($facet_edit_page, $form, $this->t('Save'));
$expected_url = '/admin/config/search/facets/' . $new_facet_id . '/edit';
Joris Vercammen
committed
$this->assertUrl($expected_url);
}
Joris Vercammen
committed
/**
* Tests that an url alias works correctly.
*/
public function testUrlAlias() {
$facet_id = 'ab_facet';
$facet_name = 'ab>Facet';
// Make sure we're logged in with a user that has sufficient permissions.
$this->drupalLogin($this->adminUser);
$facet_add_page = '/admin/config/search/facets/add-facet';
$facet_edit_page = '/admin/config/search/facets/' . $facet_id . '/edit';
Joris Vercammen
committed
$this->drupalGet($facet_add_page);
$this->assertResponse(200);
$form_values = [
'name' => $facet_name,
'id' => $facet_id,
'status' => 1,
'facet_source_id' => 'search_api_views:search_api_test_view:page_1',
'facet_source_configs[search_api_views:search_api_test_view:page_1][field_identifier]' => 'type',
Joris Vercammen
committed
];
$this->drupalPostForm(NULL, ['facet_source_id' => 'search_api_views:search_api_test_view:page_1'], $this->t('Configure facet source'));
Joris Vercammen
committed
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertText($this->t('The name of the facet for usage in URLs field is required.'));
$form_values['url_alias'] = 'test';
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertRaw(t('Facet %name has been created.', ['%name' => $facet_name]));
$this->createFacetBlock($facet_id);
$this->drupalGet('search-api-test-fulltext');
$this->assertLink('item');
$this->assertLink('article');
$this->clickLink('item');
$url = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['f[0]' => 'test:item']]);
$this->assertUrl($url);
Joris Vercammen
committed
$this->drupalGet($facet_edit_page);
$this->drupalPostForm(NULL, ['url_alias' => 'llama'], $this->t('Save'));
$this->drupalGet('search-api-test-fulltext');
$this->assertLink('item');
$this->assertLink('article');
$this->clickLink('item');
$url = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['f[0]' => 'llama:item']]);
$this->assertUrl($url);
Joris Vercammen
committed
}
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
/**
* Tests facet dependencies.
*/
public function testFacetDependencies() {
$facet_name = "DependableFacet";
$facet_id = 'dependablefacet';
$this->addFacet($facet_name);
$depending_facet_name = "DependingFacet";
$depending_facet_id = "dependingfacet";
$this->addFacet($depending_facet_name, 'keywords');
// Create both facets as blocks and add them on the page.
$this->createFacetBlock($facet_id);
$this->createFacetBlock($depending_facet_id);
// Go the the view and test that both facets are shown. Item and article
// come from the DependableFacet, orange and grape come from DependingFacet.
$this->drupalGet('search-api-test-fulltext');
$this->assertLink('grape');
$this->assertLink('orange');
$this->assertLink('item');
$this->assertLink('article');
$this->assertFacetBlocksAppear();
// Change the visiblity settings of the DependingFacet.
$this->drupalGet('admin/structure/block/manage/dependingfacet');
$edit = [
'visibility[other_facet][facets]' => 'facet_block:dependablefacet',
'visibility[other_facet][facet_value]' => 'item',
];
$this->drupalPostForm(NULL, $edit, $this->t('Save block'));
$this->assertText('The block configuration has been saved.');
// Go to the view and test that only the types are shown.
$this->drupalGet('search-api-test-fulltext');
$this->assertNoLink('grape');
$this->assertNoLink('orange');
$this->assertLink('item');
$this->assertLink('article');
// Click on the item, and test that this shows the keywords.
$this->clickLink('item');
$this->assertLink('grape');
$this->assertLink('orange');
// Go back to the view, click on article and test that the keywords are
// hidden.
$this->drupalGet('search-api-test-fulltext');
$this->clickLink('article');
$this->assertNoLink('grape');
$this->assertNoLink('orange');
// Change the visibility settings to negate the previous settings.
$this->drupalGet('admin/structure/block/manage/dependingfacet');
$edit = [
'visibility[other_facet][facets]' => 'facet_block:dependablefacet',
'visibility[other_facet][facet_value]' => 'item',
'visibility[other_facet][negate]' => TRUE,
];
$this->drupalPostForm(NULL, $edit, $this->t('Save block'));
// Go the the view and test only the type facet is shown.
$this->drupalGet('search-api-test-fulltext');
$this->assertLink('item');
$this->assertLink('article');
$this->assertLink('grape');
$this->assertLink('orange');
// Click on the article, and test that this shows the keywords.
$this->clickLink('article');
$this->assertLink('grape');
$this->assertLink('orange');
// Go back to the view, click on item and test that the keywords are
// hidden.
$this->drupalGet('search-api-test-fulltext');
$this->clickLink('item');
$this->assertNoLink('grape');
$this->assertNoLink('orange');
}
Joris Vercammen
committed
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
/**
* Tests the facet's and/or functionality.
*/
public function testAndOrFacet() {
$facet_name = 'test & facet';
$facet_id = 'test_facet';
$facet_edit_page = 'admin/config/search/facets/' . $facet_id . '/display';
$this->drupalLogin($this->adminUser);
$this->addFacet($facet_name);
$this->createFacetBlock('test_facet');
$this->drupalGet($facet_edit_page);
$this->drupalPostForm(NULL, ['facet_settings[query_operator]' => 'AND'], $this->t('Save'));
$this->insertExampleContent();
$this->assertEqual($this->indexItems($this->indexId), 5, '5 items were indexed.');
$this->drupalGet('search-api-test-fulltext');
$this->assertLink('item');
$this->assertLink('article');
$this->clickLink('item');
$this->assertLink('(-) item');
$this->assertNoLink('article');
$this->drupalGet($facet_edit_page);
$this->drupalPostForm(NULL, ['facet_settings[query_operator]' => 'OR'], $this->t('Save'));
$this->drupalGet('search-api-test-fulltext');
$this->assertLink('item');
$this->assertLink('article');
$this->clickLink('item');
$this->assertLink('(-) item');
$this->assertLink('article');
}
Joris Vercammen
committed
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
/**
* Tests that we disallow unwanted values.
*/
public function testUnwantedValues() {
// Go to the Add facet page and make sure that returns a 200.
$facet_add_page = '/admin/config/search/facets/add-facet';
$this->drupalGet($facet_add_page);
$this->assertResponse(200);
// Configure the facet source by selecting one of the search api views.
$this->drupalGet($facet_add_page);
$this->drupalPostForm(NULL, ['facet_source_id' => 'search_api_views:search_api_test_view:page_1'], $this->t('Configure facet source'));
// Fill in all fields and make sure the 'field is required' message is no
// longer shown.
$facet_source_form = [
'facet_source_id' => 'search_api_views:search_api_test_view:page_1',
'facet_source_configs[search_api_views:search_api_test_view:page_1][field_identifier]' => 'type',
];
$this->drupalPostForm(NULL, $facet_source_form, $this->t('Save'));
$form_values = [
'name' => 'name 1',
'id' => 'name 1',
'status' => 1,
'url_alias' => 'name',
];
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertText($this->t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
$form_values = [
'name' => 'name 1',
'id' => 'name:&1',
'status' => 1,
'url_alias' => 'name',
];
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertText($this->t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
$form_values = [
'name' => 'name 1',
'id' => 'name_1',
'status' => 1,
'url_alias' => 'name:1',
];
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertText($this->t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
$form_values = [
'name' => 'name 1',
'id' => 'name_1',
'status' => 1,
'url_alias' => 'name_1',
];
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertNoText($this->t('The machine-readable name must contain only lowercase letters, numbers, and underscores.'));
}
Joris Vercammen
committed
/**
* Tests for processor integration.
*/
public function testProcessorIntegration() {
$facet_name = "Snowy owl~";
$facet_id = "snowy_owl_";
$this->addFacet($facet_name);
// Go to the processors form and check that the count limit processor is not
// checked.
$this->drupalGet('admin/config/search/facets/' . $facet_id . '/display');
$this->assertNoFieldChecked('edit-facet-settings-count-limit-status');
$form = ['facet_settings[count_limit][status]' => TRUE];
$this->drupalPostForm(NULL, $form, $this->t('Save'));
$this->assertResponse(200);
$this->assertFieldChecked('edit-facet-settings-count-limit-status');
Joris Vercammen
committed
Evaldas Užkuras
committed
// Enable the sort processor and change sort direction.
// Test that the sort settings change persisted.
$form = [
'facet_sorting[active_widget_order][status]' => TRUE,
'facet_sorting[active_widget_order][settings][sort]' => 'DESC',
];
$this->drupalPostForm(NULL, $form, $this->t('Save'));
$this->assertResponse(200);
$this->assertFieldChecked('edit-facet-sorting-active-widget-order-status');
$this->assertFieldChecked('edit-facet-sorting-active-widget-order-settings-sort-desc');
Joris Vercammen
committed
// Add an extra processor so we can test the weights as well.
$form = [
'facet_settings[hide_non_narrowing_result_processor][status]' => TRUE,
'facet_settings[count_limit][status]' => TRUE,
];
$this->drupalPostForm(NULL, $form, $this->t('Save'));
$this->assertResponse(200);
$this->assertFieldChecked('edit-facet-settings-count-limit-status');
$this->assertFieldChecked('edit-facet-settings-hide-non-narrowing-result-processor-status');
$this->assertOptionSelected('edit-processors-count-limit-weights-build', -10);
$this->assertOptionSelected('edit-processors-hide-non-narrowing-result-processor-weights-build', -10);
// Change the weight of one of the processors and test that the weight
// change persisted.
$form = [
'facet_settings[hide_non_narrowing_result_processor][status]' => TRUE,
'facet_settings[count_limit][status]' => TRUE,
'processors[hide_non_narrowing_result_processor][weights][build]' => 5,
];
$this->drupalPostForm(NULL, $form, $this->t('Save'));
$this->assertFieldChecked('edit-facet-settings-count-limit-status');
$this->assertFieldChecked('edit-facet-settings-hide-non-narrowing-result-processor-status');
$this->assertOptionSelected('edit-processors-count-limit-weights-build', -10);
$this->assertOptionSelected('edit-processors-hide-non-narrowing-result-processor-weights-build', 5);
Joris Vercammen
committed
}
/**
* Deletes a facet block by id.
*
* @param string $id
* The id of the block.
*/
José Manuel Rodríguez Vélez
committed
protected function deleteBlock($id) {
$this->drupalGet('admin/structure/block/manage/' . $this->blocks[$id]->id(), array('query' => array('destination' => 'admin')));
$this->clickLink(t('Delete'));
$this->drupalPostForm(NULL, array(), t('Delete'));
$this->assertRaw(t('The block %name has been deleted.', array('%name' => $this->blocks[$id]->label())));
}
/**
* Helper function: asserts that a facet block does not appear.
*/
José Manuel Rodríguez Vélez
committed
protected function assertNoFacetBlocksAppear() {
foreach ($this->blocks as $block) {
$this->assertNoBlockAppears($block);
}
}
/**
* Helper function: asserts that a facet block appears.
*/
José Manuel Rodríguez Vélez
committed
protected function assertFacetBlocksAppear() {
foreach ($this->blocks as $block) {
$this->assertBlockAppears($block);
}
}
/**
* Creates a facet block by id.
*
* @param string $id
* The id of the block.
*/
José Manuel Rodríguez Vélez
committed
protected function createFacetBlock($id) {
Joris Vercammen
committed
$block = [
'plugin_id' => 'facet_block:' . $id,
'settings' => [
'region' => 'footer',
'id' => str_replace('_', '-', $id),
],
José Manuel Rodríguez Vélez
committed
];
Joris Vercammen
committed
$this->blocks[$id] = $this->drupalPlaceBlock($block['plugin_id'], $block['settings']);
José Manuel Rodríguez Vélez
committed
}
/**
* Configures empty behavior option to show a text on empty results.
*
* @param string $facet_name
*/
protected function setEmptyBehaviorFacetText($facet_name) {
$facet_id = $this->convertNameToMachineName($facet_name);
$facet_display_page = '/admin/config/search/facets/' . $facet_id . '/display';
// Go to the facet edit page and make sure "edit facet %facet" is present.
$this->drupalGet($facet_display_page);
$this->assertResponse(200);
// Configure the text for empty results behavior.
$edit = [
'facet_settings[empty_behavior]' => 'text',
'facet_settings[empty_behavior_container][empty_behavior_text][value]' => 'No results found for this block!',
];
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
José Manuel Rodríguez Vélez
committed
/**
* Configures a facet to only be visible when accessing to the facet source.
*
* @param string $facet_name
José Manuel Rodríguez Vélez
committed
*/
protected function setOptionShowOnlyWhenFacetSourceVisible($facet_name) {
$facet_id = $this->convertNameToMachineName($facet_name);
$facet_display_page = '/admin/config/search/facets/' . $facet_id . '/display';
$this->drupalGet($facet_display_page);
José Manuel Rodríguez Vélez
committed
$this->assertResponse(200);
'facet_settings[only_visible_when_facet_source_is_visible]' => TRUE,
'widget' => 'links',
'widget_configs[show_numbers]' => '0',
];
$this->drupalPostForm(NULL, $edit, $this->t('Save'));
José Manuel Rodríguez Vélez
committed
}
Joris Vercammen
committed
/**
* Get the facet overview page and make sure the overview is empty.
Joris Vercammen
committed
*/
$facet_overview = '/admin/config/search/facets';
$this->drupalGet($facet_overview);
$this->assertResponse(200);
// The list overview has Field: field_name as description. This tests on the
// absence of that.
/**
* Tests adding a facet trough the interface.
* @param string $facet_name
* The name of the facet.
protected function addFacet($facet_name, $facet_type = 'type') {
$facet_id = $this->convertNameToMachineName($facet_name);
// Go to the Add facet page and make sure that returns a 200.
$facet_add_page = '/admin/config/search/facets/add-facet';
$this->drupalGet($facet_add_page);
$this->assertResponse(200);
Joris Vercammen
committed
'status' => 1,
Joris Vercammen
committed
'url_alias' => $facet_id,
// Try filling out the form, but without having filled in a name for the
// facet to test for form errors.
$this->drupalPostForm($facet_add_page, $form_values, $this->t('Save'));
$this->assertText($this->t('Facet name field is required.'));
$this->assertText($this->t('Facet source field is required.'));
// Make sure that when filling out the name, the form error disappears.
$form_values['name'] = $facet_name;
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertNoText($this->t('Facet name field is required.'));
// Configure the facet source by selecting one of the search api views.
$this->drupalGet($facet_add_page);
$this->drupalPostForm(NULL, ['facet_source_id' => 'search_api_views:search_api_test_view:page_1'], $this->t('Configure facet source'));
Joris Vercammen
committed
// The facet field is still required.
$this->drupalPostForm(NULL, $form_values, $this->t('Save'));
$this->assertText($this->t('Facet field field is required.'));
// Fill in all fields and make sure the 'field is required' message is no
// longer shown.
'facet_source_id' => 'search_api_views:search_api_test_view:page_1',
'facet_source_configs[search_api_views:search_api_test_view:page_1][field_identifier]' => $facet_type,
];
$this->drupalPostForm(NULL, $form_values + $facet_source_form, $this->t('Save'));
$this->assertNoText('field is required.');
Joris Vercammen
committed
// Make sure that the redirection to the display page is correct.
$this->assertRaw(t('Facet %name has been created.', ['%name' => $facet_name]));
Joris Vercammen
committed
$this->assertUrl('admin/config/search/facets/' . $facet_id . '/display');
$this->drupalGet('admin/config/search/facets');
/**
* Tests editing of a facet through the UI.
*
* @param string $facet_name
* The name of the facet.
*/
public function editFacet($facet_name) {
$facet_id = $this->convertNameToMachineName($facet_name);
$facet_edit_page = '/admin/config/search/facets/' . $facet_id . '/edit';
// Go to the facet edit page and make sure "edit facet %facet" is present.
$this->drupalGet($facet_edit_page);
$this->assertResponse(200);
$this->assertRaw($this->t('Edit facet @facet', ['@facet' => $facet_name]));
// Change the facet name to add in "-2" to test editing of a facet works.
$form_values = ['name' => $facet_name . ' - 2'];
$this->drupalPostForm($facet_edit_page, $form_values, $this->t('Save'));
// Make sure that the redirection back to the overview was successful and
// the edited facet is shown on the overview page.
$this->assertRaw(t('Facet %name has been updated.', ['%name' => $facet_name . ' - 2']));
// Make sure the "-2" suffix is still on the facet when editing a facet.
$this->drupalGet($facet_edit_page);
$this->assertRaw($this->t('Edit facet @facet', ['@facet' => $facet_name . ' - 2']));
// Edit the form and change the facet's name back to the initial name.
$form_values = ['name' => $facet_name];
$this->drupalPostForm($facet_edit_page, $form_values, $this->t('Save'));
// Make sure that the redirection back to the overview was successful and
// the edited facet is shown on the overview page.
$this->assertRaw(t('Facet %name has been updated.', ['%name' => $facet_name]));
Joris Vercammen
committed
/**
* This deletes an unused facet through the UI.
*
* @param string $facet_name
Joris Vercammen
committed
*/
José Manuel Rodríguez Vélez
committed
protected function deleteUsedFacet($facet_name) {
$facet_id = $this->convertNameToMachineName($facet_name);
$facet_delete_page = '/admin/config/search/facets/' . $facet_id . '/delete';
José Manuel Rodríguez Vélez
committed
// Go to the facet delete page and make the warning is shown.
$this->drupalGet($facet_delete_page);
$this->assertResponse(200);
// Check that the facet by testing for the message and the absence of the
// facet name on the overview.
$this->assertRaw($this->t('The facet is currently used in a block and thus can\'t be removed. Remove the block first.'));
}
/**
* This deletes a facet through the UI.
*
* @param string $facet_name
José Manuel Rodríguez Vélez
committed
*/
Joris Vercammen
committed
protected function deleteUnusedFacet($facet_name) {
$facet_id = $this->convertNameToMachineName($facet_name);
Joris Vercammen
committed
$facet_delete_page = '/admin/config/search/facets/' . $facet_id . '/delete';
Joris Vercammen
committed
// Go to the facet delete page and make the warning is shown.
$this->drupalGet($facet_delete_page);
$this->assertResponse(200);
// @TODO Missing this text on local test. Not sure why.
// $this->assertText($this->t('Are you sure you want to delete the facet'));
Joris Vercammen
committed
// Actually submit the confirmation form.
$this->drupalPostForm(NULL, [], $this->t('Delete'));
// Check that the facet by testing for the message and the absence of the
// facet name on the overview.
$this->assertRaw($this->t('The facet %facet has been deleted.', ['%facet' => $facet_name]));
// Refresh the page because on the previous page the $facet_name is still
// visible (in the message).
$facet_overview = '/admin/config/search/facets';
Joris Vercammen
committed
$this->drupalGet($facet_overview);
$this->assertResponse(200);
$this->assertNoText($facet_name);
}
/**
* Add fields to search api index.
*/
'fields[entity:node/nid][indexed]' => 1,
'fields[entity:node/title][indexed]' => 1,
'fields[entity:node/title][type]' => 'text',
'fields[entity:node/title][boost]' => '21.0',
'fields[entity:node/body][indexed]' => 1,
'fields[entity:node/uid][indexed]' => 1,
'fields[entity:node/uid][type]' => 'search_api_test_data_type',
$this->drupalPostForm('admin/config/search/search-api/index/webtest_index/fields', $edit, $this->t('Save changes'));
$this->assertText($this->t('The changes were successfully saved.'));
}
* @param string $facet_name
* The name of the facet.
* @return string
* The facet name changed to a machine name.
*/
protected function convertNameToMachineName($facet_name) {
return preg_replace('@[^a-zA-Z0-9_]+@', '_', strtolower($facet_name));
}
José Manuel Rodríguez Vélez
committed
/**
* Go to the Delete Facet Page using the facet name.
*
* @param string $facet_name
José Manuel Rodríguez Vélez
committed
*/
protected function goToDeleteFacetPage($facet_name) {
$facet_id = $this->convertNameToMachineName($facet_name);
$facet_delete_page = '/admin/config/search/facets/' . $facet_id . '/delete';
José Manuel Rodríguez Vélez
committed
// Go to the facet delete page and make the warning is shown.
$this->drupalGet($facet_delete_page);
$this->assertResponse(200);
}