class MediaLinkabilityTest

Same name in other branches
  1. 10 core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaLinkabilityTest.php \Drupal\Tests\ckeditor5\FunctionalJavascript\MediaLinkabilityTest

@coversDefaultClass \Drupal\ckeditor5\Plugin\CKEditor5Plugin\Media @group ckeditor5 @internal

Hierarchy

Expanded class hierarchy of MediaLinkabilityTest

File

core/modules/ckeditor5/tests/src/FunctionalJavascript/MediaLinkabilityTest.php, line 17

Namespace

Drupal\Tests\ckeditor5\FunctionalJavascript
View source
class MediaLinkabilityTest extends MediaTestBase {
    
    /**
     * Ensures arbitrary attributes can be added on links wrapping media via GHS.
     *
     * @dataProvider providerLinkability
     */
    public function testLinkedMediaArbitraryHtml(bool $unrestricted) : void {
        $assert_session = $this->assertSession();
        $editor = Editor::load('test_format');
        $settings = $editor->getSettings();
        $filter_format = $editor->getFilterFormat();
        if ($unrestricted) {
            $filter_format->setFilterConfig('filter_html', [
                'status' => FALSE,
            ]);
        }
        else {
            // Allow the data-foo attribute in <a> via GHS. Also, add support for div's
            // with data-foo attribute to ensure that linked drupal-media elements can
            // be wrapped with <div>.
            $settings['plugins']['ckeditor5_sourceEditing']['allowed_tags'] = [
                '<a data-foo>',
                '<div data-bar>',
            ];
            $editor->setSettings($settings);
            $filter_format->setFilterConfig('filter_html', [
                'status' => TRUE,
                'settings' => [
                    'allowed_html' => '<p> <br> <strong> <em> <a href data-foo> <drupal-media data-entity-type data-entity-uuid data-align data-caption alt data-view-mode> <div data-bar>',
                ],
            ]);
        }
        $editor->save();
        $filter_format->save();
        $this->assertSame([], array_map(function (ConstraintViolationInterface $v) {
            return (string) $v->getMessage();
        }, iterator_to_array(CKEditor5::validatePair(Editor::load('test_format'), FilterFormat::load('test_format')))));
        // Wrap the existing drupal-media tag with a div and an a that include
        // attributes allowed via GHS.
        $original_value = $this->host->body->value;
        $this->host->body->value = '<div data-bar="baz"><a href="https://example.com" data-foo="bar">' . $original_value . '</a></div>';
        $this->host
            ->save();
        $this->drupalGet($this->host
            ->toUrl('edit-form'));
        // Confirm data-foo is present in the editing view.
        $this->assertNotEmpty($link = $assert_session->waitForElementVisible('css', 'a[href="https://example.com"]'));
        $this->assertEquals('bar', $link->getAttribute('data-foo'));
        // Confirm that the media is wrapped by the div on the editing view.
        $assert_session->elementExists('css', 'div[data-bar="baz"] > .drupal-media > a[href="https://example.com"] > div[data-drupal-media-preview]');
        // Confirm that drupal-media is wrapped by the div and a, and that GHS has
        // retained arbitrary HTML allowed by source editing.
        $editor_dom = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertNotEmpty($editor_dom->query('//div[@data-bar="baz"]/a[@data-foo="bar"]/drupal-media'));
    }
    
