class MediaContextualLinksTest in Drupal 10
Same name and namespace in other branches
- 8 core/modules/media/tests/src/Functional/MediaContextualLinksTest.php \Drupal\Tests\media\Functional\MediaContextualLinksTest
- 9 core/modules/media/tests/src/Functional/MediaContextualLinksTest.php \Drupal\Tests\media\Functional\MediaContextualLinksTest
Tests views contextual links on media items.
@group media
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\Tests\media\Functional\MediaFunctionalTestBase uses MediaFunctionalTestTrait, MediaTypeCreationTrait
- class \Drupal\Tests\media\Functional\MediaContextualLinksTest
- class \Drupal\Tests\media\Functional\MediaFunctionalTestBase uses MediaFunctionalTestTrait, MediaTypeCreationTrait
Expanded class hierarchy of MediaContextualLinksTest
File
- core/
modules/ media/ tests/ src/ Functional/ MediaContextualLinksTest.php, line 12
Namespace
Drupal\Tests\media\FunctionalView source
class MediaContextualLinksTest extends MediaFunctionalTestBase {
/**
* {@inheritdoc}
*/
protected static $modules = [
'contextual',
];
/**
* {@inheritdoc}
*/
protected $defaultTheme = 'stark';
/**
* Tests contextual links.
*/
public function testMediaContextualLinks() {
\Drupal::configFactory()
->getEditable('media.settings')
->set('standalone_url', TRUE)
->save(TRUE);
$this->container
->get('router.builder')
->rebuild();
// Create a media type.
$mediaType = $this
->createMediaType('test');
// Create a media item.
$media = Media::create([
'bundle' => $mediaType
->id(),
'name' => 'Unnamed',
]);
$media
->save();
$user = $this
->drupalCreateUser([
'administer media',
'access contextual links',
]);
$this
->drupalLogin($user);
$this
->drupalGet('media/' . $media
->id());
$this
->assertSession()
->elementAttributeContains('css', 'div[data-contextual-id]', 'data-contextual-id', 'media:media=' . $media
->id() . ':');
}
}