InstallationTest.php in Video Embed Field 8
File
tests/src/Functional/InstallationTest.php
View source
<?php
namespace Drupal\Tests\video_embed_field\Functional;
use Drupal\Tests\BrowserTestBase;
class InstallationTest extends BrowserTestBase {
use AdminUserTrait;
protected function setUp() {
parent::setUp();
$this
->drupalLogin($this
->createAdminUser());
}
public function testInstallation() {
$this
->assertInstallationStatus(FALSE);
$this
->installModules();
$this
->assertInstallationStatus(TRUE);
$this
->uninstallModules();
$this
->assertInstallationStatus(FALSE);
$this
->installModules();
$this
->assertInstallationStatus(TRUE);
}
protected function assertInstallationStatus($installed) {
$this
->drupalGet('admin/modules');
foreach ([
'video_embed_field',
'video_embed_wysiwyg',
] as $module) {
$this
->assertSession()
->{$installed ? 'checkboxChecked' : 'checkboxNotChecked'}('modules[' . $module . '][enable]');
}
}
protected function uninstallModules() {
$this
->drupalPostForm('admin/modules/uninstall', [
'uninstall[video_embed_wysiwyg]' => TRUE,
], 'Uninstall');
$this
->getSession()
->getPage()
->pressButton('Uninstall');
$this
->drupalPostForm('admin/modules/uninstall', [
'uninstall[video_embed_field]' => TRUE,
], 'Uninstall');
$this
->getSession()
->getPage()
->pressButton('Uninstall');
}
protected function installModules() {
$this
->drupalPostForm('admin/modules', [
'modules[video_embed_field][enable]' => TRUE,
'modules[video_embed_wysiwyg][enable]' => TRUE,
], 'Install');
if ($button = $this
->getSession()
->getPage()
->findButton('Continue')) {
$button
->press();
}
}
}