public function BlockInstanceTest::testBlockInstanceConfigForm in Collapsiblock 3.x
Same name and namespace in other branches
- 4.x tests/src/Functional/BlockInstanceTest.php \Drupal\Tests\collapsiblock\Functional\BlockInstanceTest::testBlockInstanceConfigForm()
Test that the block instance form shows functional Collapsiblock controls.
File
- tests/
src/ Functional/ BlockInstanceTest.php, line 42
Class
- BlockInstanceTest
- Test Collapsiblock settings on block instances.
Namespace
Drupal\Tests\collapsiblock\FunctionalCode
public function testBlockInstanceConfigForm() {
$this
->drupalLogin($this->collapsiblockBlockAdminUser);
$testBlockEditUrl = $this->collapsiblockTestBlock
->toUrl('edit-form');
$this
->drupalGet($testBlockEditUrl);
// Test that the form controls are present.
$this
->assertSession()
->checkboxChecked('edit-collapsiblock-settings-collapse-action-0');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-1');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-2');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-3');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-4');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-5');
// Submit the form with updated values.
$configFormValues = [];
$configFormValues['collapsiblock_settings[collapse_action]'] = 2;
$this
->drupalPostForm($testBlockEditUrl, $configFormValues, t('Save block'));
// Test that the form controls now show the updated configuration.
$this
->drupalGet($testBlockEditUrl);
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-0');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-1');
$this
->assertSession()
->checkboxChecked('edit-collapsiblock-settings-collapse-action-2');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-3');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-4');
$this
->assertSession()
->checkboxNotChecked('edit-collapsiblock-settings-collapse-action-5');
}