MediaContextualLinksTest.php in Drupal 8
File
core/modules/media/tests/src/Functional/MediaContextualLinksTest.php
View source
<?php
namespace Drupal\Tests\media\Functional;
use Drupal\media\Entity\Media;
class MediaContextualLinksTest extends MediaFunctionalTestBase {
public static $modules = [
'contextual',
];
protected $defaultTheme = 'stark';
public function testMediaContextualLinks() {
\Drupal::configFactory()
->getEditable('media.settings')
->set('standalone_url', TRUE)
->save(TRUE);
$this->container
->get('router.builder')
->rebuild();
$mediaType = $this
->createMediaType('test');
$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() . ':');
}
}