public function CollapseActionTest::testCollapsibleAlwaysCollapsed in Collapsiblock 3.x
Same name and namespace in other branches
- 4.x tests/src/FunctionalJavascript/CollapseActionTest.php \Drupal\Tests\collapsiblock\FunctionalJavascript\CollapseActionTest::testCollapsibleAlwaysCollapsed()
Test the "Collapsible, collapsed all the time" Block Collapse Behavior.
File
- tests/
src/ FunctionalJavascript/ CollapseActionTest.php, line 61
Class
- CollapseActionTest
- Test that collapse actions work as-intended.
Namespace
Drupal\Tests\collapsiblock\FunctionalJavascriptCode
public function testCollapsibleAlwaysCollapsed() {
// Set the collapse action.
$this
->setCollapsiblockBlockInstanceSetting($this->collapsiblockTestBlock, 4, 'collapse_action');
// Load a page that the block will be displayed on.
$this
->drupalLogin($this
->getCollapsiblockUnprivilegedUser());
$this
->drupalGet('<front>');
// Check that initially, the block title is visible but the contents are not
// 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
->assertFalse($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());
}