You are here

ModuleLegacyTest.php in Drupal 10

File

core/tests/Drupal/KernelTests/Core/Extension/ModuleLegacyTest.php
View source
<?php

namespace Drupal\KernelTests\Core\Extension;

use Drupal\KernelTests\KernelTestBase;

/**
 * Tests deprecations from module.inc file.
 *
 * @group legacy
 */
class ModuleLegacyTest extends KernelTestBase {

  /**
   * Test deprecation of module_load_include() function.
   */
  public function testModuleLoadInclude() {
    $this
      ->assertFalse($this->container
      ->get('module_handler')
      ->moduleExists('module_test'), 'Ensure module is uninstalled so we test the ability to include uninstalled code.');
    $this
      ->expectDeprecation('module_load_include() is deprecated in drupal:9.4.0 and is removed from drupal:11.0.0. Instead, you should use \\Drupal::moduleHandler()->loadInclude(). Note that including code from uninstalled extensions is no longer supported. See https://www.drupal.org/project/drupal/issues/697946');
    $filename = module_load_include('inc', 'module_test', 'module_test.file');
    $this
      ->assertStringEndsWith("module_test.file.inc", $filename);
  }

}

Classes

Namesort descending Description
ModuleLegacyTest Tests deprecations from module.inc file.