function ModuleHandlerTest::testAddProfile

Same name in other branches
  1. 9 core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testAddProfile()
  2. 8.9.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testAddProfile()
  3. 11.x core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php \Drupal\Tests\Core\Extension\ModuleHandlerTest::testAddProfile()

Tests adding a profile.

@covers ::addProfile @covers ::add

File

core/tests/Drupal/Tests/Core/Extension/ModuleHandlerTest.php, line 230

Class

ModuleHandlerTest
@coversDefaultClass \Drupal\Core\Extension\ModuleHandler @runTestsInSeparateProcesses

Namespace

Drupal\Tests\Core\Extension

Code

public function testAddProfile() : void {
    $module_handler = $this->getMockBuilder(ModuleHandler::class)
        ->setConstructorArgs([
        $this->root,
        [],
        $this->cacheBackend,
    ])
        ->onlyMethods([
        'resetImplementations',
    ])
        ->getMock();
    // Ensure we reset implementations when settings a new modules list.
    $module_handler->expects($this->once())
        ->method('resetImplementations');
    // @todo this should probably fail since its a module not a profile.
    $module_handler->addProfile('module_handler_test', 'core/tests/Drupal/Tests/Core/Extension/modules/module_handler_test');
    $this->assertTrue($module_handler->moduleExists('module_handler_test'));
}

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