Skip to content
This repository has been archived by the owner on Jan 23, 2023. It is now read-only.

Fix drupal 9 compat (file url) #18

Open
wants to merge 3 commits into
base: 1.x
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/test.yml → .github/workflows/run.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ jobs:

strategy:
matrix:
DRUPAL_TESTING_DRUPAL_VERSION: ['~8.9.0', '~9.2.0']
PHP: ['7.4']
DRUPAL_TESTING_DRUPAL_VERSION: ['~9.2.0']
PHP: ['7.4', '8.0']

steps:
- uses: actions/checkout@v1
Expand Down
2 changes: 1 addition & 1 deletion src/Controller/RssController.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public function buildItems() {
'pubDate' => $this->dateFormatter->format($item->getChangedTime(), 'custom', 'r'),
'author' => $item->field_author->first()->view(), /* @phpstan-ignore-line */
'content:encoded' => $item->field_content->first()->view(), /* @phpstan-ignore-line */
'amzn:heroImage' => ($hero_image = $item->field_hero_image->entity) ? $hero_image->url() : NULL,
'amzn:heroImage' => ($hero_image = $item->field_hero_image->entity) ? $hero_image->createFileUrl(FALSE) : NULL,
'amzn:heroImageCaption' => ($hero_image_caption = $item->field_hero_image_caption->first()) ? $hero_image_caption->view() : NULL, /* @phpstan-ignore-line */
'amzn:introText' => $item->field_intro_text->first()->view(), /* @phpstan-ignore-line */
'amzn:indexContent' => $item->field_index_content->first()->view(), /* @phpstan-ignore-line */
Expand Down
2 changes: 1 addition & 1 deletion tests/fixtures/feed.rss
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<lastBuildDate>Wed, 19 Aug 2020 10:00:00 +1000</lastBuildDate>
<amzn:rssVersion>1.0</amzn:rssVersion>
<item><title>Bacon ipsum</title><amzn:subtitle /><link>http://example.com/bacon</link><pubDate>Wed, 19 Aug 2020 10:00:00 +1000</pubDate><author>Bernd am Grill</author><content:encoded><![CDATA[<p>Bacon ipsum dolor amet chuck tenderloin sirloin, chicken tail kevin doner meatball jerky landjaeger jowl alcatra.</p>
]]></content:encoded><amzn:heroImage /><amzn:heroImageCaption /><amzn:introText><![CDATA[Capicola biltong leberkas hamburger.]]></amzn:introText><amzn:indexContent>False</amzn:indexContent><amzn:products><amzn:product><amzn:productURL>https://amazon.de/dp/asdfghjklk</amzn:productURL><amzn:productHeadline><![CDATA[Bacon cooking]]></amzn:productHeadline><amzn:productSummary><![CDATA[Best backon cooking book ever]]></amzn:productSummary><amzn:rank>1</amzn:rank><amzn:award>Award</amzn:award></amzn:product></amzn:products></item>
]]></content:encoded><amzn:heroImage>http://example.com/test-image.jpg</amzn:heroImage><amzn:heroImageCaption /><amzn:introText><![CDATA[Capicola biltong leberkas hamburger.]]></amzn:introText><amzn:indexContent>False</amzn:indexContent><amzn:products><amzn:product><amzn:productURL>https://amazon.de/dp/asdfghjklk</amzn:productURL><amzn:productHeadline><![CDATA[Bacon cooking]]></amzn:productHeadline><amzn:productSummary><![CDATA[Best backon cooking book ever]]></amzn:productSummary><amzn:rank>1</amzn:rank><amzn:award>Award</amzn:award></amzn:product></amzn:products></item>
<item><title>Bavaria ipsum dolor sit amet Prosd dei Marterl.</title><amzn:subtitle /><link>http://example.com/bavaria</link><pubDate>Wed, 19 Aug 2020 10:00:00 +1000</pubDate><author>Fonsi</author><content:encoded><![CDATA[<p>Bavaria ipsum dolor sit amet Prosd dei Marterl. Diandldrahn boarischer wea ko, dea ko Blosmusi Watschnpladdla no gwiss. Wiavui i auszutzeln Zidern, es!</p>
]]></content:encoded><amzn:heroImage /><amzn:heroImageCaption /><amzn:introText><![CDATA[Schaung kost nix Mamalad gor Mamalad hogg di hera.]]></amzn:introText><amzn:indexContent>False</amzn:indexContent><amzn:products><amzn:product><amzn:productURL>https://amazon.de/dp/asdfghjklk</amzn:productURL><amzn:productHeadline><![CDATA[Bavaria ipsum]]></amzn:productHeadline><amzn:productSummary><![CDATA[Bavaria ipsum dolor sit amet Prosd]]></amzn:productSummary><amzn:rank>1</amzn:rank><amzn:award>Award</amzn:award></amzn:product></amzn:products></item>

Expand Down
7 changes: 7 additions & 0 deletions tests/src/Functional/OnSiteTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

use Drupal\amazon_onsite\Entity\AopFeedItem;
use Drupal\Core\Url;
use Drupal\file\Entity\File;
use Drupal\Tests\BrowserTestBase;

/**
Expand Down Expand Up @@ -55,12 +56,18 @@ public function testFeed() {

$this->drupalLogin($this->anonymousUser);

$file = File::create([
'uri' => 'http://example.com/test-image.jpg',
]);
$file->save();

AopFeedItem::create([
'title' => 'Bacon ipsum',
'field_url' => 'http://example.com/bacon',
'field_author' => 'Bernd am Grill',
'field_content' => 'Bacon ipsum dolor amet chuck tenderloin sirloin, chicken tail kevin doner meatball jerky landjaeger jowl alcatra.',
'field_intro_text' => 'Capicola biltong leberkas hamburger.',
'field_hero_image' => $file->id(),
'changed' => \DateTime::createFromFormat('Y-m-d H:i:s', '2020-08-19 10:00:00')->getTimestamp(),
'field_products' => [
[
Expand Down