You are here

public function FancyLoginJavascriptTest::testExclusionLink in Fancy Login 8.2

Same name and namespace in other branches
  1. 3.0.x tests/src/FunctionalJavascript/FancyLoginJavascriptTest.php \Drupal\Tests\fancy_login\FunctionalJavascript\FancyLoginJavascriptTest::testExclusionLink()

File

tests/src/FunctionalJavascript/FancyLoginJavascriptTest.php, line 393

Class

FancyLoginJavascriptTest
@group fancy_login

Namespace

Drupal\Tests\fancy_login\FunctionalJavascript

Code

public function testExclusionLink() {

  // Ensure screen is ready
  $this
    ->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":animated")');
  $this
    ->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":animated")');

  // Click the login link
  $this
    ->click('#fancy_login_close_button');

  // Ensure screen is ready
  $this
    ->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":animated")');
  $this
    ->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":animated")');

  // Confirm that the dimmer and form are hidden
  $this
    ->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":visible")');
  $this
    ->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":visible")');

  // Create the inclusion link
  $this
    ->getSession()
    ->executeScript('jQuery("<a/>", {class:"fancy_login_disable", href:"/user/login"}).text("do not open popup").prependTo("body")');
  $link = $this
    ->getSession()
    ->getPage()
    ->find('css', 'a.fancy_login_disable');
  if (!$link) {
    throw new \Exception('Could not create exclusion link');
  }
  $this
    ->getSession()
    ->executeScript('Drupal.attachBehaviors()');

  // Confirm that the dimmer and form are hidden
  $this
    ->assertJsCondition('jQuery("#fancy_login_dim_screen").not(":visible")');
  $this
    ->assertJsCondition('jQuery("#fancy-login-user-login-form").not(":visible")');
  $this
    ->getSession()
    ->executeScript('jQuery("#fancy_login_dim_screen").remove()');

  // Click the exclusion link
  $this
    ->click("a.fancy_login_disable");
  $this
    ->getSession()
    ->wait(5000);
  $this
    ->assertStatusCodeEquals(200);
  $this
    ->assertSession()
    ->addressMatches('/\\/user\\/login$/');
}