You are here

protected function ClassLoaderTest::assertFileInclusions in X Autoload 7.5

Same name and namespace in other branches
  1. 7.4 tests/lib/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/src/ClassLoaderTest.php

File

tests/src/ClassLoaderTest.php, line 155

Class

ClassLoaderTest

Namespace

Drupal\xautoload\Tests

Code

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