You are here

public function LibraryTypeKernelTestBase::testLibrary in Libraries API 8.3

Tests that the test library can be instantiated.

File

tests/src/Kernel/LibraryTypeKernelTestBase.php, line 98

Class

LibraryTypeKernelTestBase
Provides an improved version of the core kernel test base class.

Namespace

Drupal\Tests\libraries\Kernel

Code

public function testLibrary() {
  $type_id = $this
    ->getLibraryTypeId();
  $id = $this
    ->getLibraryId();
  try {
    $library = $this->libraryManager
      ->getLibrary($id);
    $this
      ->assertTrue(TRUE, "Test {$type_id} library can be instantiated.");
    $this
      ->assertInstanceOf($this
      ->getLibraryType()
      ->getLibraryClass(), $library);
    $this
      ->assertEquals($this
      ->getLibraryId(), $library
      ->getId());
  } catch (LibraryDefinitionNotFoundException $exception) {
    $this
      ->fail("Missing library definition for test {$type_id} library.");
  } catch (LibraryTypeNotFoundException $exception) {
    $this
      ->fail("Missing library type declaration for test {$type_id} library.");
  }
}