drupalLogin($this->adminUser); $this->setUpExampleStructure(); $this->insertExampleContent(); $this->assertEqual($this->indexItems($this->indexId), 5, '5 items were indexed.'); } /** * Tests checkbox widget. */ public function testCheckboxWidget() { $id = 't'; $name = 'Facet & checkbox~'; $this->createFacet($name, $id); $this->drupalGet('admin/config/search/facets/' . $id . '/edit'); $this->drupalPostForm(NULL, ['widget' => 'checkbox'], $this->t('Save')); $this->drupalGet('search-api-test-fulltext'); $this->assertLink('item'); $this->assertLink('article'); } /** * Tests links widget's basic functionality. */ public function testLinksWidget() { $id = 'links_widget'; $name = '>.Facet &* Links'; $this->createFacet($name, $id); $this->drupalGet('admin/config/search/facets/' . $id . '/edit'); $this->drupalPostForm(NULL, ['widget' => 'links'], $this->t('Save')); $this->drupalGet('search-api-test-fulltext'); $this->assertLink('item'); $this->assertLink('article'); $this->clickLink('item'); $this->assertRaw('(-) item'); } /** * Tests select widget's basic functionality. */ public function testSelectWidget() { $id = 'select_widget'; $name = 'Select'; $this->createFacet($name, $id); $this->drupalGet('admin/config/search/facets/' . $id . '/edit'); $this->drupalPostForm(NULL, ['widget' => 'select'], $this->t('Save')); $this->drupalGet('search-api-test-fulltext'); $this->assertField('edit-type', 'Dropdown is visible.'); $this->assertText('Displaying 5 search results'); $url = Url::fromUserInput('/search-api-test-fulltext', ['query' => ['f[0]' => 'select_widget:item']]); $url->setAbsolute(); $this->drupalPostForm(NULL, ['type' => $url->toString()], $this->t('submit')); $this->assertResponse(200); $this->assertText('Displaying 3 search results'); } /** * Tests the functionality of a widget to hide/show the item-count. */ public function testLinksShowHideCount() { $id = 'links_widget'; $name = '>.Facet &* Links'; $facet_edit_page = 'admin/config/search/facets/' . $id . '/edit'; $this->createFacet($name, $id); // Go to the view and check that the facet links are shown with their // default settings. $this->drupalGet('search-api-test-fulltext'); $this->assertLink('item'); $this->assertLink('article'); $this->drupalGet($facet_edit_page); $this->drupalPostForm(NULL, ['widget' => 'links', 'widget_configs[show_numbers]' => TRUE], $this->t('Save')); // Go back to the same view and check that links now display the count. $this->drupalGet('search-api-test-fulltext'); $this->assertRaw('item (3)'); $this->assertRaw('article (2)'); $this->drupalGet($facet_edit_page); $this->drupalPostForm(NULL, ['widget' => 'links', 'widget_configs[show_numbers]' => FALSE], $this->t('Save')); // The count should be hidden again. $this->drupalGet('search-api-test-fulltext'); $this->assertLink('item'); $this->assertLink('article'); } }