function ClassLoaderTest::testClassLoadingNotInstalledModules

Same name in other branches
  1. 8.9.x core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php \Drupal\Tests\system\Functional\Module\ClassLoaderTest::testClassLoadingNotInstalledModules()
  2. 10 core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php \Drupal\Tests\system\Functional\Module\ClassLoaderTest::testClassLoadingNotInstalledModules()
  3. 11.x core/modules/system/tests/src/Functional/Module/ClassLoaderTest.php \Drupal\Tests\system\Functional\Module\ClassLoaderTest::testClassLoadingNotInstalledModules()

Tests that module-provided classes can't be loaded if module not installed.

See also

\Drupal\module_autoload_test\SomeClass

File

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

Class

ClassLoaderTest
Tests class loading for modules.

Namespace

Drupal\Tests\system\Functional\Module

Code

public function testClassLoadingNotInstalledModules() {
    // Enable the module_test module.
    \Drupal::service('module_installer')->install([
        'module_test',
    ], FALSE);
    $this->resetAll();
    // Check twice to test an unprimed and primed system_list() cache.
    for ($i = 0; $i < 2; $i++) {
        $this->drupalGet('module-test/class-loading');
        $this->assertSession()
            ->statusCodeEquals(200);
        $this->assertSession()
            ->pageTextNotContains($this->expected);
    }
}

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