function DrupalKernelTest::testClassLoaderAutoDetect
Tests class_loader_auto_detect setting.
This test runs in a separate process since it registers class loaders and results in statics being set.
@runInSeparateProcess
@preserveGlobalState disabled
@covers ::boot
      
    
@dataProvider providerClassLoaderAutoDetect
Parameters
bool $value: The value to set class_loader_auto_detect to.
File
- 
              core/tests/ Drupal/ KernelTests/ Core/ DrupalKernel/ DrupalKernelTest.php, line 231 
Class
- DrupalKernelTest
- Tests DIC compilation to disk.
Namespace
Drupal\KernelTests\Core\DrupalKernelCode
public function testClassLoaderAutoDetect($value) {
  // Create a virtual file system containing items that should be
  // excluded. Exception being modules directory.
  vfsStream::setup('root', NULL, [
    'sites' => [
      'default' => [],
    ],
    'core' => [
      'lib' => [
        'Drupal' => [
          'Core' => [],
          'Component' => [],
        ],
      ],
    ],
  ]);
  $this->setSetting('class_loader_auto_detect', $value);
  $classloader = $this->prophesize(ClassLoader::class);
  // Assert that we call the setApcuPrefix on the classloader if
  // class_loader_auto_detect is set to TRUE;
  if ($value) {
    $classloader->setApcuPrefix(Argument::type('string'))
      ->shouldBeCalled();
  }
  else {
    $classloader->setApcuPrefix(Argument::type('string'))
      ->shouldNotBeCalled();
  }
  // Create a kernel suitable for testing.
  $kernel = new DrupalKernel('test', $classloader->reveal(), FALSE, vfsStream::url('root'));
  $kernel->setSitePath(vfsStream::url('root/sites/default'));
  $kernel->boot();
}Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.
