You are here

public function ParagraphsStylePluginTest::testStyleOverriding in Paragraphs Collection 8

Tests the style overriding with sub themes.

File

tests/src/FunctionalJavascript/ParagraphsStylePluginTest.php, line 718

Class

ParagraphsStylePluginTest
Tests the style selection plugin.

Namespace

Drupal\Tests\paragraphs_collection\FunctionalJavascript

Code

public function testStyleOverriding() {

  // Install theme c and assert that the gotten style has the class "c".
  \Drupal::service('module_installer')
    ->install([
    'paragraphs_collection_test',
  ]);
  $style_discovery = \Drupal::getContainer()
    ->get('paragraphs_collection.style_discovery');
  $style = $style_discovery
    ->getStyle('style-overridden');
  $this
    ->assertEquals($style['title'], new TranslatableMarkup('Overridden style Module'));
  $this
    ->assertEquals($style['classes'], [
    'overridden-style-module',
  ]);
  \Drupal::service('theme_installer')
    ->install([
    'paragraphs_collection_test_theme_a',
  ]);
  $style = $style_discovery
    ->getStyle('style-overridden');
  $this
    ->assertEquals($style['title'], new TranslatableMarkup('Overridden style A'));
  $this
    ->assertEquals($style['classes'], [
    'overridden-style-a',
  ]);
  \Drupal::service('theme_installer')
    ->uninstall([
    'paragraphs_collection_test_theme_a',
  ]);
  $style = $style_discovery
    ->getStyle('style-overridden');
  $this
    ->assertEquals($style['title'], new TranslatableMarkup('Overridden style C'));
  $this
    ->assertEquals($style['classes'], [
    'overridden-style-c',
  ]);
}