You are here

function ComposerJsonTest::testComposerJson in X Autoload 7.5

File

tests/src/ComposerJsonTest.php, line 13

Class

ComposerJsonTest

Namespace

Drupal\xautoload\Tests

Code

function testComposerJson() {
  $finder = new ClassFinder();
  $masterAdapter = new ClassFinderAdapter($finder, new ClassMapGenerator());
  foreach (array(
    dirname(__DIR__) . '/fixtures/.libraries/ComposerTestLib' => array(
      'ComposerTestLib\\Foo',
      'ComposerTestLib\\Other\\Foo',
    ),
    dirname(__DIR__) . '/fixtures/.libraries/ComposerTargetDirTestLib' => array(
      'Acme\\ComposerTargetDirTestLib\\Foo',
    ),
  ) as $dir => $classes) {
    $localDirectoryAdapter = new LocalDirectoryAdapter($masterAdapter, $dir);
    $localDirectoryAdapter
      ->composerJson('composer.json');
    foreach ($classes as $class) {
      $this
        ->assertFalse(class_exists($class, FALSE), "Class {$class} not defined yet.");
      $finder
        ->loadClass($class);
      $this
        ->assertTrue(class_exists($class, FALSE), "Class {$class} is defined.");
    }
  }
}