You are here

public function CookieTest::testCookieWithPaths in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/behat/mink/driver-testsuite/tests/Basic/CookieTest.php \Behat\Mink\Tests\Driver\Basic\CookieTest::testCookieWithPaths()

@dataProvider cookieWithPathsDataProvider

File

vendor/behat/mink/driver-testsuite/tests/Basic/CookieTest.php, line 53

Class

CookieTest

Namespace

Behat\Mink\Tests\Driver\Basic

Code

public function testCookieWithPaths($cookieRemovalMode) {

  // start clean
  $session = $this
    ->getSession();
  $session
    ->visit($this
    ->pathTo('/sub-folder/cookie_page2.php'));
  $this
    ->assertContains('Previous cookie: NO', $session
    ->getPage()
    ->getText());

  // cookie from root path is accessible in sub-folder
  $session
    ->visit($this
    ->pathTo('/cookie_page1.php'));
  $session
    ->visit($this
    ->pathTo('/sub-folder/cookie_page2.php'));
  $this
    ->assertContains('Previous cookie: srv_var_is_set', $session
    ->getPage()
    ->getText());

  // cookie from sub-folder overrides cookie from root path
  $session
    ->visit($this
    ->pathTo('/sub-folder/cookie_page1.php'));
  $session
    ->visit($this
    ->pathTo('/sub-folder/cookie_page2.php'));
  $this
    ->assertContains('Previous cookie: srv_var_is_set_sub_folder', $session
    ->getPage()
    ->getText());
  if ($cookieRemovalMode == 'session_reset') {
    $session
      ->reset();
  }
  elseif ($cookieRemovalMode == 'cookie_delete') {
    $session
      ->setCookie('srvr_cookie', null);
  }

  // cookie is removed from all paths
  $session
    ->visit($this
    ->pathTo('/sub-folder/cookie_page2.php'));
  $this
    ->assertContains('Previous cookie: NO', $session
    ->getPage()
    ->getText());
}