/** * 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()."); }