ExperimentalThemeTest.php in Drupal 8
File
core/modules/system/tests/src/Functional/Theme/ExperimentalThemeTest.php
View source
<?php
namespace Drupal\Tests\system\Functional\Theme;
use Drupal\Tests\BrowserTestBase;
class ExperimentalThemeTest extends BrowserTestBase {
protected $adminUser;
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'access administration pages',
'administer themes',
]);
$this
->drupalLogin($this->adminUser);
}
public function testExperimentalConfirmForm() {
$this
->drupalGet('admin/appearance');
$this
->assertText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION));
$this
->assertText(sprintf('Experimental dependency test %s', \Drupal::VERSION));
$this
->drupalGet('admin/appearance');
$this
->cssSelect('a[title="Install <strong>Test theme</strong> theme"]')[0]
->click();
$this
->assertText('The <strong>Test theme</strong> theme has been installed.');
$this
->assertNoText('Experimental modules are provided for testing purposes only.');
$this
->drupalGet('admin/appearance');
$this
->cssSelect('a[title="Install Experimental test theme"]')[0]
->click();
$this
->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.');
$this
->assertNoText('The Experimental Test theme has been installed.');
$this
->assertText('Experimental themes are provided for testing purposes only.');
$this
->assertNoText('You must enable');
$this
->drupalPostForm(NULL, [], 'Continue');
$this
->assertText('The Experimental test theme has been installed.');
$this
->cssSelect('a[title="Set Experimental test as default theme"]')[0]
->click();
$this
->assertNoText('Experimental themes are provided for testing purposes only. Use at your own risk.');
$this
->assertText('Experimental test is now the default theme.');
$this
->assertNoText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION));
$this
->assertText(sprintf('Experimental test %s (default theme, administration theme, experimental theme)', \Drupal::VERSION));
$this
->config('system.theme')
->set('default', 'test_theme')
->save();
\Drupal::service('theme_handler')
->refreshInfo();
\Drupal::service('theme_installer')
->uninstall([
'experimental_theme_test',
]);
$this
->drupalGet('admin/appearance');
$this
->cssSelect('a[title="Install Experimental test as default theme"]')[0]
->click();
$this
->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.');
$this
->drupalGet('admin/appearance');
$this
->cssSelect('a[title="Install Experimental dependency test theme"]')[0]
->click();
$this
->assertNoText('The Experimental dependency test theme has been installed.');
$this
->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.');
$this
->assertText('The following themes are experimental: Experimental test');
$this
->assertNoText('The following themes are experimental: Experimental test, Experimental dependency test');
$this
->assertNoText('The following themes are experimental: Experimental dependency test');
$this
->assertText('You must enable the Experimental test theme to install Experimental dependency test');
$this
->drupalPostForm(NULL, [], 'Continue');
$this
->assertText('The Experimental dependency test theme has been installed.');
$this
->assertText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION));
$this
->assertText(sprintf('Experimental dependency test %s', \Drupal::VERSION));
$this
->cssSelect('a[title="Set Experimental dependency test as default theme"]')[0]
->click();
$this
->assertNoText('Experimental themes are provided for testing purposes only. Use at your own risk.');
$this
->assertText('Experimental dependency test is now the default theme.');
$this
->assertText(sprintf('Experimental test %s (experimental theme)', \Drupal::VERSION));
$this
->assertText(sprintf('Experimental dependency test %s (default theme, administration theme)', \Drupal::VERSION));
$this
->config('system.theme')
->set('default', 'test_theme')
->save();
\Drupal::service('theme_handler')
->refreshInfo();
\Drupal::service('theme_installer')
->uninstall([
'experimental_theme_test',
'experimental_theme_dependency_test',
]);
$this
->drupalGet('admin/appearance');
$this
->cssSelect('a[title="Install Experimental dependency test as default theme"]')[0]
->click();
$this
->assertText('Experimental themes are provided for testing purposes only. Use at your own risk.');
}
}