WebformVariantPluginTest.php in Webform 8.5
File
tests/src/Functional/Variant/WebformVariantPluginTest.php
View source
<?php
namespace Drupal\Tests\webform\Functional\Variant;
use Drupal\webform\Entity\Webform;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
class WebformVariantPluginTest extends WebformBrowserTestBase {
public static $modules = [
'webform',
'webform_test_variant',
];
public function testWebformVariantDependencies() {
$webform = Webform::load('contact');
$this
->assertEqual($webform
->getDependencies(), [
'module' => [
'webform',
],
]);
$variant_manager = $this->container
->get('plugin.manager.webform.variant');
$webform_variant_configuration = [
'id' => 'test',
'label' => 'test',
'variant_id' => 'test',
'status' => 1,
'weight' => 2,
'debug' => TRUE,
];
$webform_variant = $variant_manager
->createInstance('test', $webform_variant_configuration);
$webform
->addWebformVariant($webform_variant);
$webform
->save();
$this
->assertEqual($webform
->getDependencies(), [
'module' => [
'webform_test_variant',
'webform',
],
]);
$this->container
->get('module_installer')
->uninstall([
'webform_test_variant',
]);
$webform = Webform::load('contact');
$this
->assertNotEqual($webform
->getDependencies(), [
'module' => [
'webform_test_variant',
'webform',
],
]);
$this
->assertEqual($webform
->getDependencies(), [
'module' => [
'webform',
],
]);
}
}