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

(cherry picked from commit 5397521df4)
merge-requests/7849/head
Alex Pott 2024-04-17 00:58:06 +01:00
parent e9c7c01bc8
commit b918dd3238
No known key found for this signature in database
GPG Key ID: BDA67E7EE836E5CE
1 changed files with 25 additions and 6 deletions

View File

@ -45,9 +45,16 @@ class WebAssert extends MinkWebAssert {
} }
/** /**
* {@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) { if ($url instanceof Url) {
$url = $url->setAbsolute()->toString(); $url = $url->setAbsolute()->toString();
} }
@ -752,9 +759,16 @@ class WebAssert extends MinkWebAssert {
} }
/** /**
* {@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); $expected = $this->cleanUrl($page, TRUE);
$actual = $this->cleanUrl($this->session->getCurrentUrl(), str_contains($expected, '?')); $actual = $this->cleanUrl($this->session->getCurrentUrl(), str_contains($expected, '?'));
@ -762,9 +776,14 @@ class WebAssert extends MinkWebAssert {
} }
/** /**
* {@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); $expected = $this->cleanUrl($page, TRUE);
$actual = $this->cleanUrl($this->session->getCurrentUrl(), str_contains($expected, '?')); $actual = $this->cleanUrl($this->session->getCurrentUrl(), str_contains($expected, '?'));