public function ClassCollectionLoaderTest::testClassWithTraitsReordering

@dataProvider getDifferentOrdersForTraits

File

drupal/core/vendor/symfony/class-loader/Symfony/Component/ClassLoader/Tests/ClassCollectionLoaderTest.php, line 72

Class

ClassCollectionLoaderTest

Namespace

Symfony\Component\ClassLoader\Tests

Code

public function testClassWithTraitsReordering(array $classes) {
  if (version_compare(phpversion(), '5.4.0', '<')) {
    $this
      ->markTestSkipped('Requires PHP > 5.4.0.');
    return;
  }
  require_once __DIR__ . '/Fixtures/ClassesWithParents/ATrait.php';
  require_once __DIR__ . '/Fixtures/ClassesWithParents/BTrait.php';
  require_once __DIR__ . '/Fixtures/ClassesWithParents/CTrait.php';
  require_once __DIR__ . '/Fixtures/ClassesWithParents/D.php';
  require_once __DIR__ . '/Fixtures/ClassesWithParents/E.php';
  $expected = array(
    'ClassesWithParents\\GInterface',
    'ClassesWithParents\\CInterface',
    'ClassesWithParents\\CTrait',
    'ClassesWithParents\\ATrait',
    'ClassesWithParents\\BTrait',
    'ClassesWithParents\\B',
    'ClassesWithParents\\A',
    'ClassesWithParents\\D',
    'ClassesWithParents\\E',
  );
  $r = new \ReflectionClass('Symfony\\Component\\ClassLoader\\ClassCollectionLoader');
  $m = $r
    ->getMethod('getOrderedClasses');
  $m
    ->setAccessible(true);
  $ordered = $m
    ->invoke('Symfony\\Component\\ClassLoader\\ClassCollectionLoader', $classes);
  $this
    ->assertEquals($expected, array_map(function ($class) {
    return $class
      ->getName();
  }, $ordered));
}