You are here

public function SocialDrupalContext::createNodes in Open Social 8.6

Same name and namespace in other branches
  1. 8.9 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  2. 8.3 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  3. 8.4 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  4. 8.5 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  5. 8.7 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  6. 8.8 tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  7. 10.3.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  8. 10.0.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  9. 10.1.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()
  10. 10.2.x tests/behat/features/bootstrap/SocialDrupalContext.php \Drupal\social\Behat\SocialDrupalContext::createNodes()

@override DrupalContext:createNodes().

To support relative dates.

File

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

Class

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

Namespace

Drupal\social\Behat

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);
    }
  }
}