View source
<?php
namespace Drupal\Tests\system\Functional\Module;
use Drupal\Tests\BrowserTestBase;
class ExperimentalModuleTest extends BrowserTestBase {
protected $adminUser;
protected $defaultTheme = 'stark';
protected function setUp() {
parent::setUp();
$this->adminUser = $this
->drupalCreateUser([
'access administration pages',
'administer modules',
]);
$this
->drupalLogin($this->adminUser);
}
public function testExperimentalConfirmForm() {
$edit = [];
$edit["modules[test_page_test][enable]"] = TRUE;
$this
->drupalPostForm('admin/modules', $edit, t('Install'));
$this
->assertText('Module Test page has been enabled.');
$this
->assertNoText('Experimental modules are provided for testing purposes only.');
\Drupal::service('module_installer')
->uninstall([
'test_page_test',
]);
$edit = [];
$edit["modules[experimental_module_test][enable]"] = TRUE;
$this
->drupalPostForm('admin/modules', $edit, 'Install');
$this
->assertNoText('Experimental Test has been enabled.');
$this
->assertText('Experimental modules are provided for testing purposes only.');
$this
->assertText('The following modules are experimental: Experimental Test');
$this
->assertNoText('You must enable');
$this
->drupalPostForm(NULL, [], 'Continue');
$this
->assertText('Experimental Test has been enabled.');
\Drupal::service('module_installer')
->uninstall([
'experimental_module_test',
]);
$edit = [];
$edit["modules[experimental_module_dependency_test][enable]"] = TRUE;
$this
->drupalPostForm('admin/modules', $edit, 'Install');
$this
->assertNoText('2 modules have been enabled: Experimental Dependency Test, Experimental Test');
$this
->assertText('Experimental modules are provided for testing purposes only.');
$this
->assertText('The following modules are experimental: Experimental Test');
$this
->assertNoText('The following modules are experimental: Experimental Test, Experimental Dependency Test');
$this
->assertNoText('The following modules are experimental: Experimental Dependency Test');
$this
->assertText('You must enable the Experimental Test module to install Experimental Dependency Test');
$this
->drupalPostForm(NULL, [], 'Continue');
$this
->assertText('2 modules have been enabled: Experimental Dependency Test, Experimental Test');
\Drupal::service('module_installer')
->uninstall([
'experimental_module_test',
'experimental_module_dependency_test',
]);
$edit = [];
$edit["modules[experimental_module_test][enable]"] = TRUE;
$edit["modules[experimental_module_dependency_test][enable]"] = TRUE;
$this
->drupalPostForm('admin/modules', $edit, 'Install');
$this
->assertNoText('2 modules have been enabled: Experimental Dependency Test, Experimental Test');
$this
->assertText('Experimental modules are provided for testing purposes only.');
$this
->assertText('The following modules are experimental: Experimental Test');
$this
->assertNoText('The following modules are experimental: Experimental Dependency Test, Experimental Test');
$this
->assertNoText('The following modules are experimental: Experimental Dependency Test');
$this
->assertNoText('You must enable');
$this
->drupalPostForm(NULL, [], 'Continue');
$this
->assertText('2 modules have been enabled: Experimental Dependency Test, Experimental Test');
\Drupal::state()
->set('experimental_module_requirements_test_requirements', TRUE);
$edit = [];
$edit["modules[experimental_module_requirements_test][enable]"] = TRUE;
$this
->drupalPostForm('admin/modules', $edit, 'Install');
$this
->assertUrl('admin/modules', [], 'If the module can not be installed we are not taken to the confirm form.');
$this
->assertText('The Experimental Test Requirements module can not be installed.');
}
}