public function WebformShareVariantTest::testVariant in Webform 8.5
Same name and namespace in other branches
- 6.x modules/webform_share/tests/src/Functional/WebformShareVariantTest.php \Drupal\Tests\webform_share\Functional\WebformShareVariantTest::testVariant()
Test variant.
File
- modules/
webform_share/ tests/ src/ Functional/ WebformShareVariantTest.php, line 36
Class
- WebformShareVariantTest
- Webform share variant test.
Namespace
Drupal\Tests\webform_share\FunctionalCode
public function testVariant() {
$library = WebformShareIframe::LIBRARY;
$version = WebformShareIframe::VERSION;
// Enable enable share for all webforms.
$config = \Drupal::configFactory()
->getEditable('webform.settings');
$config
->set('settings.default_share', TRUE)
->save();
/**************************************************************************/
// Check default letter and number.
$this
->drupalGet("/webform/test_variant_multiple/share/{$library}/{$version}");
$this
->assertRaw('{X}');
$this
->assertRaw('{0}');
// Check variant letter [A] and number [1].
$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]');
// Check variant letter [A] and number [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]');
// Check variant randomize script is attached to shared page.
// @see _webform_page_attachments()
$this
->drupalGet("/webform/test_variant_randomize/share/{$library}/{$version}");
$this
->assertRaw('var variants = {"letter":["a","b"]};');
}