public function FeatureContext::openNodeWithTitle in Open Social 8.4
Same name and namespace in other branches
- 8.9 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 8.3 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 8.5 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 8.6 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 8.7 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 8.8 tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 10.3.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 10.0.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 10.1.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
- 10.2.x tests/behat/features/bootstrap/FeatureContext.php \Drupal\social\Behat\FeatureContext::openNodeWithTitle()
Opens specified node page of type and with title.
@Given /^(?:|I )open the "(?P<type>[^"]+)" node with title "(?P<title>[^"]+)"$/ @When /^(?:|I )go the "(?P<type>[^"]+)" node with title "(?P<title>[^"]+)"$/
File
- tests/
behat/ features/ bootstrap/ FeatureContext.php, line 621
Class
- FeatureContext
- Defines application features from the specific context.
Namespace
Drupal\social\BehatCode
public function openNodeWithTitle($type, $title) {
$query = \Drupal::entityQuery('node')
->condition('type', $type)
->condition('title', $title, '=')
->addTag('DANGEROUS_ACCESS_CHECK_OPT_OUT');
$nids = $query
->execute();
if (!empty($nids) && count($nids) === 1) {
$nid = reset($nids);
$page = '/node/' . $nid;
$this
->visitPath($page);
}
else {
if (count($nids) > 1) {
throw new \Exception(sprintf("Multiple nodes of type '%s' with title '%s' found.", $type, $title));
}
else {
throw new \Exception(sprintf("Node of type '%s' with title '%s' does not exist.", $type, $title));
}
}
}