SlideTypeTest.php in Collapsiblock 4.x
File
tests/src/FunctionalJavascript/SlideTypeTest.php
View source
<?php
namespace Drupal\Tests\collapsiblock\FunctionalJavascript;
class SlideTypeTest extends CollapsiblockJavaScriptTestBase {
protected $collapsiblockTestBlock;
protected $collapsiblockTestBlockTitleXpath;
protected $collapsiblockTestBlockContentXpath;
public function setUp() : void {
parent::setUp();
$this->collapsiblockTestBlock = $this
->drupalPlaceBlock('system_powered_by_block', [
'label_display' => TRUE,
]);
$this
->setCollapsiblockBlockInstanceSetting($this->collapsiblockTestBlock, 2, 'collapse_action');
$testBlockHtmlId = 'block-' . $this->collapsiblockTestBlock
->id();
$this->collapsiblockTestBlockTitleXpath = $this
->assertSession()
->buildXPathQuery('//*[@id=:blockId]//h2', [
':blockId' => $testBlockHtmlId,
]);
$this->collapsiblockTestBlockContentXpath = $this
->assertSession()
->buildXPathQuery('//*[@id=:blockId]//span', [
':blockId' => $testBlockHtmlId,
':class' => 'content',
]);
}
public function testFadeAndSlideSlideType() {
$this
->setCollapsiblockGlobalSetting(2, 'slide_type');
drupal_flush_all_caches();
$this
->drupalLogin($this
->getCollapsiblockUnprivilegedUser());
$this
->drupalGet('<front>');
$beforeContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($beforeContent);
$this
->assertFalse($beforeContent
->hasAttribute('aria-hidden'));
$this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockTitleXpath)
->click();
$afterCollapseContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($afterCollapseContent);
$this
->assertFalse($afterCollapseContent
->hasAttribute('aria-hidden'));
$this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockTitleXpath)
->click();
$afterReExpandContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($afterReExpandContent);
$this
->assertFalse($afterReExpandContent
->hasAttribute('aria-hidden'));
}
public function testSlideSlideType() {
$this
->setCollapsiblockGlobalSetting(1, 'slide_type');
drupal_flush_all_caches();
$this
->drupalLogin($this
->getCollapsiblockUnprivilegedUser());
$this
->drupalGet('<front>');
$beforeContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($beforeContent);
$this
->assertFalse($beforeContent
->hasAttribute('aria-hidden'));
$this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockTitleXpath)
->click();
$afterCollapseContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($afterCollapseContent);
$this
->assertTrue($afterCollapseContent
->hasAttribute('aria-hidden'));
$this
->assertEquals($afterCollapseContent
->getAttribute('aria-hidden'), 'true');
$this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockTitleXpath)
->click();
$afterReExpandContent = $this
->getSession()
->getPage()
->find('xpath', $this->collapsiblockTestBlockContentXpath);
$this
->assertNotNull($afterReExpandContent);
$this
->assertEquals($afterReExpandContent
->getAttribute('aria-hidden'), 'false');
}
}
Classes
Name |
Description |
SlideTypeTest |
Test the "Remember collapsed state on active pages" behavior. |