You are here

public function ClassLoaderTest::testAutoloadFromModuleFile in Drupal 10

Same name and namespace in other branches
  1. 8 core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php \Drupal\Tests\system\Functional\Module\ClassLoaderTest::testAutoloadFromModuleFile()
  2. 9 core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php \Drupal\Tests\system\Functional\Module\ClassLoaderTest::testAutoloadFromModuleFile()

Tests that .module files can use class constants in main section.

File

core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php, line 104

Class

ClassLoaderTest
Tests class loading for modules.

Namespace

Drupal\Tests\system\Functional\Module

Code

public function testAutoloadFromModuleFile() {
  $this
    ->assertFalse(defined('MODULE_AUTOLOAD_TEST_CONSTANT'));
  $this
    ->drupalLogin($this->rootUser);
  $edit = [
    "modules[module_autoload_test][enable]" => TRUE,
  ];
  $this
    ->drupalGet('admin/modules');
  $this
    ->submitForm($edit, 'Install');
  $this
    ->assertSession()
    ->statusCodeEquals(200);
  $this
    ->resetAll();
  $this
    ->assertSame(SomeClass::TEST, MODULE_AUTOLOAD_TEST_CONSTANT);
}