AdminUserLanguageBaseFormTest.php in Admin User Language 8
File
tests/src/Functional/AdminUserLanguageBaseFormTest.php
View source
<?php
namespace Drupal\Tests\admin_user_language\Functional;
class AdminUserLanguageBaseFormTest extends AdminUserLanguageBrowserTestBase {
public function testBasicFormSettings() {
$activeLanguages = $this
->getActiveLanguages();
$config = \Drupal::service('config.factory')
->get('admin_user_language.settings');
self::assertEquals(-1, $config
->get('default_language_to_assign'));
self::assertEquals(FALSE, $config
->get('prevent_user_override'));
$this
->drupalGet('admin/config/admin_user_language/settings');
$this
->assertSession()
->fieldExists('default_language_to_assign');
$this
->assertSession()
->fieldExists('prevent_user_override');
$randomLanguage = array_rand($activeLanguages);
$edit = [
'default_language_to_assign' => $randomLanguage,
'prevent_user_override' => TRUE,
];
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
$this
->assertSession()
->responseContains(t('The configuration options have been saved.'));
$config = \Drupal::service('config.factory')
->get('admin_user_language.settings');
self::assertEquals($randomLanguage, $config
->get('default_language_to_assign'));
self::assertEquals(TRUE, $config
->get('prevent_user_override'));
$this
->drupalGet('admin/config/admin_user_language/settings');
$this
->assertSession()
->fieldValueEquals('default_language_to_assign', $randomLanguage);
$this
->assertSession()
->fieldValueEquals('prevent_user_override', TRUE);
$edit = array(
'default_language_to_assign' => -1,
'prevent_user_override' => FALSE,
);
$this
->drupalPostForm(NULL, $edit, t('Save configuration'));
$this
->assertSession()
->responseContains(t('The configuration options have been saved.'));
$config = \Drupal::service('config.factory')
->get('admin_user_language.settings');
self::assertEquals(-1, $config
->get('default_language_to_assign'));
self::assertEquals(FALSE, $config
->get('prevent_user_override'));
}
}