YamlFormThirdPartySettingsTest.php in YAML Form 8
File
src/Tests/YamlFormThirdPartySettingsTest.php
View source
<?php
namespace Drupal\yamlform\Tests;
class YamlFormThirdPartySettingsTest extends YamlFormTestBase {
protected static $modules = [
'system',
'node',
'user',
'yamlform',
];
public function testThirdPartySettings() {
$this
->drupalLogin($this->adminFormUser);
$this
->drupalGet('admin/structure/yamlform/settings/third-party');
$this
->assertRaw('There are no third party settings available.');
$this
->drupalGet('admin/structure/yamlform/manage/contact/third-party-settings');
$this
->assertRaw('There are no third party settings available.');
\Drupal::service('module_installer')
->install([
'yamlform_test_third_party_settings',
]);
$this
->drupalGet('admin/structure/yamlform/settings/third-party');
$this
->assertNoRaw('There are no third party settings available.');
$this
->drupalGet('admin/structure/yamlform/manage/contact/third-party-settings');
$this
->assertNoRaw('There are no third party settings available.');
$edit = [
'third_party_settings[yamlform_test_third_party_settings][message]' => 'Message for all forms',
];
$this
->drupalPostForm('admin/structure/yamlform/settings/third-party', $edit, t('Save configuration'));
$this
->drupalGet('yamlform/contact');
$this
->assertRaw('Message for all forms');
$this
->assertEqual('Message for all forms', $this
->config('yamlform.settings')
->get('third_party_settings.yamlform_test_third_party_settings.message'));
$edit = [
'third_party_settings[yamlform_test_third_party_settings][message]' => 'Message for only this form',
];
$this
->drupalPostForm('admin/structure/yamlform/manage/contact/third-party-settings', $edit, t('Save'));
$this
->drupalGet('yamlform/contact');
$this
->assertRaw('Message for only this form');
\Drupal::service('module_installer')
->uninstall([
'yamlform_test_third_party_settings',
]);
$this
->drupalGet('yamlform/contact');
$this
->assertNoRaw('Message for only this form');
$this
->assertNull($this
->config('yamlform.settings')
->get('third_party_settings.yamlform_test_third_party_settings.message'));
$this
->assertNull($this
->config('yamlform.settings')
->get('third_party_settings.yamlform_test_third_party_settings'));
}
}