WebformShareVariantTest.php in Webform 8.5
File
modules/webform_share/tests/src/Functional/WebformShareVariantTest.php
View source
<?php
namespace Drupal\Tests\webform_share\Functional;
use Drupal\Tests\webform\Functional\WebformBrowserTestBase;
use Drupal\webform_share\Element\WebformShareIframe;
class WebformShareVariantTest extends WebformBrowserTestBase {
protected static $testWebforms = [
'test_variant_multiple',
'test_variant_randomize',
];
public static $modules = [
'webform',
'webform_share',
];
public function testVariant() {
$library = WebformShareIframe::LIBRARY;
$version = WebformShareIframe::VERSION;
$config = \Drupal::configFactory()
->getEditable('webform.settings');
$config
->set('settings.default_share', TRUE)
->save();
$this
->drupalGet("/webform/test_variant_multiple/share/{$library}/{$version}");
$this
->assertRaw('{X}');
$this
->assertRaw('{0}');
$this
->drupalGet("/webform/test_variant_multiple/share/{$library}/{$version}", [
'query' => [
'_webform_variant' => [
'letter' => 'a',
'number' => 1,
],
],
]);
$this
->assertNoRaw('{X}');
$this
->assertNoRaw('{0}');
$this
->assertRaw('[A]');
$this
->assertRaw('[1]');
$this
->drupalGet("/webform/test_variant_multiple/share/{$library}/{$version}", [
'query' => [
'letter' => 'a',
'number' => 1,
],
]);
$this
->assertNoRaw('{X}');
$this
->assertNoRaw('{0}');
$this
->assertRaw('[A]');
$this
->assertRaw('[1]');
$this
->drupalGet("/webform/test_variant_randomize/share/{$library}/{$version}");
$this
->assertRaw('var variants = {"letter":["a","b"]};');
}
}