composer update

This commit is contained in:
Oliver Davies 2019-01-24 08:00:03 +00:00
parent f6abc3dce2
commit 71dfaca858
1753 changed files with 45274 additions and 14619 deletions

View file

@ -3,6 +3,7 @@
namespace Drupal\Tests;
use Behat\Mink\Exception\ExpectationException;
use Behat\Mink\Exception\ResponseTextException;
use Behat\Mink\WebAssert as MinkWebAssert;
use Behat\Mink\Element\TraversableElement;
use Behat\Mink\Exception\ElementNotFoundException;
@ -545,4 +546,31 @@ class WebAssert extends MinkWebAssert {
$this->assert(!preg_match($regex, $actual), $message);
}
/**
* Checks that current page contains text only once.
*
* @param string $text
* The string to look for.
*
* @see \Behat\Mink\WebAssert::pageTextContains()
*/
public function pageTextContainsOnce($text) {
$actual = $this->session->getPage()->getText();
$actual = preg_replace('/\s+/u', ' ', $actual);
$regex = '/' . preg_quote($text, '/') . '/ui';
$count = preg_match_all($regex, $actual);
if ($count === 1) {
return;
}
if ($count > 1) {
$message = sprintf('The text "%s" appears in the text of this page more than once, but it should not.', $text);
}
else {
$message = sprintf('The text "%s" was not found anywhere in the text of the current page.', $text);
}
throw new ResponseTextException($message, $this->session->getDriver());
}
}