Commit 843b6b5c authored by pfrenssen's avatar pfrenssen Committed by StryKaizer

Issue #2919439 by pfrenssen, borisson_: Add schema for all processors and test that it works

parent ce38b047
plugin.plugin_configuration.facets_processor.*:
type: config_object
plugin.plugin_configuration.facets_processor.count_widget_widget_order:
type: mapping
label: 'Count widget order'
......@@ -87,17 +90,25 @@ plugin.plugin_configuration.facets_processor.boolean_item:
type: string
label: 'Off value'
plugin.plugin_configuration.facets_processor.url_processor_handler:
type: config_object
plugin.plugin_configuration.facets_processor.hide_non_narrowing_result_processor:
type: config_object
plugin.plugin_configuration.facets_processor.hide_active_items_processor:
type: config_object
plugin.plugin_configuration.facets_processor.list_item:
type: config_object
plugin.plugin_configuration.facets_processor.dependent_processor:
type: sequence
label: 'Dependent facet processor'
sequence:
type: mapping
label: Mapping for a processor
mapping:
enable:
type: boolean
label: 'Enable for this facet'
condition:
type: string
label: 'Type of condition'
values:
type: label
label: 'The value of the condition'
negate:
type: boolean
label: 'Should the condition be negated'
plugin.plugin_configuration.facets_processor.date_item:
type: mapping
......
plugin.plugin_configuration.facets_processor.invalid_qt:
type: config_object
plugin.plugin_configuration.facets_processor.test_pre_query:
type: mapping
label: Configuration
mapping:
test_value:
type: label
label: The value used for testing
......@@ -2,6 +2,8 @@
namespace Drupal\facets_custom_widget\Plugin\facets\processor;
use Drupal\facets\FacetInterface;
use Drupal\facets\Processor\PreQueryProcessorInterface;
use Drupal\facets\Processor\ProcessorPluginBase;
/**
......@@ -16,7 +18,7 @@ use Drupal\facets\Processor\ProcessorPluginBase;
* }
* )
*/
class InvalidQT extends ProcessorPluginBase {
class InvalidQT extends ProcessorPluginBase implements PreQueryProcessorInterface {
/**
* {@inheritdoc}
......@@ -25,4 +27,10 @@ class InvalidQT extends ProcessorPluginBase {
return '51_pegasi_b';
}
/**
* {@inheritdoc}
*/
public function preQuery(FacetInterface $facet) {
// This can be empty for this test implementation.
}
}
......@@ -2,6 +2,8 @@
namespace Drupal\Tests\facets\Functional;
use Drupal\facets\Entity\Facet;
use Drupal\facets\Processor\SortProcessorInterface;
use Drupal\field\Entity\FieldConfig;
use Drupal\field\Entity\FieldStorageConfig;
use Drupal\search_api\Item\Field;
......@@ -716,4 +718,34 @@ class ProcessorIntegrationTest extends FacetsTestBase {
$this->assertSession()->pageTextNotContains('Transform entity ID to label');
}
/**
* Tests the configuration of the processors.
*/
public function testProcessorConfig() {
$this->createFacet('Llama', 'llama');
$facet_id = 'alpaca';
$this->editForm = 'admin/config/search/facets/' . $facet_id . '/edit';
$this->createFacet('Alpaca', $facet_id);
$this->drupalGet($this->editForm);
$facet = Facet::load($facet_id);
/** @var \Drupal\facets\Processor\ProcessorInterface $processor */
foreach ($facet->getProcessors(FALSE) as $processor) {
// Sort processors have a different form key, so don't bother for now.
if ($processor instanceof SortProcessorInterface) {
continue;
}
// These processors are hidden by default, see also
// ::testHiddenProcessors.
if (in_array($processor->getPluginId(), ['boolean_item', 'translate_entity', 'uid_to_username_callback'])) {
continue;
}
$this->drupalPostForm(NULL, ["facet_settings[{$processor->getPluginId()}][status]" => '1'], 'Save');
$this->assertSession()->statusCodeEquals(200);
}
}
}
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