You are here

public function FrameworkTest::testLazyLoadOverriddenCSS in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/system/src/Tests/Ajax/FrameworkTest.php \Drupal\system\Tests\Ajax\FrameworkTest::testLazyLoadOverriddenCSS()

Tests that overridden CSS files are not added during lazy load.

File

core/modules/system/src/Tests/Ajax/FrameworkTest.php, line 200
Contains \Drupal\system\Tests\Ajax\FrameworkTest.

Class

FrameworkTest
Performs tests on AJAX framework functions.

Namespace

Drupal\system\Tests\Ajax

Code

public function testLazyLoadOverriddenCSS() {

  // The test theme overrides system.module.css without an implementation,
  // thereby removing it.
  \Drupal::service('theme_handler')
    ->install(array(
    'test_theme',
  ));
  $this
    ->config('system.theme')
    ->set('default', 'test_theme')
    ->save();

  // This gets the form, and emulates an Ajax submission on it, including
  // adding markup to the HEAD and BODY for any lazy loaded JS/CSS files.
  $this
    ->drupalPostAjaxForm('ajax_forms_test_lazy_load_form', array(
    'add_files' => TRUE,
  ), array(
    'op' => t('Submit'),
  ));

  // Verify that the resulting HTML does not load the overridden CSS file.
  // We add a "?" to the assertion, because drupalSettings may include
  // information about the file; we only really care about whether it appears
  // in a LINK or STYLE tag, for which Drupal always adds a query string for
  // cache control.
  $this
    ->assertNoText('system.module.css?', 'Ajax lazy loading does not add overridden CSS files.');
}