Commit ba3d9d33 authored by Jeroen Tubex's avatar Jeroen Tubex
Browse files

Issue #3263041 by JeroenT: Fix deprecations in test

parent ced1c05f
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ class SharpspringWebformTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  public function setUp() {
  protected function setUp(): void {
    parent::setUp();

    $this->webUser = $this->createUser();
@@ -127,13 +127,13 @@ class SharpspringWebformTest extends BrowserTestBase {
    $this->assertSession()->statusCodeEquals(200);

    // Check if base uri and endpoint are required.
    $this->drupalPostForm(NULL, ['sharpspring_status' => TRUE], 'Save');
    $this->submitForm(['sharpspring_status' => TRUE], 'Save');
    $this->assertSession()->pageTextContains('Base URI field is required.');
    $this->assertSession()->pageTextContains('Endpoint field is required.');
    $this->assertSession()->pageTextNotContains('The configuration options have been saved.');

    $this->drupalGet(Url::fromRoute('sharpspring_webforms.configuration', ['webform' => $this->webformId1]));
    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'sharpspring_status' => TRUE,
      'sharpspring_base_uri' => 'http://random-url.com',
    ], 'Save');
@@ -142,7 +142,7 @@ class SharpspringWebformTest extends BrowserTestBase {
    $this->assertSession()->pageTextNotContains('The configuration options have been saved.');

    $this->drupalGet(Url::fromRoute('sharpspring_webforms.configuration', ['webform' => $this->webformId1]));
    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'sharpspring_status' => TRUE,
      'sharpspring_endpoint' => 'random-endpoint',
    ], 'Save');
