Issue #3439527 by acbramley, smustgrave, alexpott: Add type hints to WebAssert::address* and cleanUrl
(cherry picked from commit 5397521df4
)
merge-requests/7849/head
parent
e9c7c01bc8
commit
b918dd3238
|
@ -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, '?'));
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue