You are here

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

Tests with invalid library directory.

File

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

Class

SwaggerUiLibraryDiscoveryTest
Tests the Swagger UI library discovery service.

Namespace

Drupal\Tests\swagger_ui_formatter\Unit

Code

public function testWithInvalidLibraryDirectory() : void {
  $this
    ->setUpLibraryDirectoryTest();
  $default_theme = new ActiveTheme([
    'name' => 'bartik',
  ]);
  $this->themeManager
    ->expects($this
    ->once())
    ->method('alterForTheme')
    ->with($default_theme, 'swagger_ui_library_directory', self::DEFAULT_LIBRARY_DIR)
    ->willReturnCallback(static function ($default_theme, $hook, &$library_dir) {
    $library_dir = SWAGGER_UI_FORMATTER_TEST_INVALID_LIBRARY_DIR;
    return NULL;
  });
  $this
    ->expectException(SwaggerUiLibraryDiscoveryException::class);
  $this
    ->expectExceptionCode(SwaggerUiLibraryDiscoveryException::CODE_INVALID_DIR);
  $this->swaggerUiLibraryDiscovery
    ->libraryDirectory();
}