You are here

public function SmsFrameworkGatewayAdminTest::testGatewayAdd in SMS Framework 2.1.x

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

Test adding a gateway.

File

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

Class

SmsFrameworkGatewayAdminTest
Tests gateway administration user interface.

Namespace

Drupal\Tests\sms\Functional

Code

public function testGatewayAdd() {
  $account = $this
    ->drupalCreateUser([
    'administer smsframework',
  ]);
  $this
    ->drupalLogin($account);
  $this
    ->drupalGet(Url::fromRoute('entity.sms_gateway.add'));
  $this
    ->assertResponse(200);
  $edit = [
    'label' => $this
      ->randomString(),
    'id' => mb_strtolower($this
      ->randomMachineName()),
    'status' => TRUE,
    'plugin_id' => 'memory',
  ];
  $this
    ->drupalPostForm(Url::fromRoute('entity.sms_gateway.add'), $edit, t('Save'));
  $this
    ->assertResponse(200);
  $this
    ->assertUrl(Url::fromRoute('entity.sms_gateway.edit_form', [
    'sms_gateway' => $edit['id'],
  ]));
  $this
    ->assertRaw(t('Gateway created.'));
  $this
    ->drupalGet(Url::fromRoute('sms.gateway.list'));
  $this
    ->assertRaw('<td>' . t('@label', [
    '@label' => $edit['label'],
  ]) . '</td>', 'New gateway appears on list.');
}