Verified Commit bb29e717 authored by quietone's avatar quietone
Browse files

Issue #3484247 by mstrelan, smustgrave: Add NodeElement return typehints to...

Issue #3484247 by mstrelan, smustgrave: Add NodeElement return typehints to protected test helper methods

(cherry picked from commit 8925a129)
parent 16b2f019
Loading
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

namespace Drupal\Tests\layout_builder\FunctionalJavascript;

use Behat\Mink\Element\NodeElement;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\layout_builder\Entity\LayoutBuilderEntityViewDisplay;
use Drupal\Tests\contextual\FunctionalJavascript\ContextualLinkClickTrait;
@@ -236,7 +237,7 @@ protected function moveBlockWithKeyboard($direction, $block_label, array $update
   * @return \Behat\Mink\Element\NodeElement
   *   The row handle element.
   */
  protected function findRowHandle($block_label) {
  protected function findRowHandle($block_label): NodeElement {
    $assert_session = $this->assertSession();
    return $assert_session->elementExists('css', "[data-drupal-selector=\"edit-components\"] td:contains(\"$block_label\") a.tabledrag-handle");
  }
+5 −4
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

namespace Drupal\Tests\media_library\FunctionalJavascript;

use Behat\Mink\Element\NodeElement;
use Drupal\FunctionalJavascriptTests\WebDriverTestBase;
use Drupal\media\Entity\Media;

@@ -154,7 +155,7 @@ protected function waitForElementTextContains($selector, $text, $timeout = 10000
   * @todo replace with whatever gets added in
   *   https://www.drupal.org/node/3061852
   */
  protected function assertElementExistsAfterWait($selector, $locator, $timeout = 10000) {
  protected function assertElementExistsAfterWait($selector, $locator, $timeout = 10000): NodeElement {
    $element = $this->assertSession()->waitForElement($selector, $locator, $timeout);
    $this->assertNotEmpty($element);
    return $element;
@@ -166,7 +167,7 @@ protected function assertElementExistsAfterWait($selector, $locator, $timeout =
   * @return \Behat\Mink\Element\NodeElement
   *   The menu of available media types.
   */
  protected function getTypesMenu() {
  protected function getTypesMenu(): NodeElement {
    return $this->assertSession()
      ->elementExists('css', '.js-media-library-menu');
  }
@@ -275,7 +276,7 @@ protected function pressSaveButton($expect_errors = FALSE) {
   * @return \Behat\Mink\Element\NodeElement
   *   The NodeElement found via $after_open_selector.
   */
  protected function openMediaLibraryForField($field_name, $after_open_selector = '.js-media-library-menu') {
  protected function openMediaLibraryForField($field_name, $after_open_selector = '.js-media-library-menu'): NodeElement {
    $this->assertElementExistsAfterWait('css', "#$field_name-media-library-wrapper.js-media-library-widget")
      ->pressButton('Add media');
    $this->waitForText('Add or select media');
@@ -302,7 +303,7 @@ protected function openMediaLibraryForField($field_name, $after_open_selector =
   * @return \Behat\Mink\Element\NodeElement
   *   The "additional selected media" area.
   */
  protected function getSelectionArea($open = TRUE) {
  protected function getSelectionArea($open = TRUE): NodeElement {
    $summary = $this->assertElementExistsAfterWait('css', 'summary:contains("Additional selected media")');
    if ($open) {
      $summary->click();
+2 −1
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@

namespace Drupal\Tests\update\Functional;

use Behat\Mink\Element\NodeElement;
use Drupal\Core\Url;
use Drupal\Tests\BrowserTestBase;

@@ -294,7 +295,7 @@ protected function assertUpdateTableElementNotContains($text) {
   * @return \Behat\Mink\Element\NodeElement
   *   The update element.
   */
  protected function findUpdateElementByLabel($label, int $index = 0) {
  protected function findUpdateElementByLabel($label, int $index = 0): NodeElement {
    $update_elements = $this->getSession()->getPage()
      ->findAll('css', $this->updateTableLocator . " .project-update__version:contains(\"$label\")");
    $this->assertGreaterThanOrEqual($index, count($update_elements));
+2 −2
Original line number Diff line number Diff line
@@ -556,7 +556,7 @@ protected function assertTableRow(NodeElement $row, string $id, int $weight, str
   * @return \Behat\Mink\Element\NodeElement
   *   The row element.
   */
  protected function findRowById($id, $table_id = 'tabledrag-test-table') {
  protected function findRowById($id, $table_id = 'tabledrag-test-table'): NodeElement {
    $xpath = "//table[@id='$table_id']/tbody/tr[.//input[@name='table[$id][id]']]";
    $row = $this->getSession()->getPage()->find('xpath', $xpath);
    $this->assertNotEmpty($row);
@@ -572,7 +572,7 @@ protected function findRowById($id, $table_id = 'tabledrag-test-table') {
   * @return \Behat\Mink\Element\NodeElement
   *   The toggle element.
   */
  protected function findWeightsToggle($expected_text) {
  protected function findWeightsToggle($expected_text): NodeElement {
    $toggle = $this->getSession()->getPage()->findButton($expected_text);
    $this->assertNotEmpty($toggle);
    return $toggle;