function RestExampleSettingsTest::testRestExampleSettings

Same name in other branches
  1. 4.0.x modules/rest_example/tests/src/Functional/RestExampleSettingsTest.php \Drupal\Tests\rest_example\Funtional\RestExampleSettingsTest::testRestExampleSettings()

Test that the form can be submitted.

Throws

\Drupal\Core\Entity\EntityStorageException

File

modules/rest_example/tests/src/Functional/RestExampleSettingsTest.php, line 35

Class

RestExampleSettingsTest
Test the settings in Rest Example.

Namespace

Drupal\Tests\rest_example\Funtional

Code

public function testRestExampleSettings() {
    global $base_url;
    $account = $this->drupalCreateUser();
    $this->drupalLogin($account);
    $this->drupalGet('examples/rest-client-settings');
    $edit = [
        'server_url' => $base_url,
        'server_username' => $account->get('name')->value,
        'server_password' => $account->passRaw,
    ];
    $this->drupalGet(base_path() . 'examples/rest-client-settings');
    $this->submitForm($edit, t('Save configuration'));
    $this->assertSession()
        ->pageTextContains('The configuration options have been saved.');
    $config_factory = \Drupal::configFactory();
    $rest_config = $config_factory->get('rest_example.settings');
    self::assertEquals($base_url, $rest_config->get('server_url'));
    self::assertEquals($account->get('name')->value, $rest_config->get('server_username'));
    self::assertEquals($account->passRaw, $rest_config->get('server_password'));
}