abstract class MediaJavascriptTestBase in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php \Drupal\Tests\media\FunctionalJavascript\MediaJavascriptTestBase
- 9 core/modules/media/tests/src/FunctionalJavascript/MediaJavascriptTestBase.php \Drupal\Tests\media\FunctionalJavascript\MediaJavascriptTestBase
Base class for Media functional JavaScript tests.
Hierarchy
- class \Drupal\Tests\BrowserTestBase extends \PHPUnit\Framework\TestCase uses \Drupal\Tests\PhpUnitCompatibilityTrait, \Symfony\Bridge\PhpUnit\ExpectDeprecationTrait, FunctionalTestSetupTrait, TestSetupTrait, BlockCreationTrait, ConfigTestTrait, ExtensionListTestTrait, ContentTypeCreationTrait, NodeCreationTrait, RandomGeneratorTrait, TestRequirementsTrait, PhpUnitWarnings, UiHelperTrait, UserCreationTrait, XdebugRequestTrait
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase
- class \Drupal\Tests\media\FunctionalJavascript\MediaJavascriptTestBase uses MediaFunctionalTestTrait, MediaTypeCreationTrait
- class \Drupal\FunctionalJavascriptTests\WebDriverTestBase
Expanded class hierarchy of MediaJavascriptTestBase
File
- core/
modules/ media/ tests/ src/ FunctionalJavascript/ MediaJavascriptTestBase.php, line 12
Namespace
Drupal\Tests\media\FunctionalJavascriptView source
abstract class MediaJavascriptTestBase extends WebDriverTestBase {
use MediaFunctionalTestTrait;
use MediaTypeCreationTrait;
/**
* Modules to enable.
*
* @var array
*/
protected static $modules = [
'system',
'node',
'field_ui',
'views_ui',
'media',
'media_test_source',
];
/**
* Waits and asserts that a given element is visible.
*
* @param string $selector
* The CSS selector.
* @param int $timeout
* (Optional) Timeout in milliseconds, defaults to 1000.
* @param string $message
* (Optional) Message to pass to assertJsCondition().
*/
protected function waitUntilVisible($selector, $timeout = 1000, $message = '') {
$condition = "jQuery('" . $selector . ":visible').length > 0";
$this
->assertJsCondition($condition, $timeout, $message);
}
/**
* Asserts that a link to a new media item is displayed in the messages area.
*
* @return string
* The link URL.
*/
protected function assertLinkToCreatedMedia() {
$assert_session = $this
->assertSession();
$selector = 'div[aria-label="Status message"] a';
// Get the canonical media entity URL from the creation message.
$link = $assert_session
->elementExists('css', $selector);
$assert_session
->elementAttributeExists('css', $selector, 'href');
return $link
->getAttribute('href');
}
}