Skip to content

Commit

Permalink
d10 update
Browse files Browse the repository at this point in the history
  • Loading branch information
wilso929 authored and wilso929 committed Oct 19, 2023
1 parent cdfc6d0 commit e37936b
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
6 changes: 4 additions & 2 deletions src/Plugin/Field/FieldFormatter/ReplayWebPageFormatter.php
Original file line number Diff line number Diff line change
Expand Up @@ -83,10 +83,12 @@ public function settingsSummary() {
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$element = [];
$media = $items->getEntity();
$ent = $items->getEntity();

if ($media->hasField('field_base_url') && $media->hasField('field_media_file')) {
if ($ent->hasField('field_base_url') && $ent->hasField('field_media_file')) {
// get direct path to file
/** @var \Drupal\media\Entity\Media $media */
$media = $ent;
$fid = $media->getSource()->getSourceFieldValue($media);
$file = File::load($fid);
$uri = $file->getFileUri();
Expand Down
6 changes: 3 additions & 3 deletions tests/src/Functional/DisplayTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ protected function setUp(): void {
$data = [];
$data['fields[field_media_file][type]'] = 'replaywebpage_formatter';
$this->submitForm($data, 'Save');
$this->assertSession()->pageTextContains('Your settings have been saved.');
$this->assertSession()->pageTextContainsOnce('Your settings have been saved.');

// upload file
$this->drupalGet('media/add/web_archive');
Expand All @@ -73,7 +73,7 @@ protected function setUp(): void {
$path = \Drupal::service('extension.list.module')->getPath('replaywebpage') . '/tests/files/wikipedia.wacz';
$data['files[field_media_file_0]'] = $path;
$this->submitForm($data, 'Save');
$this->assertSession()->pageTextContains('Web Archive Test has been created.');
$this->assertSession()->pageTextContainsOnce('Web Archive Test has been created.');

// create content type
$this->drupalGet('admin/structure/types/add');
Expand Down Expand Up @@ -114,7 +114,7 @@ protected function setUp(): void {
*/
public function testPlayerWarcDisplay() {
$this->drupalGet('node/1');
$this->assertSession()->responseMatches('~https://cdn.jsdelivr.net/npm/replaywebpage@[\d\.]+/ui.js~');
$this->assertSession()->responseContains('~https://cdn.jsdelivr.net/npm/replaywebpage@[\d\.]+/ui.js~');
$this->assertSession()->responseContains('wikipedia.wacz');
$this->assertSession()->responseContains('https://en.wikipedia.org/wiki/Pok%C3%A9mon');
}
Expand Down

0 comments on commit e37936b

Please sign in to comment.