Verified Commit b918dd32 authored by Alex Pott's avatar Alex Pott
Browse files

Issue #3439527 by acbramley, smustgrave, alexpott: Add type hints to...

Issue #3439527 by acbramley, smustgrave, alexpott: Add type hints to WebAssert::address* and cleanUrl

(cherry picked from commit 5397521d)
parent e9c7c01b
Loading
Loading
Loading
Loading
Loading
+25 −6
Original line number Diff line number Diff line
@@ -45,9 +45,16 @@ public function __construct(Session $session, $base_url = '') {
  }

  /**
   * {@inheritdoc}
   * Trims the base URL from the URL.
   *
   * @param string|\Drupal\Core\Url $url
   *   A url string, or object.
   * @param bool $include_query
   *   Whether to include the query string in the return value.
   *
   * @return string
   */
  protected function cleanUrl($url, $include_query = FALSE) {
  protected function cleanUrl(string|Url $url, bool $include_query = FALSE) {
    if ($url instanceof Url) {
      $url = $url->setAbsolute()->toString();
    }
@@ -752,9 +759,16 @@ public function pageContainsNoDuplicateId() {
  }

  /**
   * {@inheritdoc}
   * Checks that current session address is equals to provided one.
   *
   * @param string|\Drupal\Core\Url $page
   *   A url string, or object.
   *
   * @return void
   *
   * @throws \Behat\Mink\Exception\ExpectationException
   */
  public function addressEquals($page) {
  public function addressEquals(string|Url $page) {
    $expected = $this->cleanUrl($page, TRUE);
    $actual = $this->cleanUrl($this->session->getCurrentUrl(), str_contains($expected, '?'));

@@ -762,9 +776,14 @@ public function addressEquals($page) {
  }

  /**
   * {@inheritdoc}
   * Checks that current session address is not equals to provided one.
   *
   * @param string|\Drupal\Core\Url $page
   *   A url string, or object.
   *
   * @throws \Behat\Mink\Exception\ExpectationException
   */
  public function addressNotEquals($page) {
  public function addressNotEquals(string|Url $page) {
    $expected = $this->cleanUrl($page, TRUE);
    $actual = $this->cleanUrl($this->session->getCurrentUrl(), str_contains($expected, '?'));