You are here

ExtensionsTest.php in Autoload 7

Same filename and directory in other branches
  1. 7.2 src/Tests/Unit/ExtensionsTest.php

File

src/Tests/Unit/ExtensionsTest.php
View source
<?php

namespace Drupal\autoload\Tests\Unit;


/**
 * Class ExtensionsTest.
 */
class ExtensionsTest extends AuxiliaryTest {

  /**
   * {@inheritdoc}
   */
  protected static $modules = array(
    'autoload_test_extensions',
  );

  /**
   * {@inheritdoc}
   */
  public static function getInfo() {
    $info = parent::getInfo();
    $info['name'] = 'Extensions';
    $info['description'] = t('Ensure that registered file extensions available for autoloading.');
    return $info;
  }

  /**
   * {@inheritdoc}
   */
  public function test() {

    // These extensions are always available!
    $this
      ->assertExtensions(array(
      '.php',
      '.inc',
    ));

    // Only Drupal can change this. Modules cannot!
    spl_autoload_extensions('.test');

    // List of extensions changed as expected.
    $this
      ->assertExtensions(array(
      '.php',
      '.inc',
      '.test',
    ));

    // But class must not exist since extension was registered not by Drupal.
    $this
      ->assertFalse(class_exists('Drupal\\autoload_test_extensions\\PSR4'));
  }

}

Classes

Namesort descending Description
ExtensionsTest Class ExtensionsTest.