diff --git a/src/Plugin/facets/widget/CheckboxWidget.php b/src/Plugin/facets/widget/CheckboxWidget.php index eb7e23e..bb71fed 100644 --- a/src/Plugin/facets/widget/CheckboxWidget.php +++ b/src/Plugin/facets/widget/CheckboxWidget.php @@ -159,6 +159,7 @@ class CheckboxWidget implements WidgetInterface, FormInterface { // We have an active item, so redirecting to that page. if ($result_link instanceof Url) { + $result_link->setAbsolute(); $form_state->setResponse(new RedirectResponse($result_link->toString())); return; } diff --git a/src/Tests/WidgetIntegrationTest.php b/src/Tests/WidgetIntegrationTest.php new file mode 100644 index 0000000..5f91902 --- /dev/null +++ b/src/Tests/WidgetIntegrationTest.php @@ -0,0 +1,83 @@ +drupalLogin($this->adminUser); + + $this->setUpExampleStructure(); + $this->insertExampleContent(); + $this->assertEqual($this->indexItems($this->indexId), 5, '5 items were indexed.'); + } + + /** + * Tests various url integration things. + */ + public function testCheckboxWidget() { + $id = 't'; + $name = 'Facet & checkbox~'; + $facet_add_page = 'admin/config/search/facets/add-facet'; + + $this->drupalGet($facet_add_page); + + $form_values = [ + 'id' => $id, + 'status' => 1, + 'url_alias' => $id, + 'name' => $name, + '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_id' => 'search_api_views:search_api_test_view:page_1'], $this->t('Configure facet source')); + $this->drupalPostForm(NULL, $form_values, $this->t('Save')); + $this->drupalPostForm(NULL, ['widget' => 'checkbox'], $this->t('Save')); + + $block_values = [ + 'plugin_id' => 'facet_block:' . $id, + 'settings' => [ + 'region' => 'footer', + 'id' => str_replace('_', '-', $id), + ] + ]; + $this->drupalPlaceBlock($block_values['plugin_id'], $block_values['settings']); + + $this->drupalGet('search-api-test-fulltext'); + $this->drupalPostForm(NULL, array('type[item]' => 'item'), $this->t('submit')); + $this->assertFieldChecked('edit-type-item'); + } + +}