public function RestExampleSettingsTest::testRestExampleSettings in Examples for Developers 3.x
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\FuntionalCode
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
->drupalPostForm(base_path() . 'examples/rest-client-settings', $edit, t('Save configuration'));
$this
->assertText('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'));
}