You are here

public function SocialDrupalContext::createNodes in Open Social 8.2

Same name and namespace in other branches
  1. 8 tests/behat/features/bootstrap/SocialDrupalContext.php \SocialDrupalContext::createNodes()

@override DrupalContext:createNodes().

To support relative dates.

File

tests/behat/features/bootstrap/SocialDrupalContext.php, line 117

Class

SocialDrupalContext
Provides pre-built step definitions for interacting with Open Social.

Code

public function createNodes($type, TableNode $nodesTable) {
  foreach ($nodesTable
    ->getHash() as $nodeHash) {
    $node = (object) $nodeHash;
    $node->type = $type;
    if (isset($node->field_event_date)) {
      $node->field_event_date = date('Y-m-d H:i:s', strtotime($node->field_event_date));
    }
    $entity = $this
      ->nodeCreate($node);
    if (isset($node->alias)) {
      \Drupal::service('path.alias_storage')
        ->save("/node/" . $entity->nid, $node->alias);
    }
  }
}