You are here

protected function CriticalCssProviderTest::setUp in Critical CSS 8

Overrides UnitTestCase::setUp

File

tests/src/Unit/CriticalCssProviderTest.php, line 39

Class

CriticalCssProviderTest
Unit tests for CriticalCssProvider.

Namespace

Drupal\Tests\critical_css\Unit

Code

protected function setUp() {
  $config_factory = $this
    ->getConfigFactoryStub([
    'critical_css_enabled.settings' => [
      'enabled' => TRUE,
      'enabled_for_logged_in_users' => FALSE,
      'preload_non_critical_css' => FALSE,
      'dir_path' => "/css/critical",
      'excluded_ids' => NULL,
    ],
  ]);
  $module_handler = $this
    ->createConfiguredMock(ModuleHandler::class, [
    'alter' => TRUE,
  ]);
  $request = $this
    ->createConfiguredMock(Request::class, [
    'getPathInfo' => '/node/1',
  ]);
  $request_stack = $this
    ->createConfiguredMock(RequestStack::class, [
    'getCurrentRequest' => $request,
  ]);
  $current_route_match = $this
    ->createConfiguredMock(CurrentRouteMatch::class, [
    'getParameter' => NULL,
  ]);
  $current_path_stack = $this
    ->createConfiguredMock(CurrentPathStack::class, [
    'getPath' => '/article/title',
  ]);
  $current_user = $this
    ->createConfiguredMock(AccountProxy::class, [
    'isAnonymous' => TRUE,
  ]);
  $active_theme = $this
    ->createConfiguredMock(ActiveTheme::class, [
    'getPath' => 'core/themes/bartik',
  ]);
  $theme_manager = $this
    ->createConfiguredMock(ThemeManager::class, [
    'getActiveTheme' => $active_theme,
  ]);
  $admin_context = $this
    ->createConfiguredMock(AdminContext::class, [
    'isAdminRoute' => FALSE,
  ]);
  $this->criticalCssProvider = new CriticalCssProvider($module_handler, $request_stack, $config_factory, $current_route_match, $current_path_stack, $current_user, $theme_manager, $admin_context);
}