function LibraryDiscoveryParserTest::testLibraryOverrideDeprecated

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest::testLibraryOverrideDeprecated()
  2. 11.x core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php \Drupal\Tests\Core\Asset\LibraryDiscoveryParserTest::testLibraryOverrideDeprecated()

Tests deprecated library with an override.

@covers ::applyLibrariesOverride

@group legacy

File

core/tests/Drupal/Tests/Core/Asset/LibraryDiscoveryParserTest.php, line 692

Class

LibraryDiscoveryParserTest
@coversDefaultClass \Drupal\Core\Asset\LibraryDiscoveryParser @group Asset

Namespace

Drupal\Tests\Core\Asset

Code

public function testLibraryOverrideDeprecated() : void {
    $this->expectDeprecation('Theme "deprecated" is overriding a deprecated library. The "deprecated/deprecated" asset library is deprecated in drupal:X.0.0 and is removed from drupal:Y.0.0. Use another library instead. See https://www.example.com');
    $mock_theme_path = 'mocked_themes/kittens';
    $this->themeManager = $this->createMock(ThemeManagerInterface::class);
    $this->activeTheme = $this->getMockBuilder(ActiveTheme::class)
        ->disableOriginalConstructor()
        ->getMock();
    $this->activeTheme
        ->expects($this->atLeastOnce())
        ->method('getLibrariesOverride')
        ->willReturn([
        $mock_theme_path => [
            'deprecated/deprecated' => [
                'css' => [
                    'theme' => [
                        'css/example.css' => 'css/overridden.css',
                    ],
                ],
            ],
        ],
    ]);
    $this->themeManager
        ->expects($this->any())
        ->method('getActiveTheme')
        ->willReturn($this->activeTheme);
    $path = __DIR__ . '/library_test_files';
    $path = substr($path, strlen($this->root) + 1);
    $this->extensionPathResolver
        ->expects($this->atLeastOnce())
        ->method('getPath')
        ->with('module', 'deprecated')
        ->willReturn($path);
    $this->componentPluginManager = $this->createMock(ComponentPluginManager::class);
    $this->libraryDiscoveryParser = new TestLibraryDiscoveryParser($this->root, $this->moduleHandler, $this->themeManager, $this->streamWrapperManager, $this->librariesDirectoryFileFinder, $this->extensionPathResolver, $this->componentPluginManager);
    $this->moduleHandler
        ->expects($this->atLeastOnce())
        ->method('moduleExists')
        ->with('deprecated')
        ->willReturn(TRUE);
    $this->libraryDiscoveryParser
        ->buildByExtension('deprecated');
}

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