You are here

protected function AssetResolverTest::setUp in Drupal 10

Same name and namespace in other branches
  1. 8 core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php \Drupal\Tests\Core\Asset\AssetResolverTest::setUp()
  2. 9 core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php \Drupal\Tests\Core\Asset\AssetResolverTest::setUp()

Overrides UnitTestCase::setUp

File

core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php, line 74
Contains \Drupal\Tests\Core\Asset\AssetResolverTest.

Class

AssetResolverTest
@coversDefaultClass \Drupal\Core\Asset\AssetResolver @group Asset

Namespace

Drupal\Tests\Core\Asset

Code

protected function setUp() : void {
  parent::setUp();
  $this->libraryDiscovery = $this
    ->getMockBuilder('Drupal\\Core\\Asset\\LibraryDiscovery')
    ->disableOriginalConstructor()
    ->getMock();
  $this->libraryDependencyResolver = $this
    ->createMock('\\Drupal\\Core\\Asset\\LibraryDependencyResolverInterface');
  $this->libraryDependencyResolver
    ->expects($this
    ->any())
    ->method('getLibrariesWithDependencies')
    ->willReturnArgument(0);
  $this->moduleHandler = $this
    ->createMock('\\Drupal\\Core\\Extension\\ModuleHandlerInterface');
  $this->themeManager = $this
    ->createMock('\\Drupal\\Core\\Theme\\ThemeManagerInterface');
  $active_theme = $this
    ->getMockBuilder('\\Drupal\\Core\\Theme\\ActiveTheme')
    ->disableOriginalConstructor()
    ->getMock();
  $this->themeManager
    ->expects($this
    ->any())
    ->method('getActiveTheme')
    ->willReturn($active_theme);
  $this->languageManager = $this
    ->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
  $english = $this
    ->createMock('\\Drupal\\Core\\Language\\LanguageInterface');
  $english
    ->expects($this
    ->any())
    ->method('getId')
    ->willReturn('en');
  $japanese = $this
    ->createMock('\\Drupal\\Core\\Language\\LanguageInterface');
  $japanese
    ->expects($this
    ->any())
    ->method('getId')
    ->willReturn('jp');
  $this->languageManager = $this
    ->createMock('\\Drupal\\Core\\Language\\LanguageManagerInterface');
  $this->languageManager
    ->expects($this
    ->any())
    ->method('getCurrentLanguage')
    ->will($this
    ->onConsecutiveCalls($english, $english, $japanese, $japanese));
  $this->cache = new TestMemoryBackend();
  $this->assetResolver = new AssetResolver($this->libraryDiscovery, $this->libraryDependencyResolver, $this->moduleHandler, $this->themeManager, $this->languageManager, $this->cache);
}