You are here

public function SmsFrameworkGatewayAdminTest::testGatewayDelete in SMS Framework 2.x

Same name and namespace in other branches
  1. 8 tests/src/Functional/SmsFrameworkGatewayAdminTest.php \Drupal\Tests\sms\Functional\SmsFrameworkGatewayAdminTest::testGatewayDelete()
  2. 2.1.x tests/src/Functional/SmsFrameworkGatewayAdminTest.php \Drupal\Tests\sms\Functional\SmsFrameworkGatewayAdminTest::testGatewayDelete()

Tests deleting a gateway.

File

tests/src/Functional/SmsFrameworkGatewayAdminTest.php, line 184

Class

SmsFrameworkGatewayAdminTest
Tests gateway administration user interface.

Namespace

Drupal\Tests\sms\Functional

Code

public function testGatewayDelete() {
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer smsframework',
  ]));
  $test_gateway = $this
    ->createMemoryGateway();
  $this
    ->drupalGet(Url::fromRoute('entity.sms_gateway.edit_form', [
    'sms_gateway' => $test_gateway
      ->id(),
  ]));
  $this
    ->clickLink(t('Delete'));
  $delete_url = Url::fromRoute('entity.sms_gateway.delete_form', [
    'sms_gateway' => $test_gateway
      ->id(),
  ]);
  $this
    ->assertUrl($delete_url);
  $this
    ->assertRaw(t('Are you sure you want to delete SMS gateway %label?', [
    '%label' => $test_gateway
      ->label(),
  ]));
  $this
    ->drupalPostForm($delete_url, [], t('Delete'));
  $this
    ->assertUrl(Url::fromRoute('sms.gateway.list'));
  $this
    ->assertResponse(200);
  $this
    ->assertRaw(t('Gateway %label was deleted.', [
    '%label' => $test_gateway
      ->label(),
  ]));
  $this
    ->assertNoRaw('<td>' . t('@label', [
    '@label' => $test_gateway
      ->label(),
  ]) . '</td>');
}