3 namespace Drupal\Tests\video_embed_field\Functional;
5 use Drupal\Tests\BrowserTestBase;
8 * Test the modules install and uninstall cleanly.
10 * @group video_embed_field
12 class InstallationTest extends BrowserTestBase {
19 protected function setUp() {
21 $this->drupalLogin($this->createAdminUser());
25 * Test the installation and uninstallation of the the modules.
27 public function testInstallation() {
28 $this->assertInstallationStatus(FALSE);
29 $this->installModules();
30 $this->assertInstallationStatus(TRUE);
31 $this->uninstallModules();
32 $this->assertInstallationStatus(FALSE);
33 $this->installModules();
34 $this->assertInstallationStatus(TRUE);
38 * Assert the installation status of the modules.
40 * @param bool $installed
41 * If the modules should be installed or not.
43 protected function assertInstallationStatus($installed) {
44 $this->drupalGet('admin/modules');
45 // @todo, add video_embed_media once infrastructure places version
46 // information in module info files.
47 foreach (['video_embed_field', 'video_embed_wysiwyg'] as $module) {
48 $this->assertSession()->{$installed ? 'checkboxChecked' : 'checkboxNotChecked'}('modules[' . $module . '][enable]');
53 * Uninstall the module using the UI.
55 protected function uninstallModules() {
56 $this->drupalPostForm('admin/modules/uninstall', [
57 'uninstall[video_embed_wysiwyg]' => TRUE,
59 $this->getSession()->getPage()->pressButton('Uninstall');
60 $this->drupalPostForm('admin/modules/uninstall', [
61 'uninstall[video_embed_field]' => TRUE,
63 $this->getSession()->getPage()->pressButton('Uninstall');
67 * Install the modules using the UI.
69 protected function installModules() {
70 $this->drupalPostForm('admin/modules', [
71 'modules[video_embed_field][enable]' => TRUE,
72 'modules[video_embed_wysiwyg][enable]' => TRUE,
74 // Continue is only required to confirm dependencies being enabled on the
75 // first call of this function.
76 if ($button = $this->getSession()->getPage()->findButton('Continue')) {