    /**
     * Tests linkability of the media CKEditor widget.
     *
     * Due to the very different HTML markup generated for the editing view and
     * the data view, this is explicitly testing the "editingDowncast" and
     * "dataDowncast" results. These are CKEditor 5 concepts.
     *
     * @see https://ckeditor.com/docs/ckeditor5/latest/framework/guides/architecture/editing-engine.html#conversion
     *
     * @dataProvider providerLinkability
     */
    public function testLinkability(bool $unrestricted) : void {
        // Disable filter_html.
        if ($unrestricted) {
            FilterFormat::load('test_format')->setFilterConfig('filter_html', [
                'status' => FALSE,
            ])
                ->save();
        }
        $page = $this->getSession()
            ->getPage();
        $this->drupalGet($this->host
            ->toUrl('edit-form'));
        $this->waitForEditor();
        $assert_session = $this->assertSession();
        // Initial state: the Drupal Media CKEditor Widget is not selected.
        $drupalmedia = $assert_session->waitForElementVisible('css', '.ck-content .ck-widget.drupal-media');
        $this->assertNotEmpty($drupalmedia);
        $this->assertFalse($drupalmedia->hasClass('.ck-widget_selected'));
        // Assert the "editingDowncast" HTML before making changes.
        $assert_session->elementExists('css', '.ck-content .ck-widget.drupal-media > [data-drupal-media-preview]');
        // Assert the "dataDowncast" HTML before making changes.
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertNotEmpty($xpath->query('//drupal-media'));
        $this->assertEmpty($xpath->query('//a'));
        // Assert the link button is present and not pressed.
        $link_button = $this->getEditorButton('Link');
        $this->assertSame('false', $link_button->getAttribute('aria-pressed'));
        // Wait for the preview to load.
        $preview = $assert_session->waitForElement('css', '.ck-content .ck-widget.drupal-media [data-drupal-media-preview="ready"]');
        $this->assertNotEmpty($preview);
        // Tests linking Drupal media.
        $drupalmedia->click();
        $this->assertTrue($drupalmedia->hasClass('ck-widget_selected'));
        $this->assertEditorButtonEnabled('Link');
        // Assert structure of image toolbar balloon.
        $this->assertVisibleBalloon('.ck-toolbar[aria-label="Drupal Media toolbar"]');
        $link_media_button = $this->getBalloonButton('Link media');
        // Click the "Link media" button.
        $this->assertSame('false', $link_media_button->getAttribute('aria-pressed'));
        $link_media_button->press();
        // Assert structure of link form balloon.
        $balloon = $this->assertVisibleBalloon('.ck-link-form');
        $url_input = $balloon->find('css', '.ck-labeled-field-view__input-wrapper .ck-input-text');
        // Fill in link form balloon's <input> and hit "Save".
        $url_input->setValue('http://linking-embedded-media.com');
        $balloon->pressButton('Save');
        // Assert the "editingDowncast" HTML after making changes. Assert the link
        // exists, then assert the link exists. Then assert the expected DOM
        // structure in detail.
        $assert_session->elementExists('css', '.ck-content a[href="http://linking-embedded-media.com"]');
        $assert_session->elementExists('css', '.ck-content .drupal-media.ck-widget > a[href="http://linking-embedded-media.com"] > div[aria-label] > article > div > img[src*="image-test.png"]');
        // Assert the "dataDowncast" HTML after making changes.
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertNotEmpty($xpath->query('//drupal-media'));
        $this->assertNotEmpty($xpath->query('//a[@href="http://linking-embedded-media.com"]'));
        $this->assertNotEmpty($xpath->query('//a[@href="http://linking-embedded-media.com"]/drupal-media'));
        // Ensure that the media caption is retained and not linked as a result of
        // linking media.
        $this->assertNotEmpty($xpath->query('//a[@href="http://linking-embedded-media.com"]/drupal-media[@data-caption="baz"]'));
        // Add `class="trusted"` to the link.
        $this->assertEmpty($xpath->query('//a[@href="http://linking-embedded-media.com" and @class="trusted"]'));
        $this->pressEditorButton('Source');
        $source_text_area = $assert_session->waitForElement('css', '.ck-source-editing-area textarea');
        $this->assertNotEmpty($source_text_area);
        $new_value = str_replace('<a ', '<a class="trusted" ', $source_text_area->getValue());
        $source_text_area->setValue('<p>temp</p>');
        $source_text_area->setValue($new_value);
        $this->pressEditorButton('Source');
        // When unrestricted, additional attributes on links should be retained.
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertCount($unrestricted ? 1 : 0, $xpath->query('//a[@href="http://linking-embedded-media.com" and @class="trusted"]'));
        // Save the entity whose text field is being edited.
        $page->pressButton('Save');
        // Assert the HTML the end user sees.
        $assert_session->elementExists('css', $unrestricted ? 'a[href="http://linking-embedded-media.com"].trusted img[src*="image-test.png"]' : 'a[href="http://linking-embedded-media.com"] img[src*="image-test.png"]');
        // Go back to edit the now *linked* <drupal-media>. Everything from this
        // point onwards is effectively testing "upcasting" and proving there is no
        // data loss.
        $this->drupalGet($this->host
            ->toUrl('edit-form'));
        $this->waitForEditor();
        // Assert the "dataDowncast" HTML before making changes.
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertNotEmpty($xpath->query('//drupal-media'));
        $this->assertNotEmpty($xpath->query('//a[@href="http://linking-embedded-media.com"]'));
        $this->assertNotEmpty($xpath->query('//a[@href="http://linking-embedded-media.com"]/drupal-media'));
        // Tests unlinking media.
        $drupalmedia->click();
        $this->assertEditorButtonEnabled('Link');
        $this->assertSame('true', $this->getEditorButton('Link')
            ->getAttribute('aria-pressed'));
        // Assert structure of Drupal media toolbar balloon.
        $this->assertVisibleBalloon('.ck-toolbar[aria-label="Drupal Media toolbar"]');
        $link_media_button = $this->getBalloonButton('Link media');
        $this->assertSame('true', $link_media_button->getAttribute('aria-pressed'));
        $link_media_button->click();
        // Assert structure of link actions balloon.
        $this->getBalloonButton('Edit link');
        $unlink_image_button = $this->getBalloonButton('Unlink');
        // Click the "Unlink" button.
        $unlink_image_button->click();
        $this->assertSame('false', $this->getEditorButton('Link')
            ->getAttribute('aria-pressed'));
        // Assert the "editingDowncast" HTML after making changes. Assert the link
        // exists, then assert no link exists. Then assert the expected DOM
        // structure in detail.
        $assert_session->elementNotExists('css', '.ck-content a');
        $assert_session->elementExists('css', '.ck-content .drupal-media.ck-widget > div[aria-label] > article > div > img[src*="image-test.png"]');
        // Ensure that figcaption exists.
        // @see https://www.drupal.org/project/drupal/issues/3268318
        $assert_session->elementExists('css', '.ck-content .drupal-media.ck-widget > figcaption');
        // Assert the "dataDowncast" HTML after making changes.
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertNotEmpty($xpath->query('//drupal-media'));
        $this->assertEmpty($xpath->query('//a'));
    }
    public static function providerLinkability() : array {
        return [
            'restricted' => [
                FALSE,
            ],
            'unrestricted' => [
                TRUE,
            ],
        ];
    }
    
