protected function IntegrationTest::deleteUnusedFacet in Facets 8
Deletes a facet through the UI.
Parameters
string $facet_name: The name of the facet.
1 call to IntegrationTest::deleteUnusedFacet()
- IntegrationTest::testFramework in tests/src/ Functional/ IntegrationTest.php 
- Tests various operations via the Facets' admin UI.
File
- tests/src/ Functional/ IntegrationTest.php, line 1102 
Class
- IntegrationTest
- Tests the overall functionality of the Facets admin UI.
Namespace
Drupal\Tests\facets\FunctionalCode
protected function deleteUnusedFacet($facet_name) {
  $facet_id = $this
    ->convertNameToMachineName($facet_name);
  $facet_delete_page = '/admin/config/search/facets/' . $facet_id . '/delete';
  $facet_overview = '/admin/config/search/facets';
  // Go to the facet delete page and make the warning is shown.
  $this
    ->drupalGet($facet_delete_page);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextContains("This action cannot be undone.");
  // Click the cancel link and see that we redirect to the overview page.
  $this
    ->clickLink("Cancel");
  $this
    ->assertSession()
    ->addressEquals($facet_overview);
  // Back to the delete page.
  $this
    ->drupalGet($facet_delete_page);
  // Actually submit the confirmation form.
  $this
    ->drupalPostForm(NULL, [], 'Delete');
  // Check that the facet by testing for the message and the absence of the
  // facet name on the overview.
  $this
    ->assertSession()
    ->pageTextContains('The facet ' . $facet_name . ' has been deleted.');
  // Refresh the page because on the previous page the $facet_name is still
  // visible (in the message).
  $this
    ->drupalGet($facet_overview);
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->assertSession()
    ->pageTextNotContains($facet_name);
}