You are here

public function CollapseActionTest::testNoAction in Collapsiblock 3.x

Same name and namespace in other branches
  1. 4.x tests/src/FunctionalJavascript/CollapseActionTest.php \Drupal\Tests\collapsiblock\FunctionalJavascript\CollapseActionTest::testNoAction()

Test the "None" Block Collapse Behavior makes no change.

File

tests/src/FunctionalJavascript/CollapseActionTest.php, line 189

Class

CollapseActionTest
Test that collapse actions work as-intended.

Namespace

Drupal\Tests\collapsiblock\FunctionalJavascript

Code

public function testNoAction() {

  // Set the collapse action.
  $this
    ->setCollapsiblockBlockInstanceSetting($this->collapsiblockTestBlock, 1, 'collapse_action');

  // Load a page that the block will be displayed on.
  $this
    ->drupalLogin($this
    ->getCollapsiblockUnprivilegedUser());
  $this
    ->drupalGet('<front>');

  // Check that the block title and contents are initially visible.
  $beforeTitle = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockTitleXpath);
  $this
    ->assertNotNull($beforeTitle);
  $this
    ->assertTrue($beforeTitle
    ->isVisible());
  $beforeContent = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockContentXpath);
  $this
    ->assertNotNull($beforeContent);
  $this
    ->assertTrue($beforeContent
    ->isVisible());

  // Click on the block title.
  $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockTitleXpath)
    ->click();

  // Check that the block title and contents are visible after the click.
  $afterTitle = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockTitleXpath);
  $this
    ->assertNotNull($afterTitle);
  $this
    ->assertTrue($afterTitle
    ->isVisible());
  $afterContent = $this
    ->getSession()
    ->getPage()
    ->find('xpath', $this->collapsiblockTestBlockContentXpath);
  $this
    ->assertNotNull($afterContent);
  $this
    ->assertTrue($afterContent
    ->isVisible());
}