You are here

protected function BlockTestTrait::deleteBlock in Facets 8

Deletes a facet block by id.

Parameters

string $id: The id of the block.

1 call to BlockTestTrait::deleteBlock()
IntegrationTest::testFramework in tests/src/Functional/IntegrationTest.php
Tests various operations via the Facets' admin UI.

File

tests/src/Functional/BlockTestTrait.php, line 85

Class

BlockTestTrait
Shared test methods for facet blocks.

Namespace

Drupal\Tests\facets\Functional

Code

protected function deleteBlock($id) {

  // Delete a facet block trough the UI, the text for that link has changed
  // in Drupal::VERSION 8.3.
  $delete_link_title = \Drupal::VERSION >= 8.300000000000001 ? 'Remove block' : 'Delete';
  $delete_confirm_form_button_title = \Drupal::VERSION >= 8.300000000000001 ? 'Remove' : 'Delete';
  $orig_success_message = \Drupal::VERSION >= 8.300000000000001 ? 'The block ' . $this->blocks[$id]
    ->label() . ' has been removed.' : 'The block ' . $this->blocks[$id]
    ->label() . ' has been deleted.';
  $this
    ->drupalGet('admin/structure/block/manage/' . $this->blocks[$id]
    ->id(), [
    'query' => [
      'destination' => 'admin',
    ],
  ]);
  $this
    ->clickLink($delete_link_title);
  $this
    ->drupalPostForm(NULL, [], $delete_confirm_form_button_title);
  $this
    ->assertSession()
    ->pageTextContains($orig_success_message);
}