You are here

public function AssetCollectorTest::testAlterCss in Entity Print 8.2

Test that we can alter the CSS using the event.

File

tests/src/Unit/AssetCollectorTest.php, line 33

Class

AssetCollectorTest
Test the asset collector service.

Namespace

Drupal\Tests\entity_print\Unit

Code

public function testAlterCss() {
  $event_dispatcher = $this
    ->prophesize(EventDispatcherInterface::class);
  $event_dispatcher
    ->dispatch(Argument::cetera())
    ->will(function ($args) {

    // Argument 1 is the PrintCssAlterEvent.
    $args[1]
      ->getBuild()[] = 'my_theme/my_css';
  });
  $asset_collector = new AssetCollector($this
    ->getThemeHandlerMock()
    ->reveal(), $this
    ->getInfoParserMock()
    ->reveal(), $event_dispatcher
    ->reveal());
  $this
    ->assertEquals([
    'my_theme/my_css',
  ], $asset_collector
    ->getCssLibraries([]));
}