function RegistryTest::testPostProcessExtension

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Theme/RegistryTest.php \Drupal\Tests\Core\Theme\RegistryTest::testPostProcessExtension()
  2. 10 core/tests/Drupal/Tests/Core/Theme/RegistryTest.php \Drupal\Tests\Core\Theme\RegistryTest::testPostProcessExtension()
  3. 11.x core/tests/Drupal/Tests/Core/Theme/RegistryTest.php \Drupal\Tests\Core\Theme\RegistryTest::testPostProcessExtension()

@covers ::postProcessExtension @covers ::completeSuggestion @covers ::mergePreprocessFunctions

@dataProvider providerTestPostProcessExtension

Parameters

array $defined_functions: An array of functions to be used in place of get_defined_functions().

array $hooks: An array of theme hooks to process.

array $expected: The expected results.

File

core/tests/Drupal/Tests/Core/Theme/RegistryTest.php, line 176

Class

RegistryTest
@coversDefaultClass \Drupal\Core\Theme\Registry @group Theme

Namespace

Drupal\Tests\Core\Theme

Code

public function testPostProcessExtension($defined_functions, $hooks, $expected) {
    static::$functions['user'] = $defined_functions;
    $theme = $this->prophesize(ActiveTheme::class);
    $theme->getBaseThemeExtensions()
        ->willReturn([]);
    $theme->getName()
        ->willReturn('test');
    $theme->getEngine()
        ->willReturn('twig');
    $this->moduleHandler
        ->expects($this->atLeastOnce())
        ->method('getModuleList')
        ->willReturn([]);
    $class = new \ReflectionClass(Registry::class);
    $reflection_method = $class->getMethod('postProcessExtension');
    $reflection_method->setAccessible(TRUE);
    $reflection_method->invokeArgs($this->registry, [
        &$hooks,
        $theme->reveal(),
    ]);
    $this->assertArrayEquals($expected, $hooks);
}

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