public function LibrariesWebTest::testLibrariesInfo in Libraries API 8.3
Tests libraries_info().
File
- src/
Tests/ LibrariesWebTest.php, line 156
Class
- LibrariesWebTest
- Tests basic detection and loading of libraries.
Namespace
Drupal\libraries\TestsCode
public function testLibrariesInfo() {
// Test that library information is found correctly.
$expected = [
'name' => 'Example files',
'library path' => drupal_get_path('module', 'libraries') . '/tests/example',
'version' => '1',
'files' => [
'js' => [
'example_1.js' => [],
],
'css' => [
'example_1.css' => [],
],
'php' => [
'example_1.php' => [],
],
],
'module' => 'libraries_test',
];
libraries_info_defaults($expected, 'example_files');
$library = libraries_info('example_files');
$this
->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
$this
->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
$this
->assertEqual($library, $expected, 'Library information is correctly gathered.');
// Test a library specified with an .info file gets detected.
$expected = [
'name' => 'Example info file',
'info file' => drupal_get_path('module', 'libraries') . '/tests/example/example_info_file.libraries.info.yml',
];
libraries_info_defaults($expected, 'example_info_file');
$library = libraries_info('example_info_file');
// If this module was downloaded from Drupal.org, the Drupal.org packaging
// system has corrupted the test info file.
// @see http://drupal.org/node/1606606
unset($library['core'], $library['datestamp'], $library['project'], $library['version']);
$this
->verbose('Expected:<pre>' . var_export($expected, TRUE) . '</pre>');
$this
->verbose('Actual:<pre>' . var_export($library, TRUE) . '</pre>');
$this
->assertEqual($library, $expected, 'Library specified with an .info file found');
}