/**
  * Test hook_registry_files_alter() wildcard replacement.
  */
 public function testWildcardClassmap()
 {
     $this->filesystem->addClass('test://lib/xy/z.php', 'Foo\\Bar');
     $this->assertFalse(class_exists('Foo\\Bar', FALSE), 'Class Foo\\Bar must not exist yet.');
     xautoload()->adapter->addClassmapSources(array('test://lib/**/*.php'));
     $this->assertTrue(class_exists('Foo\\Bar'), 'Class Foo\\Bar must exist.');
 }
Ejemplo n.º 2
0
 /**
  * @param string $path
  * @param int $options
  *
  * @return bool
  */
 function dir_opendir($path, $options)
 {
     $contents = self::$filesystem->getDirContents($path);
     if (FALSE === $contents) {
         return FALSE;
     }
     $this->path = $path;
     $this->dirContents = $contents;
     return TRUE;
 }
 /**
  * Assert that inclusions are done in the expected order.
  *
  * @param \Drupal\xautoload\ClassLoader\ClassLoaderInterface $loader
  * @param string $class
  * @param string[] $expectedCandidates
  */
 protected function assertFileInclusions($loader, $class, array $expectedCandidates)
 {
     // Register the class file in the virtual filesystem.
     $this->filesystem->addClass(end($expectedCandidates), $class);
     $this->filesystem->resetReportedOperations();
     // Check that the class is not already defined.
     $this->assertFalse(class_exists($class, FALSE), "Class '{$class}' is not defined before loadClass().");
     // Trigger the class loader.
     $loader->loadClass($class);
     $expectedOperations = array();
     foreach ($expectedCandidates as $file) {
         $expectedOperations[] = $file . ' - stat';
     }
     $expectedOperations[] = end($expectedCandidates) . ' - include';
     $this->assertSame($expectedOperations, $this->filesystem->getReportedOperations());
     // Check that the class is defined after the class loader has done its job.
     $this->assertTrue(class_exists($class, FALSE), "Class is defined after loadClass().");
 }