You are here

public function BlockInstanceTest::testBlockInstanceConfigForm in Collapsiblock 4.x

Same name and namespace in other branches
  1. 3.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\Functional

Code

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
    ->submitForm($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');
}