You are here

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

Tests with unsupported package.json.

File

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

Class

SwaggerUiLibraryDiscoveryTest
Tests the Swagger UI library discovery service.

Namespace

Drupal\Tests\swagger_ui_formatter\Unit

Code

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

  // Imitate that the Swagger UI library "version" from package.json is not
  // supported.
  $this->cache
    ->method('get')
    ->willReturn((object) [
    'data' => SWAGGER_UI_FORMATTER_TEST_VERSION_IS_NOT_SUPPORTED_IN_PACKAGE_JSON_DIR,
  ]);
  $this
    ->expectException(SwaggerUiLibraryDiscoveryException::class);
  $this
    ->expectExceptionCode(SwaggerUiLibraryDiscoveryException::CODE_LIBRARY_VERSION_IS_NOT_SUPPORTED);
  $this->swaggerUiLibraryDiscovery
    ->libraryVersion();
}