Behat: And I remember this node.
SOmetimes you have to create several nodes of varying content types to ultimately test something that refers back to something other than the last node created. Here are two step functions that can carry out that action
This one saves or marks the node for later recall.
<?php
/**
* @Given /^I remember this node$/
*/
public function iRememberThisNode() {
$node = $this->getLastCreatedEntity("node");
variable_set('remembered_node', $node->nid);
}
?>
This one recalls the saved node for final testing.
<?php
/**
* @Then /^I visit the remembered node$/
*/
public function iVisitTheRememberedNode() {
$nid = variable_get('remembered_node', '');
if (!empty($nid)) {
$this->getSession()->visit($this->locatePath('/node/' . $nid));
}
}
?>