protected function ClassLoaderTest::assertFileInclusions in X Autoload 7.4
Same name and namespace in other branches
- 7.5 tests/src/ClassLoaderTest.php \Drupal\xautoload\Tests\ClassLoaderTest::assertFileInclusions()
Assert that inclusions are done in the expected order.
Parameters
\Drupal\xautoload\ClassLoader\ClassLoaderInterface $loader:
string $class:
string[] $expectedCandidates:
1 call to ClassLoaderTest::assertFileInclusions()
- ClassLoaderTest::assertCandidateOrder in tests/
lib/ ClassLoaderTest.php
File
- tests/
lib/ ClassLoaderTest.php, line 146
Class
Namespace
Drupal\xautoload\TestsCode
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().");
}