You are here

public function SocialDrupalContext::assertViewingNode in Open Social 8.8

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

@override DrupalContext:assertViewingNode().

To support relative dates.

File

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

Class

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

Namespace

Drupal\social\Behat

Code

public function assertViewingNode($type, TableNode $fields) {
  $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;
  }
  $saved = $this
    ->nodeCreate($node);

  // Set internal browser on the node.
  $this
    ->getSession()
    ->visit($this
    ->locatePath('/node/' . $saved->nid));
}