private function SocialMessageContext::_assertRegion in Open Social 10.2.x
Same name and namespace in other branches
- 10.3.x tests/behat/features/bootstrap/SocialMessageContext.php \Drupal\social\Behat\SocialMessageContext::_assertRegion()
- 10.0.x tests/behat/features/bootstrap/SocialMessageContext.php \Drupal\social\Behat\SocialMessageContext::_assertRegion()
- 10.1.x tests/behat/features/bootstrap/SocialMessageContext.php \Drupal\social\Behat\SocialMessageContext::_assertRegion()
Internal callback to check for a specific message in a given context.
Parameters
$message: string The message to be checked
$selectorId: string CSS selector name
$exceptionMsgNone: string The message being thrown when no message is contained, string should contain one '%s' as a placeholder for the current URL
$exceptionMsgMissing: string The message being thrown when the message is not contained, string should contain two '%s' as placeholders for the current URL and the message.
$region: string The region
Throws
\Behat\Mink\Exception\ExpectationException Thrown when the expected message is not present in the page.
1 call to SocialMessageContext::_assertRegion()
- SocialMessageContext::assertRegionSuccessMessage in tests/
behat/ features/ bootstrap/ SocialMessageContext.php - Checks if the current page contains the given success message
File
- tests/
behat/ features/ bootstrap/ SocialMessageContext.php, line 53
Class
- SocialMessageContext
- Provides step-definitions for interacting with Drupal messages.
Namespace
Drupal\social\BehatCode
private function _assertRegion($message, $selectorId, $exceptionMsgNone, $exceptionMsgMissing, $region) {
$session = $this
->getSession();
$regionObj = $session
->getPage()
->find('region', $region);
$selector = $this
->getDrupalSelector($selectorId);
$selectorObjects = $regionObj
->findAll('css', $selector);
if (empty($selectorObjects)) {
throw new ExpectationException(sprintf($exceptionMsgNone, $session
->getCurrentUrl()), $session
->getDriver());
}
foreach ($selectorObjects as $selectorObject) {
if (strpos(trim($selectorObject
->getText()), $message) !== FALSE) {
return;
}
}
throw new ExpectationException(sprintf($exceptionMsgMissing, $session
->getCurrentUrl(), $message), $session
->getDriver());
}