class ExtensionsTest in Autoload 7.2
Same name and namespace in other branches
- 7 src/Tests/Unit/ExtensionsTest.php \Drupal\autoload\Tests\Unit\ExtensionsTest
Class ExtensionsTest.
Hierarchy
- class \Drupal\autoload\Tests\Unit\AutoloadTestBase extends \Drupal\autoload\Tests\Unit\DrupalWebTestCase
- class \Drupal\autoload\Tests\Unit\ExtensionsTest
Expanded class hierarchy of ExtensionsTest
File
- src/
Tests/ Unit/ ExtensionsTest.php, line 8
Namespace
Drupal\autoload\Tests\UnitView source
class ExtensionsTest extends AutoloadTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = array(
'autoload_test_extensions',
);
/**
* {@inheritdoc}
*/
public static function getInfo() {
return static::info(t('Ensure registered file extensions are available for autoloading.'));
}
/**
* {@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',
));
// Class must not exist since an extension was registered not by Drupal.
$this
->assertFalse(class_exists('Drupal\\autoload_test_extensions\\PSR4'), 'A class cannot be loaded despite on registered file extension.');
}
/**
* Assert registered extensions for autoloading.
*
* @param string[] $extensions
* Extensions list. Each one must start from dot.
*/
protected function assertExtensions(array $extensions) {
$this
->assertFalse(array_diff(autoload_extensions(), $extensions), 'Required extensions available.');
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
AutoloadTestBase:: |
protected | property | A path to file with the autoloading class map. | |
AutoloadTestBase:: |
protected | property | ||
AutoloadTestBase:: |
protected static | function | Returns an information about the test. | |
AutoloadTestBase:: |
protected | function | ||
AutoloadTestBase:: |
protected | function | ||
ExtensionsTest:: |
protected static | property |
Modules which should enabled for testing. Overrides AutoloadTestBase:: |
|
ExtensionsTest:: |
protected | function | Assert registered extensions for autoloading. | |
ExtensionsTest:: |
public static | function | ||
ExtensionsTest:: |
public | function |