private function SwaggerUiFieldFormatterTest::validateSwaggerUiErrorMessage in Swagger UI Field Formatter 8.3
Tests Swagger UI library related field error message.
Parameters
string $filename_prefix: Prefix for created screenshot file, ex.: name of the caller method.
2 calls to SwaggerUiFieldFormatterTest::validateSwaggerUiErrorMessage()
- SwaggerUiFieldFormatterTest::testFileFormatter in tests/
src/ FunctionalJavascript/ SwaggerUiFieldFormatterTest.php - Tests the file field formatter.
- SwaggerUiFieldFormatterTest::testLinkFormatter in tests/
src/ FunctionalJavascript/ SwaggerUiFieldFormatterTest.php - Tests the link field formatter.
File
- tests/
src/ FunctionalJavascript/ SwaggerUiFieldFormatterTest.php, line 116
Class
- SwaggerUiFieldFormatterTest
- Tests file and link field formatters.
Namespace
Drupal\Tests\swagger_ui_formatter\FunctionalJavascriptCode
private function validateSwaggerUiErrorMessage(string $filename_prefix) : void {
$assert = $this
->assertSession();
$swagger_ui_library_error_msg = 'The Swagger UI library is missing, incorrectly defined or not supported.';
/** @var \Drupal\swagger_ui_formatter_test\Service\SwaggerUiLibraryDiscovery $swagger_ui_library_discovery */
$swagger_ui_library_discovery = \Drupal::service('swagger_ui_formatter.swagger_ui_library_discovery');
$swagger_ui_library_discovery
->fakeMissingLibrary(TRUE);
$this
->getSession()
->reload();
$this
->createScreenshot($filename_prefix . '-' . __FUNCTION__ . '-after-fake-missing-library-enabled');
$assert
->pageTextContainsOnce($swagger_ui_library_error_msg);
$swagger_ui_library_discovery
->fakeMissingLibrary(FALSE);
// DrupalWTF, render cache should be invalidated automatically - just like
// it worked when the faking was enabled. Static state again?
// @see \Drupal\swagger_ui_formatter_test\Service\SwaggerUiLibraryDiscovery::flushCaches()
Cache::invalidateTags([
'rendered',
]);
$this
->getSession()
->reload();
$this
->createScreenshot($filename_prefix . '-' . __FUNCTION__ . '-after-fake-missing-library-disabled');
$assert
->pageTextNotContains($swagger_ui_library_error_msg);
$swagger_ui_library_discovery
->fakeUnsupportedLibrary(TRUE);
$this
->getSession()
->reload();
$this
->createScreenshot($filename_prefix . '-' . __FUNCTION__ . '-after-fake-unsupported-library-enabled');
$assert
->pageTextContainsOnce($swagger_ui_library_error_msg);
$swagger_ui_library_discovery
->fakeUnsupportedLibrary(FALSE);
Cache::invalidateTags([
'rendered',
]);
$this
->getSession()
->reload();
$this
->createScreenshot($filename_prefix . '-' . __FUNCTION__ . '-after-fake-unsupported-library-disabled');
$assert
->pageTextNotContains($swagger_ui_library_error_msg);
}