You are here

public function FlexsliderTest::testSettings in Flex Slider 8.2

Test settings and their affect on loading FlexSlider assets.

This works since aggregation is off by default in SimpleTest.

File

tests/src/Functional/FlexsliderTest.php, line 226

Class

FlexsliderTest
Test the FlexSlider presets, configuration options and permission controls.

Namespace

Drupal\Tests\flexslider\Functional

Code

public function testSettings() {

  // Login with admin user.
  $this
    ->drupalLogin($this->adminUser);

  // Debug flag initially off.
  $this
    ->assertRaw('libraries/flexslider/jquery.flexslider-min.js');

  // Change the debug settings.
  $this
    ->drupalGet('admin/config/media/flexslider/advanced');
  $settings['flexslider_debug'] = TRUE;
  $this
    ->drupalPostForm('admin/config/media/flexslider/advanced', $settings, $this
    ->t('Save configuration'));
  $this
    ->assertResponse(200);
  $this
    ->assertText('The configuration options have been saved.');
  $this
    ->drupalGet('user/' . $this->adminUser
    ->id());
  $this
    ->assertRaw('libraries/flexslider/jquery.flexslider.js');

  // Test the css settings.
  // Show that the css files are originally loaded.
  $this
    ->assertRaw('libraries/flexslider/flexslider.css');
  $this
    ->assertRaw('flexslider/assets/css/flexslider_img.css');

  // Turn off the css.
  $this
    ->drupalGet('admin/config/media/flexslider/advanced');
  $settings = [
    'flexslider_css' => FALSE,
    'integration_css' => FALSE,
  ];
  $this
    ->drupalPostForm('admin/config/media/flexslider/advanced', $settings, $this
    ->t('Save configuration'));
  $this
    ->drupalGet('user/' . $this->adminUser
    ->id());

  // Show css is not loaded when flags are off.
  $this
    ->assertNoRaw('libraries/flexslider/flexslider.css');
  $this
    ->assertNoRaw('flexslider/assets/css/flexslider_img.css');
}