View source
<?php
namespace Drupal\Tests;
use Behat\Mink\Exception\ExpectationException;
use Behat\Mink\Exception\ResponseTextException;
use Behat\Mink\WebAssert as MinkWebAssert;
use Behat\Mink\Element\ElementInterface;
use Behat\Mink\Element\TraversableElement;
use Behat\Mink\Exception\ElementNotFoundException;
use Behat\Mink\Session;
use Drupal\Component\Utility\Html;
use Drupal\Core\Url;
use PHPUnit\Framework\Assert;
use PHPUnit\Framework\AssertionFailedError;
use PHPUnit\Framework\Constraint\ArrayHasKey;
use PHPUnit\Framework\Constraint\IsIdentical;
use PHPUnit\Framework\Constraint\IsEqual;
use PHPUnit\Framework\Constraint\LogicalNot;
class WebAssert extends MinkWebAssert {
protected $baseUrl = '';
public function __construct(Session $session, $base_url = '') {
parent::__construct($session);
$this->baseUrl = $base_url;
}
protected function cleanUrl($url, $include_query = FALSE) {
if ($url instanceof Url) {
$url = $url
->setAbsolute()
->toString();
}
if ($this->baseUrl !== '' && strpos($url, $this->baseUrl) === 0) {
$url = substr($url, strlen($this->baseUrl));
}
$parts = parse_url($url);
if (empty($parts['host']) && strpos($url, '/') !== 0) {
$parts['path'] = '/' . $parts['path'];
}
$fragment = empty($parts['fragment']) ? '' : '#' . $parts['fragment'];
$path = empty($parts['path']) ? '/' : $parts['path'];
$query = $include_query && !empty($parts['query']) ? '?' . $parts['query'] : '';
return preg_replace('/^\\/[^\\.\\/]+\\.php\\//', '/', $path) . $query . $fragment;
}
public function responseHeaderExists(string $name, string $message = '') : void {
if ($message === '') {
$message = "Failed asserting that the response has a '{$name}' header.";
}
$headers = $this->session
->getResponseHeaders();
$constraint = new ArrayHasKey($name);
Assert::assertThat($headers, $constraint, $message);
}
public function responseHeaderDoesNotExist(string $name, string $message = '') : void {
if ($message === '') {
$message = "Failed asserting that the response does not have a '{$name}' header.";
}
$headers = $this->session
->getResponseHeaders();
$constraint = new LogicalNot(new ArrayHasKey($name));
Assert::assertThat($headers, $constraint, $message);
}
public function pageTextMatchesCount(int $count, string $regex, string $message = '') : void {
$actual = preg_replace('/\\s+/u', ' ', $this->session
->getPage()
->getText());
$matches = preg_match_all($regex, $actual);
if ($message === '') {
$message = "Failed asserting that the page matches the pattern '{$regex}' {$count} time(s), {$matches} found.";
}
$constraint = new IsIdentical($count);
Assert::assertThat($matches, $constraint, $message);
}
public function buttonExists($button, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$node = $container
->findButton($button);
if ($node === NULL) {
throw new ElementNotFoundException($this->session
->getDriver(), 'button', 'id|name|label|value', $button);
}
return $node;
}
public function buttonNotExists($button, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$node = $container
->findButton($button);
$this
->assert(NULL === $node, sprintf('A button "%s" appears on this page, but it should not.', $button));
}
public function selectExists($select, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$node = $container
->find('named', [
'select',
$select,
]);
if ($node === NULL) {
throw new ElementNotFoundException($this->session
->getDriver(), 'select', 'id|name|label|value', $select);
}
return $node;
}
public function optionExists($select, $option, TraversableElement $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$select_field = $container
->find('named', [
'select',
$select,
]);
if ($select_field === NULL) {
throw new ElementNotFoundException($this->session
->getDriver(), 'select', 'id|name|label|value', $select);
}
$option_field = $select_field
->find('named', [
'option',
$option,
]);
if ($option_field === NULL) {
throw new ElementNotFoundException($this->session
->getDriver(), 'select', 'id|name|label|value', $option);
}
return $option_field;
}
public function optionNotExists($select, $option, TraversableElement $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$select_field = $container
->find('named', [
'select',
$select,
]);
if ($select_field === NULL) {
throw new ElementNotFoundException($this->session
->getDriver(), 'select', 'id|name|label|value', $select);
}
$option_field = $select_field
->find('named', [
'option',
$option,
]);
$this
->assert($option_field === NULL, sprintf('An option "%s" exists in select "%s", but it should not.', $option, $select));
}
public function titleEquals($expected_title) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$title_element = $this->session
->getPage()
->find('css', 'title');
if (!$title_element) {
throw new ExpectationException('No title element found on the page', $this->session
->getDriver());
}
$actual_title = $title_element
->getText();
$this
->assert($expected_title === $actual_title, 'Title found');
}
public function linkExists($label, $index = 0, $message = '') {
$message = $message ? $message : strtr('Link with label %label found.', [
'%label' => $label,
]);
$links = $this->session
->getPage()
->findAll('named', [
'link',
$label,
]);
$this
->assert(!empty($links[$index]), $message);
}
public function linkExistsExact($label, $index = 0, $message = '') {
$message = $message ? $message : strtr('Link with label %label found.', [
'%label' => $label,
]);
$links = $this->session
->getPage()
->findAll('named_exact', [
'link',
$label,
]);
$this
->assert(!empty($links[$index]), $message);
}
public function linkNotExists($label, $message = '') {
$message = $message ? $message : strtr('Link with label %label not found.', [
'%label' => $label,
]);
$links = $this->session
->getPage()
->findAll('named', [
'link',
$label,
]);
$this
->assert(empty($links), $message);
}
public function linkNotExistsExact($label, $message = '') {
$message = $message ? $message : strtr('Link with label %label not found.', [
'%label' => $label,
]);
$links = $this->session
->getPage()
->findAll('named_exact', [
'link',
$label,
]);
$this
->assert(empty($links), $message);
}
public function linkByHrefExists($href, $index = 0, $message = '') {
$xpath = $this
->buildXPathQuery('//a[contains(@href, :href)]', [
':href' => $href,
]);
$message = $message ? $message : strtr('Link containing href %href found.', [
'%href' => $href,
]);
$links = $this->session
->getPage()
->findAll('xpath', $xpath);
$this
->assert(!empty($links[$index]), $message);
}
public function linkByHrefNotExists($href, $message = '') {
$xpath = $this
->buildXPathQuery('//a[contains(@href, :href)]', [
':href' => $href,
]);
$message = $message ? $message : strtr('No link containing href %href found.', [
'%href' => $href,
]);
$links = $this->session
->getPage()
->findAll('xpath', $xpath);
$this
->assert(empty($links), $message);
}
public function buildXPathQuery($xpath, array $args = []) {
foreach ($args as $placeholder => $value) {
if (is_object($value)) {
throw new \InvalidArgumentException('Just pass in scalar values for $args and remove all t() calls from your test.');
}
if (is_string($value)) {
$parts = explode('"', $value);
foreach ($parts as &$part) {
$part = '"' . $part . '"';
}
$value = count($parts) > 1 ? 'concat(' . implode(', \'"\', ', $parts) . ')' : $parts[0];
}
$replacement = function ($matches) use ($value) {
return $value;
};
$xpath = preg_replace_callback('/' . preg_quote($placeholder) . '\\b/', $replacement, $xpath);
}
return $xpath;
}
public function assertNoEscaped($raw) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$this
->responseNotContains(Html::escape($raw));
}
public function assertEscaped($raw) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$this
->responseContains(Html::escape($raw));
}
public function responseContains($text) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
parent::responseContains((string) $text);
}
public function responseNotContains($text) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
parent::responseNotContains((string) $text);
}
public function assert($condition, $message) {
if ($condition) {
return;
}
throw new ExpectationException($message, $this->session
->getDriver());
}
public function fieldDisabled($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$node = $container
->findField($field);
if ($node === NULL) {
throw new ElementNotFoundException($this->session
->getDriver(), 'field', 'id|name|label|value', $field);
}
if (!$node
->hasAttribute('disabled')) {
throw new ExpectationException("Field {$field} is disabled", $this->session
->getDriver());
}
return $node;
}
public function fieldEnabled($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$node = $container
->findField($field);
if ($node === NULL) {
throw new ElementNotFoundException($this->session
->getDriver(), 'field', 'id|name|label|value', $field);
}
if ($node
->hasAttribute('disabled')) {
throw new ExpectationException("Field {$field} is not enabled", $this->session
->getDriver());
}
return $node;
}
public function hiddenFieldExists($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
if ($node = $container
->find('hidden_field_selector', [
'hidden_field',
$field,
])) {
return $node;
}
throw new ElementNotFoundException($this->session
->getDriver(), 'form hidden field', 'id|name|value', $field);
}
public function hiddenFieldNotExists($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$container = $container ?: $this->session
->getPage();
$node = $container
->find('hidden_field_selector', [
'hidden_field',
$field,
]);
$this
->assert($node === NULL, "A hidden field '{$field}' exists on this page, but it should not.");
}
public function hiddenFieldValueEquals($field, $value, TraversableElement $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$node = $this
->hiddenFieldExists($field, $container);
$actual = $node
->getValue();
$regex = '/^' . preg_quote($value, '/') . '$/ui';
$message = "The hidden field '{$field}' value is '{$actual}', but '{$value}' expected.";
$this
->assert((bool) preg_match($regex, $actual), $message);
}
public function hiddenFieldValueNotEquals($field, $value, TraversableElement $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$node = $this
->hiddenFieldExists($field, $container);
$actual = $node
->getValue();
$regex = '/^' . preg_quote($value, '/') . '$/ui';
$message = "The hidden field '{$field}' value is '{$actual}', but it should not be.";
$this
->assert(!preg_match($regex, $actual), $message);
}
public function pageTextContainsOnce($text) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$regex = '/' . preg_quote($text, '/') . '/ui';
try {
$this
->pageTextMatchesCount(1, $regex);
} catch (AssertionFailedError $e) {
throw new ResponseTextException($e
->getMessage(), $this->session
->getDriver());
}
}
public function pageContainsNoDuplicateId() {
$seen_ids = [];
foreach ($this->session
->getPage()
->findAll('xpath', '//*[@id]') as $element) {
$id = $element
->getAttribute('id');
if (isset($seen_ids[$id])) {
throw new ExpectationException(sprintf('The page contains a duplicate HTML ID "%s".', $id), $this->session
->getDriver());
}
$seen_ids[$id] = TRUE;
}
}
public function addressEquals($page) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$expected = $this
->cleanUrl($page, TRUE);
$actual = $this
->cleanUrl($this->session
->getCurrentUrl(), strpos($expected, '?') !== FALSE);
$this
->assert($actual === $expected, sprintf('Current page is "%s", but "%s" expected.', $actual, $expected));
}
public function addressNotEquals($page) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
$expected = $this
->cleanUrl($page, TRUE);
$actual = $this
->cleanUrl($this->session
->getCurrentUrl(), strpos($expected, '?') !== FALSE);
$this
->assert($actual !== $expected, sprintf('Current page is "%s", but should not be.', $actual));
}
public function addressMatches($regex) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::addressMatches($regex);
}
public function cookieEquals($name, $value) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::cookieEquals($name, $value);
}
public function cookieExists($name) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::cookieExists($name);
}
public function statusCodeEquals($code) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::statusCodeEquals($code);
}
public function statusCodeNotEquals($code) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::statusCodeNotEquals($code);
}
public function responseHeaderEquals($name, $value) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseHeaderEquals($name, $value);
}
public function responseHeaderNotEquals($name, $value) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseHeaderNotEquals($name, $value);
}
public function responseHeaderContains($name, $value) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseHeaderContains($name, $value);
}
public function responseHeaderNotContains($name, $value) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseHeaderNotContains($name, $value);
}
public function responseHeaderMatches($name, $regex) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseHeaderMatches($name, $regex);
}
public function responseHeaderNotMatches($name, $regex) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseHeaderNotMatches($name, $regex);
}
public function pageTextContains($text) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::pageTextContains($text);
}
public function pageTextNotContains($text) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::pageTextNotContains($text);
}
public function pageTextMatches($regex) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::pageTextMatches($regex);
}
public function pageTextNotMatches($regex) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::pageTextNotMatches($regex);
}
public function responseMatches($regex) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseMatches($regex);
}
public function responseNotMatches($regex) {
if (func_num_args() > 1) {
@trigger_error('Calling ' . __METHOD__ . ' with more than one argument is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::responseNotMatches($regex);
}
public function elementsCount($selectorType, $selector, $count, ElementInterface $container = NULL) {
if (func_num_args() > 4) {
@trigger_error('Calling ' . __METHOD__ . ' with more than four arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementsCount($selectorType, $selector, $count, $container);
}
public function elementExists($selectorType, $selector, ElementInterface $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementExists($selectorType, $selector, $container);
}
public function elementNotExists($selectorType, $selector, ElementInterface $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementNotExists($selectorType, $selector, $container);
}
public function elementTextEquals(string $selectorType, $selector, string $text) : void {
$selector_string = is_array($selector) ? '[' . implode(', ', $selector) . ']' : $selector;
$message = "Failed asserting that the text of the element identified by '{$selector_string}' equals '{$text}'.";
$constraint = new IsEqual($text);
Assert::assertThat($this
->elementExists($selectorType, $selector)
->getText(), $constraint, $message);
}
public function elementTextContains($selectorType, $selector, $text) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementTextContains($selectorType, $selector, $text);
}
public function elementTextNotContains($selectorType, $selector, $text) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementTextNotContains($selectorType, $selector, $text);
}
public function elementContains($selectorType, $selector, $html) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementContains($selectorType, $selector, $html);
}
public function elementNotContains($selectorType, $selector, $html) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementNotContains($selectorType, $selector, $html);
}
public function elementAttributeExists($selectorType, $selector, $attribute) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementAttributeExists($selectorType, $selector, $attribute);
}
public function elementAttributeContains($selectorType, $selector, $attribute, $text) {
if (func_num_args() > 4) {
@trigger_error('Calling ' . __METHOD__ . ' with more than four arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementAttributeContains($selectorType, $selector, $attribute, $text);
}
public function elementAttributeNotContains($selectorType, $selector, $attribute, $text) {
if (func_num_args() > 4) {
@trigger_error('Calling ' . __METHOD__ . ' with more than four arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::elementAttributeNotContains($selectorType, $selector, $attribute, $text);
}
public function fieldExists($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::fieldExists($field, $container);
}
public function fieldNotExists($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::fieldNotExists($field, $container);
}
public function fieldValueEquals($field, $value, TraversableElement $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::fieldValueEquals($field, $value, $container);
}
public function fieldValueNotEquals($field, $value, TraversableElement $container = NULL) {
if (func_num_args() > 3) {
@trigger_error('Calling ' . __METHOD__ . ' with more than three arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::fieldValueNotEquals($field, $value, $container);
}
public function checkboxChecked($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::checkboxChecked($field, $container);
}
public function checkboxNotChecked($field, TraversableElement $container = NULL) {
if (func_num_args() > 2) {
@trigger_error('Calling ' . __METHOD__ . ' with more than two arguments is deprecated in drupal:9.1.0 and will throw an \\InvalidArgumentException in drupal:10.0.0. See https://www.drupal.org/node/3162537', E_USER_DEPRECATED);
}
return parent::checkboxNotChecked($field, $container);
}
}