You are here

public function PostContext::cleanupPost in Open Social 10.3.x

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

@AfterScenario @database&&@post

File

tests/behat/features/bootstrap/PostContext.php, line 19

Class

PostContext
Defines application features from the specific context.

Namespace

Drupal\social\Behat

Code

public function cleanupPost(AfterScenarioScope $scope) {
  $query = \Drupal::entityQuery('post')
    ->condition('field_post', array(
    'This is a public post.',
    'This is a community post.',
  ), 'IN');
  $post_ids = $query
    ->execute();
  $posts = \Drupal::entityTypeManager()
    ->getStorage('post')
    ->loadMultiple($post_ids);
  foreach ($posts as $post) {
    $post
      ->delete();
  }
}