You are here

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

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

Tests incoming specific features of gateway edit form.

File

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

Class

SmsFrameworkGatewayAdminTest
Tests gateway administration user interface.

Namespace

Drupal\Tests\sms\Functional

Code

public function testIncomingGatewayEdit() {
  $gateway = $this
    ->createMemoryGateway([
    'plugin' => 'incoming',
  ]);
  $this
    ->drupalLogin($this
    ->drupalCreateUser([
    'administer smsframework',
  ]));
  $url = Url::fromRoute('entity.sms_gateway.edit_form')
    ->setRouteParameter('sms_gateway', $gateway
    ->id());
  $this
    ->drupalGet($url);

  // Memory gateway supports incoming messages, so the URL should display.
  $this
    ->assertSession()
    ->fieldValueEquals('incoming_messages[push_path]', $gateway
    ->getPushIncomingPath());
  $incoming_route = '/' . $this
    ->randomMachineName();
  $edit = [
    'incoming_messages[push_path]' => $incoming_route,
  ];
  $this
    ->drupalPostForm(NULL, $edit, t('Save'));

  // Reload the gateway, check properties modified.
  $gateway = SmsGateway::load($gateway
    ->id());
  $this
    ->assertEquals($incoming_route, $gateway
    ->getPushIncomingPath());
}