    /**
     * Ensure that manual link decorators work with linkable media.
     *
     * @dataProvider providerLinkability
     */
    public function testLinkManualDecorator(bool $unrestricted) : void {
        \Drupal::service('module_installer')->install([
            'ckeditor5_manual_decorator_test',
        ]);
        $this->resetAll();
        $decorator = 'Open in a new tab';
        $decorator_attributes = '[@target="_blank"][@rel="noopener noreferrer"][@class="link-new-tab"]';
        // Disable filter_html.
        if ($unrestricted) {
            FilterFormat::load('test_format')->setFilterConfig('filter_html', [
                'status' => FALSE,
            ])
                ->save();
            $decorator = 'Pink color';
            $decorator_attributes = '[@style="color:pink;"]';
        }
        $this->drupalGet($this->host
            ->toUrl('edit-form'));
        $this->waitForEditor();
        $assert_session = $this->assertSession();
        $page = $this->getSession()
            ->getPage();
        $this->assertNotEmpty($drupalmedia = $assert_session->waitForElementVisible('css', '.ck-content .ck-widget.drupal-media'));
        $drupalmedia->click();
        $this->assertVisibleBalloon('.ck-toolbar[aria-label="Drupal Media toolbar"]');
        // Turn off caption, so we don't accidentally put our link in that text
        // field instead of on the actual media.
        $this->getBalloonButton('Toggle caption off')
            ->click();
        $assert_session->assertNoElementAfterWait('css', 'figure.drupal-media > figcaption');
        $this->assertVisibleBalloon('.ck-toolbar[aria-label="Drupal Media toolbar"]');
        $this->getBalloonButton('Link media')
            ->click();
        $balloon = $this->assertVisibleBalloon('.ck-link-form');
        $url_input = $balloon->find('css', '.ck-labeled-field-view__input-wrapper .ck-input-text');
        $url_input->setValue('http://linking-embedded-media.com');
        $this->getBalloonButton($decorator)
            ->click();
        $balloon->pressButton('Save');
        $this->assertNotEmpty($assert_session->waitForElementVisible('css', '.drupal-media a'));
        $this->assertVisibleBalloon('.ck-link-actions');
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertNotEmpty($xpath->query("//a[@href='http://linking-embedded-media.com']{$decorator_attributes}"));
        $this->assertNotEmpty($xpath->query("//a[@href='http://linking-embedded-media.com']{$decorator_attributes}/drupal-media"));
        // Ensure that manual decorators upcast correctly.
        $page->pressButton('Save');
        $this->drupalGet($this->host
            ->toUrl('edit-form'));
        $this->assertNotEmpty($drupalmedia = $assert_session->waitForElementVisible('css', '.ck-content .ck-widget.drupal-media'));
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertNotEmpty($xpath->query("//a[@href='http://linking-embedded-media.com']{$decorator_attributes}"));
        $this->assertNotEmpty($xpath->query("//a[@href='http://linking-embedded-media.com']{$decorator_attributes}/drupal-media"));
        // Finally, ensure that media can be unlinked.
        $drupalmedia->click();
        $this->assertVisibleBalloon('.ck-toolbar[aria-label="Drupal Media toolbar"]');
        $this->getBalloonButton('Link media')
            ->click();
        $this->assertVisibleBalloon('.ck-link-actions');
        $this->getBalloonButton('Unlink')
            ->click();
        $this->assertTrue($assert_session->waitForElementRemoved('css', '.drupal-media a'));
        $xpath = new \DOMXPath($this->getEditorDataAsDom());
        $this->assertEmpty($xpath->query('//a'));
        $this->assertNotEmpty($xpath->query('//drupal-media'));
    }

}

