Loading modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -2,10 +2,13 @@ namespace Drupal\Tests\facets_range_widget\Unit\Plugin\widget; use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Url; use Drupal\facets\Entity\Facet; use Drupal\facets\FacetSource\FacetSourcePluginManager; use Drupal\facets\Result\Result; use Drupal\facets\UrlProcessor\UrlProcessorInterface; use Drupal\facets\Widget\WidgetPluginManager; use Drupal\facets_range_widget\Plugin\facets\widget\SliderWidget; use Drupal\Tests\facets\Unit\Plugin\widget\WidgetTestBase; Loading Loading @@ -65,6 +68,8 @@ class SliderWidgetTest extends WidgetTestBase { * Tests building of the widget. */ public function testBuild() { $facet = new Facet(['id' => 'barn_owl'], 'facets_facet'); $widget = $this->prophesize(SliderWidget::class); $widget->getConfiguration()->willReturn(['show_numbers' => FALSE]); $pluginManager = $this->prophesize(WidgetPluginManager::class); Loading @@ -73,8 +78,16 @@ class SliderWidgetTest extends WidgetTestBase { $url_generator = $this->prophesize(UrlGeneratorInterface::class); $entity_type_manager = $this->prophesize(EntityTypeManager::class); $url_processor = $this->prophesize(UrlProcessorInterface::class); $manager = $this->createMock(FacetSourcePluginManager::class); $manager->method('createInstance')->willReturn($url_processor->reveal()); $container = new ContainerBuilder(); $container->set('plugin.manager.facets.widget', $pluginManager->reveal()); $container->set('plugin.manager.facets.url_processor', $manager); $container->set('entity_type.manager', $entity_type_manager->reveal()); $container->set('url_generator', $url_generator->reveal()); \Drupal::setContainer($container); Loading tests/src/Functional/Rest/FacetResourceTestBase.php +1 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ abstract class FacetResourceTestBase extends EntityResourceTestBase { protected function getExpectedCacheContexts() { return array_merge(parent::getExpectedCacheContexts(), [ 'url.query_args', 'facets_filter:f', ]); } Loading tests/src/FunctionalJavascript/AjaxBehaviorTest.php +16 −11 Original line number Diff line number Diff line Loading @@ -47,8 +47,9 @@ class AjaxBehaviorTest extends JsBase { $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']); $this->assertNotEmpty($links); // Click the item facet. $this->clickLink('item'); // Click the item facets. $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 3 search results'); Loading @@ -58,7 +59,7 @@ class AjaxBehaviorTest extends JsBase { $this->assertEmpty($links); // Click the item facet again, and check that the article facet is back. $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 5 search results'); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']); Loading @@ -67,7 +68,8 @@ class AjaxBehaviorTest extends JsBase { // Check that the strawberry link disappears when filtering on items. $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertNotEmpty($links); $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertEmpty($links); Loading Loading @@ -95,13 +97,14 @@ class AjaxBehaviorTest extends JsBase { // Check that the article_category option disappears when filtering on item. $dropdown_entry = $this->xpath('//*[@id="block-duck-block"]/div/select/option[normalize-space(text())=:label]', [':label' => 'article_category']); $this->assertNotEmpty($dropdown_entry); $block_owl->clickLink('item'); $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $dropdown_entry = $this->xpath('//*[@id="block-duck-block"]/div/select/option[normalize-space(text())=:label]', [':label' => 'article_category']); $this->assertEmpty($dropdown_entry); // Click the item facet again. $block_owl->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Select the article_category in the dropdown. Loading Loading @@ -143,7 +146,8 @@ class AjaxBehaviorTest extends JsBase { $this->assertNotEmpty($links); // Click the item facet. $this->clickLink('item'); $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 3 search results'); Loading @@ -153,7 +157,7 @@ class AjaxBehaviorTest extends JsBase { $this->assertEmpty($links); // Click the item facet again, and check that the article facet is back. $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 5 search results'); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']); Loading @@ -162,11 +166,11 @@ class AjaxBehaviorTest extends JsBase { // Check that the strawberry link disappears when filtering on items. $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertNotEmpty($links); $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertEmpty($links); $this->clickLink('item'); $owl_link->click(); $this->getSession()->getPage()->checkField('strawberry'); // Check that the article link exists (and is formatted like a facet) link. Loading Loading @@ -198,7 +202,8 @@ class AjaxBehaviorTest extends JsBase { $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 3 search results'); $this->clickLink('item'); $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 1 search results'); } Loading tests/src/FunctionalJavascript/WidgetJSTest.php +5 −12 Original line number Diff line number Diff line Loading @@ -353,21 +353,18 @@ class WidgetJSTest extends JsBase { '', TRUE, ], // The second option should have the expected option text, have the URI // that points to the updated search result as the value, and is not // selected. [ 'item (3)', base_path() . 'search-api-test-fulltext?f%5B0%5D=llama%3Aitem', 'llama:item', FALSE, ], // The third option is similar. [ 'article (2)', base_path() . 'search-api-test-fulltext?f%5B0%5D=llama%3Aarticle', 'llama:article', FALSE, ], ]; $this->assertSelectOptions($expected, $options); // Selecting one of the options should cause a redirect to a page with Loading @@ -391,18 +388,14 @@ class WidgetJSTest extends JsBase { base_path() . 'search-api-test-fulltext', FALSE, ], // The second option should now be selected, and since clicking it again // would negate it, it should also link to the search page without any // chosen facets. [ 'item (3)', base_path() . 'search-api-test-fulltext', 'llama:item', TRUE, ], // The third option remains unchanged. [ 'article (2)', base_path() . 'search-api-test-fulltext?f%5B0%5D=llama%3Aarticle', 'llama:article', FALSE, ], ]; Loading tests/src/Kernel/FacetManager/DefaultFacetManagerTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ class DefaultFacetManagerTest extends EntityKernelTestBase { $query->getCacheContexts(), $facet_mars->getFacetSource()->getCacheContexts(), [ 'facets_filter:f', 'fpc_query_type_plugin', 'dummy_query_pre_query', ] Loading Loading @@ -334,6 +335,7 @@ class DefaultFacetManagerTest extends EntityKernelTestBase { // Added by views view source plugin. 'url', 'languages:language_interface', 'facets_filter:f', ], 'tags' => [ // Facet controls query and look & feel of the facet results, so it's Loading Loading
modules/facets_range_widget/tests/src/Unit/Plugin/widget/SliderWidgetTest.php +13 −0 Original line number Diff line number Diff line Loading @@ -2,10 +2,13 @@ namespace Drupal\Tests\facets_range_widget\Unit\Plugin\widget; use Drupal\Core\Entity\EntityTypeManager; use Drupal\Core\Routing\UrlGeneratorInterface; use Drupal\Core\Url; use Drupal\facets\Entity\Facet; use Drupal\facets\FacetSource\FacetSourcePluginManager; use Drupal\facets\Result\Result; use Drupal\facets\UrlProcessor\UrlProcessorInterface; use Drupal\facets\Widget\WidgetPluginManager; use Drupal\facets_range_widget\Plugin\facets\widget\SliderWidget; use Drupal\Tests\facets\Unit\Plugin\widget\WidgetTestBase; Loading Loading @@ -65,6 +68,8 @@ class SliderWidgetTest extends WidgetTestBase { * Tests building of the widget. */ public function testBuild() { $facet = new Facet(['id' => 'barn_owl'], 'facets_facet'); $widget = $this->prophesize(SliderWidget::class); $widget->getConfiguration()->willReturn(['show_numbers' => FALSE]); $pluginManager = $this->prophesize(WidgetPluginManager::class); Loading @@ -73,8 +78,16 @@ class SliderWidgetTest extends WidgetTestBase { $url_generator = $this->prophesize(UrlGeneratorInterface::class); $entity_type_manager = $this->prophesize(EntityTypeManager::class); $url_processor = $this->prophesize(UrlProcessorInterface::class); $manager = $this->createMock(FacetSourcePluginManager::class); $manager->method('createInstance')->willReturn($url_processor->reveal()); $container = new ContainerBuilder(); $container->set('plugin.manager.facets.widget', $pluginManager->reveal()); $container->set('plugin.manager.facets.url_processor', $manager); $container->set('entity_type.manager', $entity_type_manager->reveal()); $container->set('url_generator', $url_generator->reveal()); \Drupal::setContainer($container); Loading
tests/src/Functional/Rest/FacetResourceTestBase.php +1 −0 Original line number Diff line number Diff line Loading @@ -125,6 +125,7 @@ abstract class FacetResourceTestBase extends EntityResourceTestBase { protected function getExpectedCacheContexts() { return array_merge(parent::getExpectedCacheContexts(), [ 'url.query_args', 'facets_filter:f', ]); } Loading
tests/src/FunctionalJavascript/AjaxBehaviorTest.php +16 −11 Original line number Diff line number Diff line Loading @@ -47,8 +47,9 @@ class AjaxBehaviorTest extends JsBase { $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']); $this->assertNotEmpty($links); // Click the item facet. $this->clickLink('item'); // Click the item facets. $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 3 search results'); Loading @@ -58,7 +59,7 @@ class AjaxBehaviorTest extends JsBase { $this->assertEmpty($links); // Click the item facet again, and check that the article facet is back. $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 5 search results'); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']); Loading @@ -67,7 +68,8 @@ class AjaxBehaviorTest extends JsBase { // Check that the strawberry link disappears when filtering on items. $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertNotEmpty($links); $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertEmpty($links); Loading Loading @@ -95,13 +97,14 @@ class AjaxBehaviorTest extends JsBase { // Check that the article_category option disappears when filtering on item. $dropdown_entry = $this->xpath('//*[@id="block-duck-block"]/div/select/option[normalize-space(text())=:label]', [':label' => 'article_category']); $this->assertNotEmpty($dropdown_entry); $block_owl->clickLink('item'); $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $dropdown_entry = $this->xpath('//*[@id="block-duck-block"]/div/select/option[normalize-space(text())=:label]', [':label' => 'article_category']); $this->assertEmpty($dropdown_entry); // Click the item facet again. $block_owl->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); // Select the article_category in the dropdown. Loading Loading @@ -143,7 +146,8 @@ class AjaxBehaviorTest extends JsBase { $this->assertNotEmpty($links); // Click the item facet. $this->clickLink('item'); $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 3 search results'); Loading @@ -153,7 +157,7 @@ class AjaxBehaviorTest extends JsBase { $this->assertEmpty($links); // Click the item facet again, and check that the article facet is back. $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 5 search results'); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'article']); Loading @@ -162,11 +166,11 @@ class AjaxBehaviorTest extends JsBase { // Check that the strawberry link disappears when filtering on items. $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertNotEmpty($links); $this->clickLink('item'); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $links = $this->xpath('//a//span[normalize-space(text())=:label]', [':label' => 'strawberry']); $this->assertEmpty($links); $this->clickLink('item'); $owl_link->click(); $this->getSession()->getPage()->checkField('strawberry'); // Check that the article link exists (and is formatted like a facet) link. Loading Loading @@ -198,7 +202,8 @@ class AjaxBehaviorTest extends JsBase { $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 3 search results'); $this->clickLink('item'); $owl_link = $this->assertSession()->elementExists("xpath", "//label[@for='owl-item']/span[1]"); $owl_link->click(); $this->assertSession()->assertWaitOnAjaxRequest(); $this->assertSession()->pageTextContains('Displaying 1 search results'); } Loading
tests/src/FunctionalJavascript/WidgetJSTest.php +5 −12 Original line number Diff line number Diff line Loading @@ -353,21 +353,18 @@ class WidgetJSTest extends JsBase { '', TRUE, ], // The second option should have the expected option text, have the URI // that points to the updated search result as the value, and is not // selected. [ 'item (3)', base_path() . 'search-api-test-fulltext?f%5B0%5D=llama%3Aitem', 'llama:item', FALSE, ], // The third option is similar. [ 'article (2)', base_path() . 'search-api-test-fulltext?f%5B0%5D=llama%3Aarticle', 'llama:article', FALSE, ], ]; $this->assertSelectOptions($expected, $options); // Selecting one of the options should cause a redirect to a page with Loading @@ -391,18 +388,14 @@ class WidgetJSTest extends JsBase { base_path() . 'search-api-test-fulltext', FALSE, ], // The second option should now be selected, and since clicking it again // would negate it, it should also link to the search page without any // chosen facets. [ 'item (3)', base_path() . 'search-api-test-fulltext', 'llama:item', TRUE, ], // The third option remains unchanged. [ 'article (2)', base_path() . 'search-api-test-fulltext?f%5B0%5D=llama%3Aarticle', 'llama:article', FALSE, ], ]; Loading
tests/src/Kernel/FacetManager/DefaultFacetManagerTest.php +2 −0 Original line number Diff line number Diff line Loading @@ -171,6 +171,7 @@ class DefaultFacetManagerTest extends EntityKernelTestBase { $query->getCacheContexts(), $facet_mars->getFacetSource()->getCacheContexts(), [ 'facets_filter:f', 'fpc_query_type_plugin', 'dummy_query_pre_query', ] Loading Loading @@ -334,6 +335,7 @@ class DefaultFacetManagerTest extends EntityKernelTestBase { // Added by views view source plugin. 'url', 'languages:language_interface', 'facets_filter:f', ], 'tags' => [ // Facet controls query and look & feel of the facet results, so it's Loading