function LibraryDiscoveryParserTest::testLibraryOverrideDeprecated

Same name and namespace in other branches
  1. 10 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 672

Class

LibraryDiscoveryParserTest
@coversDefaultClass <a href="/api/drupal/core%21lib%21Drupal%21Core%21Asset%21LibraryDiscoveryParser.php/class/LibraryDiscoveryParser/9" title="Parses library files to get extension data." class="local">\Drupal\Core\Asset\LibraryDiscoveryParser</a> @group Asset

Namespace

Drupal\Tests\Core\Asset

Code

public function testLibraryOverrideDeprecated() {
    $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->libraryDiscoveryParser = new TestLibraryDiscoveryParser($this->root, $this->moduleHandler, $this->themeManager, $this->streamWrapperManager, $this->librariesDirectoryFileFinder, $this->extensionPathResolver);
    $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.