Members

Title Sort descending Modifiers Object type Summary Member alias Overriden Title Overrides
BlockCreationTrait::placeBlock protected function Creates a block instance based on default settings. Aliased as: drupalPlaceBlock
BrowserHtmlDebugTrait::$htmlOutputBaseUrl protected property The Base URI to use for links to the output files.
BrowserHtmlDebugTrait::$htmlOutputClassName protected property Class name for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputCounter protected property Counter for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputCounterStorage protected property Counter storage for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputDirectory protected property Directory name for HTML output logging.
BrowserHtmlDebugTrait::$htmlOutputEnabled protected property HTML output enabled.
BrowserHtmlDebugTrait::$htmlOutputTestId protected property HTML output test ID.
BrowserHtmlDebugTrait::formatHtmlOutputHeaders protected function Formats HTTP headers as string for HTML output logging.
BrowserHtmlDebugTrait::getResponseLogHandler protected function Provides a Guzzle middleware handler to log every response received.
BrowserHtmlDebugTrait::htmlOutput protected function Logs a HTML output message in a text file.
BrowserHtmlDebugTrait::initBrowserOutputFile protected function Creates the directory to store browser output.
BrowserTestBase::$baseUrl protected property The base URL.
BrowserTestBase::$configImporter protected property The config importer that can be used in a test.
BrowserTestBase::$customTranslations protected property An array of custom translations suitable for SettingsEditor::rewrite().
BrowserTestBase::$mink protected property Mink session manager.
BrowserTestBase::$minkDefaultDriverArgs protected property Mink default driver params.
BrowserTestBase::$originalContainer protected property The original container.
BrowserTestBase::$originalShutdownCallbacks protected property The original array of shutdown function callbacks.
BrowserTestBase::$profile protected property The profile to install as a basis for testing. 41
BrowserTestBase::$timeLimit protected property Time limit in seconds for the test.
BrowserTestBase::$translationFilesDirectory protected property The translation file directory for the test environment.
BrowserTestBase::cleanupEnvironment protected function Clean up the test environment.
BrowserTestBase::config protected function Configuration accessor for tests. Returns non-overridden configuration.
BrowserTestBase::filePreDeleteCallback public static function Ensures test files are deletable.
BrowserTestBase::getDefaultDriverInstance protected function Gets an instance of the default Mink driver.
BrowserTestBase::getHttpClient protected function Obtain the HTTP client for the system under test.
BrowserTestBase::getOptions protected function Helper function to get the options of select field.
BrowserTestBase::getSession public function Returns Mink session.
BrowserTestBase::getSessionCookies protected function Get session cookies from current session.
BrowserTestBase::getTestMethodCaller protected function Retrieves the current calling line in the class under test. Overrides BrowserHtmlDebugTrait::getTestMethodCaller
BrowserTestBase::installDrupal public function Installs Drupal into the test site. 2
BrowserTestBase::registerSessions protected function Registers additional Mink sessions.
BrowserTestBase::setUpAppRoot protected function Sets up the root application path.
BrowserTestBase::setUpBeforeClass public static function 1
BrowserTestBase::translatePostValues protected function Transforms a nested array into a flat array suitable for submitForm().
BrowserTestBase::xpath protected function Performs an xpath search on the contents of the internal browser.
BrowserTestBase::__construct public function 1
BrowserTestBase::__sleep public function Prevents serializing any properties.
CKEditor5TestTrait::assertEditorButtonDisabled protected function Asserts a CKEditor button is disabled.
CKEditor5TestTrait::assertEditorButtonEnabled protected function Asserts a CKEditor button is enabled.
CKEditor5TestTrait::assertVisibleBalloon protected function Asserts a particular balloon is visible.
CKEditor5TestTrait::getBalloonButton protected function Gets a button from the currently visible balloon.
CKEditor5TestTrait::getEditorButton protected function Waits for a CKEditor button and returns it when available and visible.
CKEditor5TestTrait::getEditorDataAsDom protected function Gets CKEditor 5 instance data as a PHP DOMDocument.
CKEditor5TestTrait::getEditorDataAsHtmlString protected function Gets CKEditor 5 instance data as a HTML string.
CKEditor5TestTrait::pressEditorButton protected function Clicks a CKEditor button.
CKEditor5TestTrait::selectTextInsideElement protected function Selects text inside an element.
CKEditor5TestTrait::waitForEditor protected function Waits for CKEditor to initialize.
ConfigTestTrait::configImporter protected function Returns a ConfigImporter object to import test configuration.
ConfigTestTrait::copyConfig protected function Copies configuration objects from source storage to target storage.
ContentTypeCreationTrait::createContentType protected function Creates a custom content type based on default settings. Aliased as: drupalCreateContentType 1
ExpectDeprecationTrait::expectDeprecation public function Adds an expected deprecation.
ExpectDeprecationTrait::getCallableName private static function Returns a callable as a string suitable for inclusion in a message.
ExpectDeprecationTrait::setUpErrorHandler public function Sets up the test error handler.
ExpectDeprecationTrait::tearDownErrorHandler public function Tears down the test error handler.
ExtensionListTestTrait::getModulePath protected function Gets the path for the specified module.
ExtensionListTestTrait::getThemePath protected function Gets the path for the specified theme.
FunctionalTestSetupTrait::$apcuEnsureUniquePrefix protected property The flag to set &#039;apcu_ensure_unique_prefix&#039; setting. 1
FunctionalTestSetupTrait::$classLoader protected property The class loader to use for installation and initialization of setup.
FunctionalTestSetupTrait::$rootUser protected property The &quot;#1&quot; admin user.
FunctionalTestSetupTrait::$usesSuperUserAccessPolicy protected property Set to TRUE to make user 1 a super user. 8
FunctionalTestSetupTrait::doInstall protected function Execute the non-interactive installer. 1
FunctionalTestSetupTrait::getDatabaseTypes protected function Returns all supported database driver installer objects.
FunctionalTestSetupTrait::initConfig protected function Initialize various configurations post-installation. 1
FunctionalTestSetupTrait::initKernel protected function Initializes the kernel after installation.
FunctionalTestSetupTrait::initSettings protected function Initialize settings created during install.
FunctionalTestSetupTrait::initUserSession protected function Initializes user 1 for the site to be installed.
FunctionalTestSetupTrait::installDefaultThemeFromClassProperty protected function Installs the default theme defined by `static::$defaultTheme` when needed. 1
FunctionalTestSetupTrait::installParameters protected function Returns the parameters that will be used when the test installs Drupal. 8
FunctionalTestSetupTrait::prepareEnvironment protected function Prepares the current environment for running the test. 29
FunctionalTestSetupTrait::prepareRequestForGenerator protected function Creates a mock request and sets it on the generator.
FunctionalTestSetupTrait::prepareSettings protected function Prepares site settings and services before installation. 4
FunctionalTestSetupTrait::rebuildAll protected function Resets and rebuilds the environment after setup.
FunctionalTestSetupTrait::rebuildContainer protected function Rebuilds \Drupal::getContainer().
FunctionalTestSetupTrait::resetAll protected function Resets all data structures after having enabled new modules.
FunctionalTestSetupTrait::setContainerParameter protected function Changes parameters in the services.yml file.
FunctionalTestSetupTrait::setupBaseUrl protected function Sets up the base URL based upon the environment variable.
FunctionalTestSetupTrait::writeSettings protected function Rewrites the settings.php file of the test site. 1
MediaLinkabilityTest::providerLinkability public static function
MediaLinkabilityTest::testLinkability public function Tests linkability of the media CKEditor widget.
MediaLinkabilityTest::testLinkedMediaArbitraryHtml public function Ensures arbitrary attributes can be added on links wrapping media via GHS.
MediaLinkabilityTest::testLinkManualDecorator public function Ensure that manual link decorators work with linkable media.
MediaTestBase::$adminUser protected property The user to use during testing.
MediaTestBase::$defaultTheme protected property The theme to install as the default for testing. Overrides BrowserTestBase::$defaultTheme
MediaTestBase::$host protected property A host entity with a body field to embed media in.
MediaTestBase::$media protected property The sample Media entity to embed.
MediaTestBase::$mediaFile protected property The second sample Media entity to embed used in one of the tests.
MediaTestBase::$modules protected static property Modules to install. Overrides BrowserTestBase::$modules
MediaTestBase::assertSourceAttributeSame protected function Verifies value of an attribute on the downcast &lt;drupal-media&gt; element.
MediaTestBase::getLastPreviewRequestTransferSize protected function Gets the transfer size of the last preview request.
MediaTestBase::setUp protected function Overrides BrowserTestBase::setUp
MediaTypeCreationTrait::createMediaType protected function Create a media type for a source plugin.
NodeCreationTrait::createNode protected function Creates a node based on default settings. Aliased as: drupalCreateNode
NodeCreationTrait::getNodeByTitle public function Get a node from the database based on its title. Aliased as: drupalGetNodeByTitle
RandomGeneratorTrait::getRandomGenerator protected function Gets the random generator for the utility methods.
RandomGeneratorTrait::randomMachineName protected function Generates a unique random string containing letters and numbers.
RandomGeneratorTrait::randomObject public function Generates a random PHP object.
RandomGeneratorTrait::randomString public function Generates a pseudo-random string of ASCII characters of codes 32 to 126.
RefreshVariablesTrait::refreshVariables protected function Refreshes in-memory configuration and state information. 2
SessionTestTrait::$sessionName protected property The name of the session cookie.
SessionTestTrait::generateSessionName protected function Generates a session cookie name.
SessionTestTrait::getSessionName protected function Returns the session name in use on the child site.
StorageCopyTrait::replaceStorageContents protected static function Copy the configuration from one storage to another and remove stale items.
TestFileCreationTrait::$generatedTestFiles protected property Whether the files were copied to the test files directory.
TestFileCreationTrait::compareFiles protected function Compares two files based on size and file name.
TestFileCreationTrait::generateFile protected static function Generates a test file.
TestFileCreationTrait::getTestFiles protected function Gets a list of files that can be used in tests.
TestRequirementsTrait::getDrupalRoot protected static function Returns the Drupal root directory.
TestSetupTrait::$configSchemaCheckerExclusions protected static property An array of config object names that are excluded from schema checking. 3
TestSetupTrait::$container protected property The dependency injection container used in the test.
TestSetupTrait::$databasePrefix protected property The database prefix of this test run.
TestSetupTrait::$kernel protected property The DrupalKernel instance used in the test.
TestSetupTrait::$originalSite protected property The site directory of the original parent site.
TestSetupTrait::$privateFilesDirectory protected property The private file directory for the test environment.
TestSetupTrait::$publicFilesDirectory protected property The public file directory for the test environment.
TestSetupTrait::$root protected property The app root.
TestSetupTrait::$siteDirectory protected property The site directory of this test run.
TestSetupTrait::$strictConfigSchema protected property Set to TRUE to strict check all configuration saved. 5
TestSetupTrait::$tempFilesDirectory protected property The temporary file directory for the test environment.
TestSetupTrait::$testId protected property The test run ID.
TestSetupTrait::changeDatabasePrefix protected function Changes the database connection to the prefixed one.
TestSetupTrait::getConfigSchemaExclusions protected function Gets the config schema exclusions for this test.
TestSetupTrait::prepareDatabasePrefix protected function Generates a database prefix for running tests. 1
UiHelperTrait::$loggedInUser protected property The current user logged in using the Mink controlled browser.
UiHelperTrait::$maximumMetaRefreshCount protected property The number of meta refresh redirects to follow, or NULL if unlimited.
UiHelperTrait::$metaRefreshCount protected property The number of meta refresh redirects followed during ::drupalGet().
UiHelperTrait::$useOneTimeLoginLinks protected property Use one-time login links instead of submitting the login form. 3
UiHelperTrait::buildUrl protected function Builds an absolute URL from a system path or a URL object.
UiHelperTrait::checkForMetaRefresh protected function Checks for meta refresh tag and if found call drupalGet() recursively.
UiHelperTrait::click protected function Clicks the element with the given CSS selector.
UiHelperTrait::clickLink protected function Follows a link by complete name.
UiHelperTrait::cssSelect protected function Searches elements using a CSS selector in the raw content.
UiHelperTrait::cssSelectToXpath protected function Translates a CSS expression to its XPath equivalent.
UiHelperTrait::drupalGet protected function Retrieves a Drupal path or an absolute path. 3
UiHelperTrait::drupalLogin protected function Logs in a user using the Mink controlled browser.
UiHelperTrait::drupalLogout protected function Logs a user out of the Mink controlled browser and confirms.
UiHelperTrait::drupalResetSession protected function Resets the current active session back to Anonymous session.
UiHelperTrait::drupalUserIsLoggedIn protected function Returns whether a given user account is logged in.
UiHelperTrait::getAbsoluteUrl protected function Takes a path and returns an absolute path.
UiHelperTrait::getTextContent protected function Retrieves the plain-text content from the current page.
UiHelperTrait::getUrl protected function Get the current URL from the browser.
UiHelperTrait::isTestUsingGuzzleClient protected function Determines if test is using DrupalTestBrowser.
UiHelperTrait::prepareRequest protected function Prepare for a request to testing site. 1
UiHelperTrait::submitForm protected function Fills and submits a form.
UserCreationTrait::checkPermissions protected function Checks whether a given list of permission names is valid.
UserCreationTrait::createAdminRole protected function Creates an administrative role.
UserCreationTrait::createRole protected function Creates a role with specified permissions. Aliased as: drupalCreateRole
UserCreationTrait::createUser protected function Create a user with a given set of permissions. Aliased as: drupalCreateUser
UserCreationTrait::grantPermissions protected function Grant permissions to a user role.
UserCreationTrait::setCurrentUser protected function Switch the current logged in user.
UserCreationTrait::setUpCurrentUser protected function Creates a random user account and sets it as current user.
WebDriverTestBase::$disableCssAnimations protected property Disables CSS animations in tests for more reliable testing.
WebDriverTestBase::$failOnJavascriptConsoleErrors protected property Determines if a test should fail on JavaScript console errors. 2
WebDriverTestBase::$minkDefaultDriverClass protected property Mink class for the default driver to use. Overrides BrowserTestBase::$minkDefaultDriverClass
WebDriverTestBase::assertJsCondition protected function Waits for the given time or until the given JS condition becomes TRUE.
WebDriverTestBase::assertSession public function Returns WebAssert object. Overrides UiHelperTrait::assertSession
WebDriverTestBase::createScreenshot protected function Creates a screenshot.
WebDriverTestBase::failOnJavaScriptErrors protected function Triggers a test failure if a JavaScript error was encountered.
WebDriverTestBase::getDrupalSettings protected function Gets the current Drupal javascript settings and parses into an array. Overrides BrowserTestBase::getDrupalSettings
WebDriverTestBase::getHtmlOutputHeaders protected function Returns headers in HTML output format. Overrides BrowserHtmlDebugTrait::getHtmlOutputHeaders
WebDriverTestBase::getMinkDriverArgs protected function Gets the Mink driver args from an environment variable. Overrides BrowserTestBase::getMinkDriverArgs 1
WebDriverTestBase::initFrontPage protected function Visits the front page when initializing Mink. Overrides BrowserTestBase::initFrontPage
WebDriverTestBase::initMink protected function Initializes Mink sessions. Overrides BrowserTestBase::initMink
WebDriverTestBase::installModulesFromClassProperty protected function Install modules defined by `static::$modules`. Overrides FunctionalTestSetupTrait::installModulesFromClassProperty 1
WebDriverTestBase::tearDown protected function Overrides BrowserTestBase::tearDown 1
XdebugRequestTrait::extractCookiesFromRequest protected function Adds xdebug cookies, from request setup.

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.