public function ProcessorIntegrationTest::testProcessorAdmin in Facets 8
Tests for the processors behavior in the backend.
File
- tests/
src/ Functional/ ProcessorIntegrationTest.php, line 52
Class
- ProcessorIntegrationTest
- Tests the processor functionality.
Namespace
Drupal\Tests\facets\FunctionalCode
public function testProcessorAdmin() {
$facet_name = "Guanaco";
$facet_id = "guanaco";
$this
->createFacet($facet_name, $facet_id);
// Go to the processors form and check that the count limit processor is not
// checked.
$this
->drupalGet('admin/config/search/facets/' . $facet_id . '/edit');
$this
->assertSession()
->checkboxNotChecked('edit-facet-settings-count-limit-status');
$form = [
'facet_settings[count_limit][status]' => TRUE,
];
$this
->drupalPostForm(NULL, $form, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->checkboxChecked('edit-facet-settings-count-limit-status');
// Enable the sort processor and change sort direction, check that the
// change is persisted.
$form = [
'facet_sorting[active_widget_order][status]' => TRUE,
'facet_sorting[active_widget_order][settings][sort]' => 'DESC',
];
$this
->drupalPostForm(NULL, $form, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->checkboxChecked('edit-facet-sorting-active-widget-order-status');
$this
->assertSession()
->checkboxChecked('edit-facet-sorting-active-widget-order-settings-sort-desc');
// 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, 'Save');
$this
->assertSession()
->statusCodeEquals(200);
$this
->assertSession()
->checkboxChecked('edit-facet-settings-count-limit-status');
$this
->assertSession()
->checkboxChecked('edit-facet-settings-hide-non-narrowing-result-processor-status');
$this
->assertOptionSelected('edit-processors-count-limit-weights-build', 50);
$this
->assertOptionSelected('edit-processors-hide-non-narrowing-result-processor-weights-build', 40);
// 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, 'Save');
$this
->assertSession()
->checkboxChecked('edit-facet-settings-count-limit-status');
$this
->assertSession()
->checkboxChecked('edit-facet-settings-hide-non-narrowing-result-processor-status');
$this
->assertOptionSelected('edit-processors-count-limit-weights-build', 50);
$this
->assertOptionSelected('edit-processors-hide-non-narrowing-result-processor-weights-build', 5);
}