public function LibrariesWebTest::_testLibrariesOutput in Libraries API 8.3
Tests that library files are properly added to the page output.
We check for JavaScript and CSS files directly in the DOM and add a list of included PHP files manually to the page output.
@todo Remove or rewrite to accomodate integration with core Libraries.
See also
_libraries_test_load()
File
- src/
Tests/ LibrariesWebTest.php, line 410
Class
- LibrariesWebTest
- Tests basic detection and loading of libraries.
Namespace
Drupal\libraries\TestsCode
public function _testLibrariesOutput() {
// Test loading of a simple library with a top-level files property.
$this
->drupalGet('libraries_test/files');
$this
->assertLibraryFiles('example_1', 'File loading');
// Test loading of integration files.
$this
->drupalGet('libraries_test/integration_files');
$this
->assertRaw('libraries_test.js', 'Integration file loading: libraries_test.js found');
$this
->assertRaw('libraries_test.css', 'Integration file loading: libraries_test.css found');
$this
->assertRaw('libraries_test.inc', 'Integration file loading: libraries_test.inc found');
// Test version overloading.
$this
->drupalGet('libraries_test/versions');
$this
->assertLibraryFiles('example_2', 'Version overloading');
// Test variant loading.
$this
->drupalGet('libraries_test/variant');
$this
->assertLibraryFiles('example_3', 'Variant loading');
// Test version overloading and variant loading.
$this
->drupalGet('libraries_test/versions_and_variants');
$this
->assertLibraryFiles('example_4', 'Concurrent version and variant overloading');
// Test caching.
\Drupal::state()
->set('libraries_test.cache', TRUE);
\Drupal::cache('libraries')
->delete('example_callback');
// When the library information is not cached, all callback groups should be
// invoked.
$this
->drupalGet('libraries_test/cache');
$this
->assertRaw('The <em>info</em> callback group was invoked.', 'Info callback invoked for uncached libraries.');
$this
->assertRaw('The <em>pre-detect</em> callback group was invoked.', 'Pre-detect callback invoked for uncached libraries.');
$this
->assertRaw('The <em>post-detect</em> callback group was invoked.', 'Post-detect callback invoked for uncached libraries.');
$this
->assertRaw('The <em>pre-load</em> callback group was invoked.', 'Pre-load callback invoked for uncached libraries.');
$this
->assertRaw('The <em>post-load</em> callback group was invoked.', 'Post-load callback invoked for uncached libraries.');
// When the library information is cached only the 'pre-load' and
// 'post-load' callback groups should be invoked.
$this
->drupalGet('libraries_test/cache');
$this
->assertNoRaw('The <em>info</em> callback group was not invoked.', 'Info callback not invoked for cached libraries.');
$this
->assertNoRaw('The <em>pre-detect</em> callback group was not invoked.', 'Pre-detect callback not invoked for cached libraries.');
$this
->assertNoRaw('The <em>post-detect</em> callback group was not invoked.', 'Post-detect callback not invoked for cached libraries.');
$this
->assertRaw('The <em>pre-load</em> callback group was invoked.', 'Pre-load callback invoked for cached libraries.');
$this
->assertRaw('The <em>post-load</em> callback group was invoked.', 'Post-load callback invoked for cached libraries.');
\Drupal::state()
->set('libraries_test.cache', FALSE);
}