class ThemeSettingsFormTest
Same name and namespace in other branches
- 11.x core/modules/system/tests/src/FunctionalJavascript/ThemeSettingsFormTest.php \Drupal\Tests\system\FunctionalJavascript\ThemeSettingsFormTest
- 10 core/modules/system/tests/src/FunctionalJavascript/ThemeSettingsFormTest.php \Drupal\Tests\system\FunctionalJavascript\ThemeSettingsFormTest
- 8.9.x core/modules/system/tests/src/FunctionalJavascript/ThemeSettingsFormTest.php \Drupal\Tests\system\FunctionalJavascript\ThemeSettingsFormTest
Tests that theme form settings works correctly.
@group system
Hierarchy
- class \Drupal\Tests\BrowserTestBase uses \Drupal\Core\Test\FunctionalTestSetupTrait, \Drupal\Tests\UiHelperTrait, \Drupal\Core\Test\TestSetupTrait, \Drupal\Tests\block\Traits\BlockCreationTrait, \Drupal\FunctionalTests\AssertLegacyTrait, \Drupal\Tests\RandomGeneratorTrait, \Drupal\Tests\node\Traits\NodeCreationTrait, \Drupal\Tests\node\Traits\ContentTypeCreationTrait, \Drupal\Tests\ConfigTestTrait, \Drupal\Tests\TestRequirementsTrait, \Drupal\Tests\user\Traits\UserCreationTrait, \Drupal\Tests\XdebugRequestTrait, \Drupal\Tests\Traits\PhpUnitWarnings, \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, \Drupal\Tests\ExtensionListTestTrait extends \PHPUnit\Framework\TestCase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
- class \Drupal\Tests\system\FunctionalJavascript\ThemeSettingsFormTest uses \Drupal\Tests\TestFileCreationTrait extends \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase extends \Drupal\Tests\BrowserTestBase
Expanded class hierarchy of ThemeSettingsFormTest
File
-
core/
modules/ system/ tests/ src/ FunctionalJavascript/ ThemeSettingsFormTest.php, line 14
Namespace
Drupal\Tests\system\FunctionalJavascriptView source
class ThemeSettingsFormTest extends WebDriverTestBase {
use TestFileCreationTrait;
/**
* {@inheritdoc}
*/
protected static $modules = [
'file',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* {@inheritdoc}
*/
protected function setUp() : void {
parent::setUp();
$admin = $this->drupalCreateUser([
'administer themes',
]);
$this->drupalLogin($admin);
}
/**
* Tests that submission handler works correctly.
*
* @dataProvider providerTestFormSettingsSubmissionHandler
*/
public function testFormSettingsSubmissionHandler($theme) {
\Drupal::service('theme_installer')->install([
$theme,
]);
$page = $this->getSession()
->getPage();
$assert_session = $this->assertSession();
$this->drupalGet("admin/appearance/settings/{$theme}");
// Add a new managed file.
$file = current($this->getTestFiles('image'));
$image_file_path = \Drupal::service('file_system')->realpath($file->uri);
$page->attachFileToField('files[custom_logo]', $image_file_path);
$assert_session->waitForButton('custom_logo_remove_button');
// Assert the new file is uploaded as temporary. This file should not be
// saved as permanent if settings are not submitted.
$image_field = $this->assertSession()
->hiddenFieldExists('custom_logo[fids]');
$file = File::load($image_field->getValue());
$this->assertFalse($file->isPermanent());
$page->pressButton('Save configuration');
\Drupal::entityTypeManager()->getStorage('file')
->resetCache();
// Assert the uploaded file is saved as permanent.
$image_field = $this->assertSession()
->hiddenFieldExists('custom_logo[fids]');
$file = File::load($image_field->getValue());
$this->assertTrue($file->isPermanent());
}
/**
* Provides test data for ::testFormSettingsSubmissionHandler().
*/
public function providerTestFormSettingsSubmissionHandler() {
return [
'test theme.theme' => [
'test_theme_theme',
],
'test theme-settings.php' => [
'test_theme_settings',
],
];
}
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.