You are here

function DrupalBootTest::testNormalRequest in X Autoload 7.4

Tests a simulated regular request.

File

tests/lib/DrupalBootTest.php, line 31

Class

DrupalBootTest

Namespace

Drupal\xautoload\Tests

Code

function testNormalRequest() {

  // Create virtual class files.
  $this->filesystem
    ->addClass('test://modules/testmod_psr0/lib/Drupal/testmod_psr0/Foo.php', 'Drupal\\testmod_psr0\\Foo');
  $this->filesystem
    ->addClass('test://modules/testmod_psr4/lib/Foo.php', 'Drupal\\testmod_psr4\\Foo');
  $this->filesystem
    ->addClass('test://modules/testmod_pearflat/lib/Foo.php', 'testmod_pearflat_Foo');
  $this
    ->assertTrue(file_exists('test://modules/testmod_psr0/lib/Drupal/testmod_psr0/Foo.php'), 'Stream wrapper file exists.');
  $services = xautoload()
    ->getServiceContainer();

  // Mock out DrupalSystem in the service container.
  $extensions = $this
    ->getExampleExtensions();
  $system = new MockDrupalSystem(array(), $extensions);
  $services
    ->set('system', $system);

  // Simulate _xautoload_register_drupal().
  // No cache is active.
  // Initialize the finder, to fire scheduled operations.
  $services->proxyFinder
    ->getFinder();

  // Register prefixes and namespaces for enabled extensions.
  $operation = new FinderOperation\BootPhase($extensions);
  $services->proxyFinder
    ->onFinderInit($operation);

  // Simulate inclusion of other module files.
  // The testmod_psr4.module must contain an equivalent to the following line,
  // to tell xautoload that PSR-4 is in action:
  $services->main
    ->registerModulePsr4('test://modules/testmod_psr4/testmod_psr4.module', 'lib');

  // Boot modules use their classes.
  $this
    ->assertLoadClass('Drupal\\testmod_psr0\\Foo');
  $this
    ->assertLoadClass('Drupal\\testmod_psr4\\Foo');
  $this
    ->assertLoadClass('testmod_pearflat_Foo');
}