function ComponentRenderTest::testCssLibraryAttachesCorrectly

Same name in this branch
  1. 11.x core/modules/sdc/tests/src/FunctionalJavascript/ComponentRenderTest.php \Drupal\Tests\sdc\FunctionalJavascript\ComponentRenderTest::testCssLibraryAttachesCorrectly()
Same name and namespace in other branches
  1. 10 core/modules/sdc/tests/src/FunctionalJavascript/ComponentRenderTest.php \Drupal\Tests\sdc\FunctionalJavascript\ComponentRenderTest::testCssLibraryAttachesCorrectly()
  2. 10 core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php \Drupal\FunctionalJavascriptTests\Components\ComponentRenderTest::testCssLibraryAttachesCorrectly()

Tests that the correct libraries are put on the page using CSS.

This also covers all the path translations necessary to produce the correct path to the assets.

File

core/tests/Drupal/FunctionalJavascriptTests/Components/ComponentRenderTest.php, line 32

Class

ComponentRenderTest
Tests the correct rendering of components.

Namespace

Drupal\FunctionalJavascriptTests\Components

Code

public function testCssLibraryAttachesCorrectly() : void {
  $build = [
    '#type' => 'inline_template',
    '#template' => "{{ include('sdc_theme_test:lib-overrides') }}",
  ];
  \Drupal::state()->set('sdc_test_component', $build);
  $this->drupalGet('sdc-test-component');
  $wrapper = $this->getSession()
    ->getPage()
    ->find('css', '#sdc-wrapper');
  // Opacity is set to 0 in the CSS file (see another-stylesheet.css).
  $this->assertFalse($wrapper->isVisible());
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.