Add feed refreshing stubs

This commit is contained in:
J. King 2021-02-05 09:04:00 -05:00
parent ab1cf7447b
commit dd29ef6c1b
2 changed files with 32 additions and 0 deletions

View file

@ -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)));

View file

@ -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"));
}
}