You are here

public function SocialDrupalContext::prepareBigPipeNoJsCookie in Open Social 10.3.x

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

Prepares Big Pipe NOJS cookie if needed.

Add support for Bigpipe in Behat tests.

Original PR here: https://github.com/jhedstrom/drupalextension/pull/325

@BeforeScenario

File

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

Class

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

Namespace

Drupal\social\Behat

Code

public function prepareBigPipeNoJsCookie(BeforeScenarioScope $scope) {

  // Start a session if not already done.
  // Needed since https://github.com/minkphp/Mink/pull/705
  // Otherwise executeScript or setCookie will throw an error.
  if (!$this
    ->getSession()
    ->isStarted()) {
    $this
      ->getSession()
      ->start();
  }
  try {

    // Check if JavaScript can be executed by Driver.
    $this
      ->getSession()
      ->getDriver()
      ->executeScript('true');
  } catch (UnsupportedDriverActionException $e) {

    // Set NOJS cookie.
    if ($this
      ->getSession()) {
      $this
        ->getSession()
        ->setCookie(BigPipeStrategy::NOJS_COOKIE, TRUE);
    }
  } catch (\Exception $e) {

    // Mute exceptions.
  }
}