Skip to content

Commit

Permalink
use fetcherConfig
Browse files Browse the repository at this point in the history
Signed-off-by: Benjamin Brahmer <info@b-brahmer.de>
  • Loading branch information
Grotax committed Aug 24, 2023
1 parent 38af7d1 commit 6892492
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 13 deletions.
12 changes: 5 additions & 7 deletions lib/Fetcher/FeedFetcher.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
use Net_URL2;
use OCP\IL10N;
use OCP\ITempManager;
use OCP\IConfig;

use OCA\News\Db\Item;
use OCA\News\Db\Feed;
Expand Down Expand Up @@ -75,9 +74,9 @@ class FeedFetcher implements IFeedFetcher
private $logger;

/**
* @var IConfig
* @var FetcherConfig
*/
private $iConfig;
private $fetcherConfig;

public function __construct(
FeedIo $fetcher,
Expand All @@ -87,7 +86,7 @@ public function __construct(
ITempManager $ITempManager,
Time $time,
LoggerInterface $logger,
IConfig $iConfig
FetcherConfig $fetcherConfig
) {
$this->reader = $fetcher;
$this->faviconFactory = $favicon;
Expand All @@ -96,7 +95,7 @@ public function __construct(
$this->ITempManager = $ITempManager;
$this->time = $time;
$this->logger = $logger;
$this->iConfig = $iConfig;
$this->fetcherConfig = $fetcherConfig;
}


Expand Down Expand Up @@ -409,7 +408,6 @@ protected function getFavicon(FeedInterface $feed, string $url): ?string
try {
// Base_uri can only be set on creation, will be used when link is relative.
$client = new Client(['base_uri' => $base_url]);
$fetcherConfig = new FetcherConfig($this->iConfig);
$response = $client->request(
'GET',
$favicon,
Expand All @@ -419,7 +417,7 @@ protected function getFavicon(FeedInterface $feed, string $url): ?string
'User-Agent' => FetcherConfig::DEFAULT_USER_AGENT,
'Accept' => 'image/*',
'If-Modified-Since' => date(DateTime::RFC7231, $last_modified),
'Accept-Encoding' => $fetcherConfig->checkEncoding()
'Accept-Encoding' => $this->fetcherConfig->checkEncoding()
]
]
);
Expand Down
12 changes: 6 additions & 6 deletions tests/Unit/Fetcher/FeedFetcherTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@
use \OCA\News\Db\Item;
use OCA\News\Scraper\Scraper;
use OCA\News\Fetcher\FeedFetcher;
use GuzzleHttp\Client;
use OCA\News\Config\FetcherConfig;

use OCA\News\Utility\Time;
use OCP\IL10N;
use OCP\ITempManager;
use OCP\IConfig;

use PHPUnit\Framework\MockObject\MockObject;
use PHPUnit\Framework\TestCase;
use Psr\Log\LoggerInterface;
Expand Down Expand Up @@ -109,9 +109,9 @@ class FeedFetcherTest extends TestCase
private $scraper;

/**
* @var MockObject|iConfig
* @var MockObject|FetcherConfig
*/
private $iConfig;
private $fetcherConfig;

//metadata
/**
Expand Down Expand Up @@ -195,7 +195,7 @@ protected function setUp(): void
$this->scraper = $this->getMockBuilder(Scraper::class)
->disableOriginalConstructor()
->getMock();
$this->iConfig = $this->getMockBuilder(IConfig::class)
$this->fetcherConfig = $this->getMockBuilder(FetcherConfig::class)
->disableOriginalConstructor()
->getMock();
$this->fetcher = new FeedFetcher(
Expand All @@ -206,7 +206,7 @@ protected function setUp(): void
$this->ITempManager,
$timeFactory,
$this->logger,
$this->iConfig
$this->fetcherConfig
);
$this->url = 'http://tests/';

Expand Down

0 comments on commit 6892492

Please sign in to comment.