public function SocialDrupalContext::assertViewingMyNode in Open Social 8.8
Same name and namespace in other branches
- 8.9 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 8.3 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 8.4 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 8.5 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 8.6 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 8.7 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 10.3.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 10.0.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 10.1.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
- 10.2.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::assertViewingMyNode()
Creates content of the given type for the current user, provided in the form: | title | My node | | Field One | My field value | | status | 1 | | ... | ... |
@Given I am viewing my :type( content):
File
- tests/
behat/ features/ bootstrap/ SocialDrupalContext.php, line 74
Class
- SocialDrupalContext
- Provides pre-built step definitions for interacting with Open Social.
Namespace
Drupal\social\BehatCode
public function assertViewingMyNode($type, TableNode $fields) {
$user_manager = $this
->getUserManager();
$user = $user_manager
->getCurrentUser();
if (!$user) {
throw new \Exception(sprintf('There is no current logged in user to create a node for.'));
}
$node = (object) array(
'type' => $type,
);
foreach ($fields
->getRowsHash() as $field => $value) {
if (strpos($field, 'date') !== FALSE) {
$value = date('Y-m-d H:i:s', strtotime($value));
}
$node->{$field} = $value;
}
$node->uid = $user->uid;
$saved = $this
->nodeCreate($node);
// Set internal browser on the node.
$this
->getSession()
->visit($this
->locatePath('/node/' . $saved->nid));
}