Browse Source

Add feed refreshing stubs

rpm
J. King 3 years ago
parent
commit
dd29ef6c1b
  1. 16
      lib/REST/Miniflux/V1.php
  2. 16
      tests/cases/REST/Miniflux/TestV1.php

16
lib/REST/Miniflux/V1.php

@ -1161,6 +1161,22 @@ class V1 extends \JKingWeb\Arsse\REST\AbstractHandler {
return new EmptyResponse(204);
}
protected function refreshFeed(array $path): ResponseInterface {
// NOTE: This is a no-op; we simply check that the feed exists
try {
Arsse::$db->subscriptionPropertiesGet(Arsse::$user->id, (int) $path[1]);
} catch (ExceptionInput $e) {
return new ErrorResponse("404", 404);
}
return new EmptyResponse(204);
}
protected function refreshAllFeeds(): ResponseInterface {
// NOTE: This is a no-op
// It could be implemented, but the need is considered low since we use a dynamic schedule always
return new EmptyResponse(204);
}
public static function tokenGenerate(string $user, string $label): string {
// Miniflux produces tokenss in base64url alphabet
$t = str_replace(["+", "/"], ["-", "_"], base64_encode(random_bytes(self::TOKEN_LENGTH)));

16
tests/cases/REST/Miniflux/TestV1.php

@ -921,4 +921,20 @@ class TestV1 extends \JKingWeb\Arsse\Test\AbstractTest {
[new ExceptionInput("subjectMissing"), null, new ErrorResponse("404", 404)],
];
}
public function testRefreshAFeed(): void {
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenReturn([]);
$this->assertMessage(new EmptyResponse(204), $this->req("PUT", "/feeds/47/refresh"));
\Phake::verify(Arsse::$db)->subscriptionPropertiesGet(Arsse::$user->id, 47);
}
public function testRefreshAMissingFeed(): void {
\Phake::when(Arsse::$db)->subscriptionPropertiesGet->thenThrow(new ExceptionInput("subjectMissing"));
$this->assertMessage(new ErrorResponse("404", 404), $this->req("PUT", "/feeds/2112/refresh"));
\Phake::verify(Arsse::$db)->subscriptionPropertiesGet(Arsse::$user->id, 2112);
}
public function testRefreshAllFeeds(): void {
$this->assertMessage(new EmptyResponse(204), $this->req("PUT", "/feeds/refresh"));
}
}

Loading…
Cancel
Save