@@ -152,7 +152,7 @@ class SharpspringWebformTest extends BrowserTestBase {

    // Check if saving actually saves the configured values.
    $this->drupalGet(Url::fromRoute('sharpspring_webforms.configuration', ['webform' => $this->webformId1]));
    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'sharpspring_status' => TRUE,
      'sharpspring_base_uri' => 'http://random-url.com/',
      'sharpspring_endpoint' => 'random-endpoint',
@@ -170,7 +170,7 @@ class SharpspringWebformTest extends BrowserTestBase {

    // Make sure that a trailing slash is added to the base_uri.
    $this->drupalGet(Url::fromRoute('sharpspring_webforms.configuration', ['webform' => $this->webformId1]));
    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'sharpspring_status' => TRUE,
      'sharpspring_base_uri' => 'http://random-url.com',
      'sharpspring_endpoint' => 'random-endpoint',
@@ -181,7 +181,7 @@ class SharpspringWebformTest extends BrowserTestBase {

    // Disabling sharpspring removes all third party settings.
    $this->drupalGet(Url::fromRoute('sharpspring_webforms.configuration', ['webform' => $this->webformId1]));
    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'sharpspring_status' => FALSE,
      'sharpspring_base_uri' => '',
      'sharpspring_endpoint' => '',
+14 −9
Original line number Diff line number Diff line
@@ -71,7 +71,7 @@ class SharpspringWebformsHandlerTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  public function setUp() {
  protected function setUp(): void {
    parent::setUp();

    $this->drupalPlaceBlock('local_actions_block');
@@ -81,12 +81,14 @@ class SharpspringWebformsHandlerTest extends BrowserTestBase {
    // Create FR.
    ConfigurableLanguage::createFromLangcode('fr')->save();
    // Set prefixes to en and fr.
    $this->drupalPostForm('admin/config/regional/language/detection/url', [
    $this->drupalGet('admin/config/regional/language/detection/url');
    $this->submitForm([
      'prefix[en]' => 'en',
      'prefix[fr]' => 'fr',
    ], 'Save configuration');
    // Set up URL and language selection page methods.
    $this->drupalPostForm('admin/config/regional/language/detection', [
    $this->drupalGet('admin/config/regional/language/detection');
    $this->submitForm([
      'language_interface[enabled][language-url]' => 1,
    ], 'Save settings');

@@ -158,7 +160,7 @@ class SharpspringWebformsHandlerTest extends BrowserTestBase {
    $this->clickLink('Add handler');
    $this->clickLink('SharpSpring Remote Post');

    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'label' => 'Test sharpspring handler',
      'handler_id' => 'test_sharpspring_handler',
      'settings[base_uri]' => 'http://example.org',
@@ -185,7 +187,7 @@ class SharpspringWebformsHandlerTest extends BrowserTestBase {
    $this->assertFalse($this->state->get('sharpspring_webforms.test.call_executed', FALSE));

    // Submit a webform.
    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'name' => 'Name',
      'email' => 'mail@example.org',
      'address[address]' => 'address',
@@ -233,7 +235,7 @@ class SharpspringWebformsHandlerTest extends BrowserTestBase {

    $this->assertFalse($this->state->get('sharpspring_webforms.test.call_executed', FALSE));

    $this->drupalPostForm(NULL, [
    $this->submitForm([
      'name' => 'Name',
      'email' => 'mail@example.org',
      'address[address]' => 'address',
@@ -259,13 +261,15 @@ class SharpspringWebformsHandlerTest extends BrowserTestBase {
  public function testTranslatedHandler() {
    /** @var \Drupal\webform\WebformInterface $webform */
    $webform = $this->webformStorage->loadUnchanged($this->webformId);
    $this->drupalPostForm('/admin/structure/webform/manage/' . $this->webformId . '/translate/fr/add', [
    $this->drupalGet('admin/structure/webform/manage/' . $this->webformId . '/translate/fr/add');
    $this->submitForm([
      'translation[config_names][webform.webform.' . $this->webformId . '][handlers][sharpspring_remote_post][settings][base_uri]' => rtrim($this->baseUrl, '/') . '/sharpspring-webforms-test/handler-translated/',
      'translation[config_names][webform.webform.' . $this->webformId . '][handlers][sharpspring_remote_post][settings][endpoint]' => 'random_endpoint_fr',
    ], 'Save translation');

    $this->assertFalse($this->state->get('sharpspring_webforms.test.call_executed', FALSE));
    $this->drupalPostForm('en/webform/' . $this->webformId, [
    $this->drupalGet('en/webform/' . $this->webformId);
    $this->submitForm([
      'name' => 'Name',
      'email' => 'mail@example.org',
      'address[address]' => 'address',
@@ -297,7 +301,8 @@ class SharpspringWebformsHandlerTest extends BrowserTestBase {
    ], $this->state->get('sharpspring_webforms.test.handler_data'));

    $this->assertFalse($this->state->get('sharpspring_webforms.test.translated_call_executed', FALSE));
    $this->drupalPostForm('fr/webform/' . $this->webformId, [
    $this->drupalGet('fr/webform/' . $this->webformId);
    $this->submitForm([
      'name' => 'Name',
      'email' => 'mail@example.org',
      'address[address]' => 'address',
+9 −5
Original line number Diff line number Diff line
@@ -69,7 +69,7 @@ class SharpspringWebformsTranslationTest extends BrowserTestBase {
  /**
   * {@inheritdoc}
   */
  public function setUp() {
  protected function setUp(): void {
    parent::setUp();

    $admin = $this->drupalCreateUser([], NULL, TRUE);
@@ -78,12 +78,14 @@ class SharpspringWebformsTranslationTest extends BrowserTestBase {
    // Create FR.
    ConfigurableLanguage::createFromLangcode('fr')->save();
    // Set prefixes to en and fr.
    $this->drupalPostForm('admin/config/regional/language/detection/url', [
    $this->drupalGet('admin/config/regional/language/detection/url');
    $this->submitForm([
      'prefix[en]' => 'en',
      'prefix[fr]' => 'fr',
    ], 'Save configuration');
    // Set up URL and language selection page methods.
    $this->drupalPostForm('admin/config/regional/language/detection', [
    $this->drupalGet('admin/config/regional/language/detection');
    $this->submitForm([
      'language_interface[enabled][language-url]' => 1,
    ], 'Save settings');

@@ -107,12 +109,14 @@ class SharpspringWebformsTranslationTest extends BrowserTestBase {
   * Tests if the correct translated drupal settings are set.
   */
  public function testTranslatedDrupalSettings() {
    $this->drupalPostForm(Url::fromRoute('sharpspring_webforms.configuration', ['webform' => $this->webformId]), [
    $this->drupalGet(Url::fromRoute('sharpspring_webforms.configuration', ['webform' => $this->webformId]));
    $this->submitForm([
      'sharpspring_status' => TRUE,
      'sharpspring_base_uri' => 'http://random-url.com/',
      'sharpspring_endpoint' => 'random-endpoint',
    ], 'Save');
    $this->drupalPostForm('/admin/structure/webform/manage/' . $this->webformId . '/translate/fr/add', [
    $this->drupalGet('admin/structure/webform/manage/' . $this->webformId . '/translate/fr/add');
    $this->submitForm([
      'translation[config_names][webform.webform.' . $this->webformId . '][third_party_settings][sharpspring_webforms][base_uri]' => 'http://random-url.com/fr',
      'translation[config_names][webform.webform.' . $this->webformId . '][third_party_settings][sharpspring_webforms][endpoint]' => 'random-endpoint-fr',
    ], 'Save translation');