installEntitySchema('file'); $this->installSchema('file', 'file_usage'); $this->installEntitySchema('media'); $this->installConfig(['language', 'datetime', 'field', 'system']); } /** * Tests some of the tokens provided by media_entity. */ public function testMediaEntityTokens() { // Create a generic media bundle. $bundle_name = $this->randomMachineName(); MediaBundle::create([ 'id' => $bundle_name, 'label' => $bundle_name, 'type' => 'generic', 'type_configuration' => [], 'field_map' => [], 'status' => 1, 'new_revision' => FALSE, ])->save(); // Create a media entity. $media = Media::create([ 'name' => $this->randomMachineName(), 'bundle' => $bundle_name, 'uid' => '1', 'langcode' => Language::LANGCODE_DEFAULT, 'status' => Media::PUBLISHED, ]); $media->save(); $token_service = $this->container->get('token'); $replaced_value = $token_service->replace('[media:name]', ['media' => $media]); $this->assertEquals($media->label(), $replaced_value, 'Token replacement for the media label was sucessful.'); } }