Esempio n. 1
0
 /**
  * Tests various url integration things.
  */
 public function testUrlIntegration()
 {
     $id = 'facet';
     $name = '&^Facet@#1';
     $this->createFacet($name, $id);
     $url = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['f[0]' => 'facet:item']]);
     $this->checkClickedFacetUrl($url);
     /** @var \Drupal\facets\FacetInterface $facet */
     $facet = Facet::load($id);
     $this->assertTrue($facet instanceof FacetInterface);
     $config = $facet->getFacetSourceConfig();
     $this->assertTrue($config instanceof FacetSourceInterface);
     $this->assertEqual(NULL, $config->getFilterKey());
     $facet = NULL;
     $config = NULL;
     // Go to the only enabled facet source's config and change the filter key.
     $this->drupalGet('admin/config/search/facets');
     $this->clickLink($this->t('Configure'), 1);
     $edit = ['filter_key' => 'y', 'url_processor' => 'query_string'];
     $this->drupalPostForm(NULL, $edit, $this->t('Save'));
     /** @var \Drupal\facets\FacetInterface $facet */
     $facet = Facet::load($id);
     $config = $facet->getFacetSourceConfig();
     $this->assertTrue($config instanceof FacetSourceInterface);
     $this->assertEqual('y', $config->getFilterKey());
     $facet = NULL;
     $config = NULL;
     $url_2 = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['y[0]' => 'facet:item']]);
     $this->checkClickedFacetUrl($url_2);
     // Go to the only enabled facet source's config and change the url
     // processor.
     $this->drupalGet('admin/config/search/facets');
     $this->clickLink($this->t('Configure'), 1);
     $edit = ['filter_key' => 'y', 'url_processor' => 'dummy_query'];
     $this->drupalPostForm(NULL, $edit, $this->t('Save'));
     /** @var \Drupal\facets\FacetInterface $facet */
     $facet = Facet::load($id);
     $config = $facet->getFacetSourceConfig();
     $this->assertTrue($config instanceof FacetSourceInterface);
     $this->assertEqual('y', $config->getFilterKey());
     $facet = NULL;
     $config = NULL;
     $url_3 = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['y[0]' => 'facet||item']]);
     $this->checkClickedFacetUrl($url_3);
 }
Esempio n. 2
0
 /**
  * Tests facet weights.
  */
 public function testWeight()
 {
     $facet_name = "Forest owlet";
     $id = "forest_owlet";
     $this->createFacet($facet_name, $id);
     /** @var \Drupal\facets\FacetInterface $facet */
     $facet = Facet::load($id);
     $facet->setWeight(10);
     $this->assertEqual(10, $facet->getWeight());
 }