You are here

public function GlobalConfigurationTest::testGlobalConfigOutput in Collapsiblock 3.x

Same name and namespace in other branches
  1. 4.x tests/src/Functional/GlobalConfigurationTest.php \Drupal\Tests\collapsiblock\Functional\GlobalConfigurationTest::testGlobalConfigOutput()

Test global configuration is output to pages.

Note this is a slow test because we have to repeatedly flush caches after changing each global configuration setting in order for it to be output.

File

tests/src/Functional/GlobalConfigurationTest.php, line 90

Class

GlobalConfigurationTest
Test the Collapsiblock global configuration form.

Namespace

Drupal\Tests\collapsiblock\Functional

Code

public function testGlobalConfigOutput() {
  $this
    ->drupalLogin($this
    ->getCollapsiblockUnprivilegedUser());

  // Test that the default configuration values are output when the site has
  // been freshly installed. Note that the default_action is NOT output.
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->responseContains('"collapsiblock":{"active_pages":false,"slide_type":1,"slide_speed":200}');

  // Test that the default action still is not output, even after changing
  // settings.
  $this
    ->setCollapsiblockGlobalSetting(2, 'default_action');
  drupal_flush_all_caches();
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->responseContains('"collapsiblock":{"active_pages":false,"slide_type":1,"slide_speed":200}');

  // Test that a changed active_pages is output. Note we (intentionally) did
  // not reset global settings to their default since the last global settings
  // change.
  $this
    ->setCollapsiblockGlobalSetting(TRUE, 'active_pages');
  drupal_flush_all_caches();
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->responseContains('"collapsiblock":{"active_pages":true,"slide_type":1,"slide_speed":200}');

  // Test that a changed slide_type is output. Note we (intentionally) did not
  // reset global settings to their default since the last global settings
  // change.
  $this
    ->setCollapsiblockGlobalSetting(2, 'slide_type');
  drupal_flush_all_caches();
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->responseContains('"collapsiblock":{"active_pages":true,"slide_type":2,"slide_speed":200}');

  // Test that a changed slide_speed is output. Note we (intentionally) did
  // not reset global settings to their default since the last global settings
  // change.
  $this
    ->setCollapsiblockGlobalSetting(500, 'slide_speed');
  drupal_flush_all_caches();
  $this
    ->drupalGet('<front>');
  $this
    ->assertSession()
    ->responseContains('"collapsiblock":{"active_pages":true,"slide_type":2,"slide_speed":500}');
}