diff --git a/src/Plugin/Field/FieldFormatter/ReplayWebPageFormatter.php b/src/Plugin/Field/FieldFormatter/ReplayWebPageFormatter.php index fe13b3d..06c9d8e 100644 --- a/src/Plugin/Field/FieldFormatter/ReplayWebPageFormatter.php +++ b/src/Plugin/Field/FieldFormatter/ReplayWebPageFormatter.php @@ -83,6 +83,7 @@ public function settingsSummary() { */ public function viewElements(FieldItemListInterface $items, $langcode) { $element = []; + /** @var \Drupal\media\Entity\Media $media */ $media = $items->getEntity(); if ($media->hasField('field_base_url') && $media->hasField('field_media_file')) { diff --git a/tests/src/Functional/DisplayTest.php b/tests/src/Functional/DisplayTest.php index c900573..1b7a113 100644 --- a/tests/src/Functional/DisplayTest.php +++ b/tests/src/Functional/DisplayTest.php @@ -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'); @@ -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'); @@ -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'); }