You are here

public function SwaggerUiLibraryDiscoveryTest::testWithMissingVersionInPackageJson in Swagger UI Field Formatter 8.3

Tests with missing version in package.json.

File

tests/src/Unit/SwaggerUiLibraryDiscoveryTest.php, line 218

Class

SwaggerUiLibraryDiscoveryTest
Tests the Swagger UI library discovery service.

Namespace

Drupal\Tests\swagger_ui_formatter\Unit

Code

public function testWithMissingVersionInPackageJson() : void {
  $this
    ->setUpLibraryVersionTest();

  // Imitate that the "version" attribute is not found in package.json with
  // a specific library directory.
  $this->cache
    ->method('get')
    ->willReturn((object) [
    'data' => SWAGGER_UI_FORMATTER_TEST_VERSION_NOT_FOUND_IN_PACKAGE_JSON_DIR,
  ]);
  $this
    ->expectException(SwaggerUiLibraryDiscoveryException::class);
  $this
    ->expectExceptionCode(SwaggerUiLibraryDiscoveryException::CODE_UNABLE_TO_IDENTIFY_LIBRARY_VERSION);
  $this->swaggerUiLibraryDiscovery
    ->libraryVersion();
}