You are here

trait CoreVersionUiTestTrait in Diff 8

Maintains differences between 8.3.x and 8.4.x for tests.

Hierarchy

1 file declares its use of CoreVersionUiTestTrait
DiffLocaleTest.php in tests/src/FunctionalJavascript/DiffLocaleTest.php

File

tests/src/Functional/CoreVersionUiTestTrait.php, line 8

Namespace

Drupal\Tests\diff\Functional
View source
trait CoreVersionUiTestTrait {

  /**
   * Posts the node form depending on core version.
   *
   * @param string|\Drupal\Core\Url $path
   *   The path to post the form.
   * @param array $edit
   *   An array of values to post.
   * @param string $submit
   *   The label of the submit button to post.
   */
  protected function drupalPostNodeForm($path, array $edit, $submit) {
    if (!version_compare(\Drupal::VERSION, '8.4', '<')) {

      // Check for translations.
      if (strpos($submit, 'translation') !== FALSE) {
        $submit = t('Save (this translation)');
      }
      else {

        // Form button is back to simply 'Save'.
        $submit = t('Save');
      }

      // Check the publish checkbox.
      if (strpos($submit, 'publish') !== FALSE) {
        $edit['status[value]'] = 1;
      }
    }
    $this
      ->drupalPostForm($path, $edit, $submit);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
CoreVersionUiTestTrait::drupalPostNodeForm protected function Posts the node form depending on core version. 1