function AssetResolverTest::setUp

Same name in other branches
  1. 8.9.x core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php \Drupal\Tests\Core\Asset\AssetResolverTest::setUp()
  2. 10 core/tests/Drupal/Tests/Core/Asset/AssetResolverTest.php \Drupal\Tests\Core\Asset\AssetResolverTest::setUp()
  3. 11.x 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

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);
}

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